Skip to content

Commit 14a9470

Browse files
[Java.Interop.Tools.TypeNameMappings] introduce project for net8.0 (#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.
1 parent bd793f1 commit 14a9470

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

Java.Interop.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.Tools.Expressi
115115
EndProject
116116
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello-NativeAOTFromJNI", "samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj", "{8DB3842B-73D7-491C-96F9-EBC863E2C917}"
117117
EndProject
118+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{40B3CE2F-B8DE-45CD-A43A-0F1A89BDB803}"
119+
EndProject
120+
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}"
121+
EndProject
118122
Global
119123
GlobalSection(SharedMSBuildProjectFiles) = preSolution
120124
src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{58b564a1-570d-4da2-b02d-25bddb1a9f4f}*SharedItemsImports = 5
@@ -326,6 +330,10 @@ Global
326330
{8DB3842B-73D7-491C-96F9-EBC863E2C917}.Debug|Any CPU.Build.0 = Debug|Any CPU
327331
{8DB3842B-73D7-491C-96F9-EBC863E2C917}.Release|Any CPU.ActiveCfg = Release|Any CPU
328332
{8DB3842B-73D7-491C-96F9-EBC863E2C917}.Release|Any CPU.Build.0 = Release|Any CPU
333+
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
334+
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
335+
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
336+
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9}.Release|Any CPU.Build.0 = Release|Any CPU
329337
EndGlobalSection
330338
GlobalSection(SolutionProperties) = preSolution
331339
HideSolutionNode = FALSE
@@ -381,6 +389,7 @@ Global
381389
{1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
382390
{211BAA88-66B1-41B2-88B2-530DBD8DF702} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
383391
{8DB3842B-73D7-491C-96F9-EBC863E2C917} = {D5A93398-AEB1-49F3-89DC-3904A47DB0C7}
392+
{C2AF6ACF-04F6-4B41-95EA-97A372C075F9} = {40B3CE2F-B8DE-45CD-A43A-0F1A89BDB803}
384393
EndGlobalSection
385394
GlobalSection(ExtensibilityGlobals) = postSolution
386395
SolutionGuid = {29204E0C-382A-49A0-A814-AD7FBF9774A5}

src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.csproj

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<LangVersion>11.0</LangVersion>
66
<Nullable>enable</Nullable>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -13,24 +13,17 @@
1313

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

16-
<!-- Only use $(ToolOutputFullPath) for netstandard2.0 -->
17-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
16+
<PropertyGroup>
1817
<OutputPath>$(ToolOutputFullPath)</OutputPath>
1918
</PropertyGroup>
2019

21-
<PropertyGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
22-
<IsTrimmable>true</IsTrimmable>
23-
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
24-
<EnableAotAnalyzer>true</EnableAotAnalyzer>
25-
</PropertyGroup>
26-
2720
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
2821

2922
<ItemGroup>
3023
<Compile Include="..\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings\JavaNativeTypeManager.cs">
3124
<Link>JavaNativeTypeManager.cs</Link>
3225
</Compile>
33-
<Compile Include="..\utils\NullableAttributes.cs" Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
26+
<Compile Include="..\utils\NullableAttributes.cs">
3427
<Link>NullableAttributes.cs</Link>
3528
</Compile>
3629
</ItemGroup>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
4+
<Nullable>enable</Nullable>
5+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6+
<IsTrimmable>true</IsTrimmable>
7+
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
8+
<EnableAotAnalyzer>true</EnableAotAnalyzer>
9+
<DefineConstants>$(DefineConstants);JCW_ONLY_TYPE_NAMES;HAVE_CECIL</DefineConstants>
10+
</PropertyGroup>
11+
12+
<Import Project="..\..\TargetFrameworkDependentValues.props" />
13+
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\Java.Interop.Localization\Java.Interop.Localization.csproj" />
17+
<ProjectReference Include="..\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
18+
<ProjectReference Include="..\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<Compile Include="..\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64.cs" />
23+
<Compile Include="..\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64.Table.cs" />
24+
<Compile Include="..\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers\Crc64Helper.cs" />
25+
</ItemGroup>
26+
27+
<Import Project="..\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems" Label="Shared" Condition="Exists('..\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems')" />
28+
29+
</Project>

0 commit comments

Comments
 (0)