Skip to content

Commit

Permalink
Bump external/Java.Interop from 3436a30 to 5bca8ad (#8803)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dependabot[bot] and jpobst authored Mar 13, 2024
1 parent 3ed7de3 commit dd6e707
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@
<PackageReference Update="Irony" Version="1.1.0" />
</ItemGroup>

<!-- Automatically add NRT attribute support for netstandard2.0 projects using NRT -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND ('$(Nullable)' == 'enable' OR '$(Nullable)' == 'annotations') ">
<Compile Include="$(MSBuildThisFileDirectory)external\Java.Interop\src\utils\NullableAttributes.cs" Visible="false" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND ('$(Nullable)' == 'enable' OR '$(Nullable)' == 'annotations') ">
<DefineConstants>$(DefineConstants);INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion external/Java.Interop
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<NoWarn>8632</NoWarn>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<Nullable>annotations</Nullable>
<!-- Causes issues with linker files imported from Mono -->
<NoWarn>$(NoWarn);CA1310;CA1305</NoWarn>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn);CA1305</NoWarn>
<Nullable>annotations</Nullable>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />
Expand All @@ -27,9 +28,6 @@
<Compile Include="..\..\external\Java.Interop\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64.Table.cs">
<Link>Crc64.Table.cs</Link>
</Compile>
<Compile Include="..\..\external\Java.Interop\src\utils\NullableAttributes.cs">
<Link>NullableAttributes.cs</Link>
</Compile>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit dd6e707

Please sign in to comment.