Skip to content

Commit dd6e707

Browse files
Bump external/Java.Interop from 3436a30 to 5bca8ad (#8803)
Change: dotnet/java-interop@3436a30...5bca8ad * dotnet/java-interop@5bca8ad6: [build] Automatically add NullableAttributes.cs for netstandard2.0 (dotnet/java-interop#1188) * dotnet/java-interop@45437e22: [Java.Interop] suppress IL3050 with `#pragma` (dotnet/java-interop#1201) * dotnet/java-interop@1c9c8c9c: [Java.Interop.Tools.Maven] Initial commit. (dotnet/java-interop#1179) With dotnet/java-interop@5bca8ad6, all instances of nullable attributes types defined in `NullableAttributes.cs` are now `internal`. However, `Xamarin.Android.Build.Tasks` was consuming the `public` types from its reference to `Java.Interop.Tools.JavaCallableWrappers`, so this change resulted in a build break: MavenExtensions.cs(26,32): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level MamJsonParser.cs(92,43): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level MamJsonParser.cs(92,81): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level We can apply almost the same logic from dotnet/java-interop@5bca8ad6 to `xamarin-android`; the difference is that neither of the `netstandard2.0` projects in xamarin-android that need the attributes have `$(Nullable)='enabled'` and thus our `Condition` fails. (`Xamarin.Android.Build.Tasks.csproj` and `Xamarin.Android.Tools.JavadocImporter.csproj` include `.cs` files from `external/Java.Interop` that have been NRT annotated and thus need the nullable attribute types.) We add `$(Nullable)='annotations'` to the `@(Compile)` which allows one to use NRT syntax but does not emit any NRT warnings since these assemblies have not been converted. We then modify the `NullableAttributes.cs` inclusion logic to additionally key off the `$(Nullable)=annotations` value. Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jonathan Pobst <jonathan.pobst@microsoft.com>
1 parent 3ed7de3 commit dd6e707

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

Directory.Build.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,13 @@
77
<PackageReference Update="Irony" Version="1.1.0" />
88
</ItemGroup>
99

10+
<!-- Automatically add NRT attribute support for netstandard2.0 projects using NRT -->
11+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND ('$(Nullable)' == 'enable' OR '$(Nullable)' == 'annotations') ">
12+
<Compile Include="$(MSBuildThisFileDirectory)external\Java.Interop\src\utils\NullableAttributes.cs" Visible="false" />
13+
</ItemGroup>
14+
15+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND ('$(Nullable)' == 'enable' OR '$(Nullable)' == 'annotations') ">
16+
<DefineConstants>$(DefineConstants);INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
17+
</PropertyGroup>
18+
1019
</Project>

external/Java.Interop

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<NoWarn>8632</NoWarn>
2020
<SignAssembly>false</SignAssembly>
2121
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
22+
<Nullable>annotations</Nullable>
2223
<!-- Causes issues with linker files imported from Mono -->
2324
<NoWarn>$(NoWarn);CA1310;CA1305</NoWarn>
2425
</PropertyGroup>

src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<NoWarn>$(NoWarn);CA1305</NoWarn>
9+
<Nullable>annotations</Nullable>
910
</PropertyGroup>
1011

1112
<Import Project="..\..\Configuration.props" />
@@ -27,9 +28,6 @@
2728
<Compile Include="..\..\external\Java.Interop\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64.Table.cs">
2829
<Link>Crc64.Table.cs</Link>
2930
</Compile>
30-
<Compile Include="..\..\external\Java.Interop\src\utils\NullableAttributes.cs">
31-
<Link>NullableAttributes.cs</Link>
32-
</Compile>
3331
</ItemGroup>
3432

3533
<ItemGroup>

0 commit comments

Comments
 (0)