Skip to content

Commit

Permalink
[Java.Interop.Tools.TypeNameMappings] introduce project for net8.0 (d…
Browse files Browse the repository at this point in the history
…otnet#1199)

Context: dotnet/android#8751
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=9137456&view=logs&j=96fd57f5-f69e-53c7-3d47-f67e6cf9b93e&s=1afc3bfe-122c-538b-e9ad-2a86c2efcfef&t=38f83f46-bc21-5edd-1614-e44f20babf10&l=29658
Context: 67c079c
Context: 56b7eeb

dotnet/android#8751 has a random build failure:

	"Xamarin.Android.sln" (default target) (1:2) ->
	"src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj" (default target) (28:9) ->
	(CoreCompile target) ->
	    src/Xamarin.Android.Build.Tasks/Utilities/MamJsonParser.cs(92,43): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level [src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
	    src/Xamarin.Android.Build.Tasks/Utilities/MamJsonParser.cs(92,81): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level [src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
	    src/Xamarin.Android.Build.Tasks/Utilities/MavenExtensions.cs(26,32): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level [src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]

It happens some percentage of the time…

Similar to 67c079c, the cause is that commit 56b7eeb updated
`Java.Interop.Tools.JavaCallableWrappers.csproj` to multitarget both
netstandard2.0 and net8.0, and on some builds the
`Java.Interop.Tools.JavaCallableWrappers.dll` used by
`Xamarin.Android.Build.Tasks.csproj` is the net8.0 build, *not* the
netstandard2.0 build.

To fix this:

  * Don't build `Java.Interop.Tools.JavaCallableWrappers.csproj` for
    `net8.0` anymore; remove net8.0 from `$(TargetFrameworks)`.

  * Introduce a new `Java.Interop.Tools.TypeNameMappings.csproj`
    project which builds the source code within
    `Java.Interop.Tools.JavaCallableWrappers.csproj` for net8.0.
    The resulting assembly is not shipped or used.  It can check
    trimmer warnings, though.

This partially reverts 67c079c and 56b7eeb.
  • Loading branch information
jonathanpeppers authored Feb 27, 2024
1 parent bd793f1 commit 14a9470
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
9 changes: 9 additions & 0 deletions Java.Interop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.Tools.Expressi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello-NativeAOTFromJNI", "samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj", "{8DB3842B-73D7-491C-96F9-EBC863E2C917}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{40B3CE2F-B8DE-45CD-A43A-0F1A89BDB803}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.Tools.TypeNameMappings", "src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings.csproj", "{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{58b564a1-570d-4da2-b02d-25bddb1a9f4f}*SharedItemsImports = 5
Expand Down Expand Up @@ -326,6 +330,10 @@ Global
{8DB3842B-73D7-491C-96F9-EBC863E2C917}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DB3842B-73D7-491C-96F9-EBC863E2C917}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DB3842B-73D7-491C-96F9-EBC863E2C917}.Release|Any CPU.Build.0 = Release|Any CPU
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -381,6 +389,7 @@ Global
{1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
{211BAA88-66B1-41B2-88B2-530DBD8DF702} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{8DB3842B-73D7-491C-96F9-EBC863E2C917} = {D5A93398-AEB1-49F3-89DC-3904A47DB0C7}
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9} = {40B3CE2F-B8DE-45CD-A43A-0F1A89BDB803}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {29204E0C-382A-49A0-A814-AD7FBF9774A5}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -13,24 +13,17 @@

<Import Project="..\..\TargetFrameworkDependentValues.props" />

<!-- Only use $(ToolOutputFullPath) for netstandard2.0 -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PropertyGroup>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
<IsTrimmable>true</IsTrimmable>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<Compile Include="..\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings\JavaNativeTypeManager.cs">
<Link>JavaNativeTypeManager.cs</Link>
</Compile>
<Compile Include="..\utils\NullableAttributes.cs" Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<Compile Include="..\utils\NullableAttributes.cs">
<Link>NullableAttributes.cs</Link>
</Compile>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsTrimmable>true</IsTrimmable>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
<DefineConstants>$(DefineConstants);JCW_ONLY_TYPE_NAMES;HAVE_CECIL</DefineConstants>
</PropertyGroup>

<Import Project="..\..\TargetFrameworkDependentValues.props" />
<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<ProjectReference Include="..\Java.Interop.Localization\Java.Interop.Localization.csproj" />
<ProjectReference Include="..\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
<ProjectReference Include="..\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64.cs" />
<Compile Include="..\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64.Table.cs" />
<Compile Include="..\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64Helper.cs" />
</ItemGroup>

<Import Project="..\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems" Label="Shared" Condition="Exists('..\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems')" />

</Project>

0 comments on commit 14a9470

Please sign in to comment.