Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@
<!-- Note: MUST be imported *after* $(Configuration) is set! -->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<!-- Mono's MSBuild does not support some implicit .NET6 source generator stuff -->
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release' And '$(MSBuildRuntimeType)' != 'Mono' ">true</TreatWarningsAsErrors>
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release' ">true</TreatWarningsAsErrors>
<_OutputPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</_OutputPath>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
<DotNetTargetFrameworkVersion>7.0</DotNetTargetFrameworkVersion>
<DotNetTargetFramework>net$(DotNetTargetFrameworkVersion)</DotNetTargetFramework>
<!--
Workaround for https://github.com/NuGet/Home/issues/6461 (VSWin Only)
Even though we don't build NuGet packages, it still attempts to build the NuGet package name, which includes
the assembly version if PackageVersion isn't specified. Because our assemblies have different versions
per-TFM, that causes a problem because the package can't have multiple versions in it.
Set a dummy PackageVersion because we don't actually need it.
-->
<PackageVersion>1.0.0.0</PackageVersion>
</PropertyGroup>

<Import
Expand Down Expand Up @@ -76,19 +67,10 @@
</PropertyGroup>

<!--
When building on a bot w/ VS2019:

warning CS8032: An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from

however, with `$(TreatWarningsAsErrors)`=True, this becomes an error,
meaning we can't build on VS2019.

Ignore CS8032 so that we can build on VS2019.

JniEnvironment.g.cs(34,8): error CS8981: The type name 'jobject' only contains lower-cased ascii characters. Such names may become reserved for the language.
-->
<PropertyGroup>
<NoWarn>$(NoWarn);CS8032;CS8981</NoWarn>
<NoWarn>$(NoWarn);CS8981</NoWarn>
</PropertyGroup>

</Project>
35 changes: 11 additions & 24 deletions TargetFrameworkDependentValues.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<PropertyGroup Condition=" '$(TargetFramework)' != '' And (!$(TargetFramework.StartsWith('nets')) And !$(TargetFramework.StartsWith('net4')) And !$(TargetFramework.StartsWith('monoandroid'))) ">
<PropertyGroup Condition=" '$(TargetFramework)' != '' And !$(TargetFramework.StartsWith('nets')) ">
<JIBuildingForNetCoreApp>True</JIBuildingForNetCoreApp>
</PropertyGroup>

<PropertyGroup Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)-$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)-$(TargetFramework.ToLowerInvariant())\</BuildToolOutputFullPath>
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)-$(TargetFramework.ToLowerInvariant())\</ToolOutputFullPath>
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)-$(TargetFramework.ToLowerInvariant())\</TestOutputFullPath>
<PropertyGroup>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)-$(DotNetTargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we "follow convention" and instead use $(BaseIntermediateOutputPath)\$(Configuration)\$(DotNetTargetFramework.ToLowerInvariant())\? Since e.g. bin/Debug/class-parse.exe won't be built anymore, the only assemblies in bin/Debug will be those for .NET Standard, and there are fewer of those running around…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have an opinion here. I went back and forth on this and eventually chose to follow the convention we use in xamarin-android. I guess it's nice if you change branches between something that is net7.0 or net8.0 they won't clobber each other, but that's not much of a reason.

<BuildToolOutputFullPathNoTF>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</BuildToolOutputFullPathNoTF>
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)-$(DotNetTargetFramework.ToLowerInvariant())\</BuildToolOutputFullPath>
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)-$(DotNetTargetFramework.ToLowerInvariant())\</ToolOutputFullPath>
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)-$(DotNetTargetFramework.ToLowerInvariant())\</TestOutputFullPath>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' != '' ">$(UtilityOutputFullPathCoreApps)</UtilityOutputFullPath>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
<_XamarinAndroidCecilPath Condition=" '$(CecilSourceDirectory)' != '' And Exists('$(UtilityOutputFullPathCoreApps)Xamarin.Android.Cecil.dll') ">$(UtilityOutputFullPathCoreApps)Xamarin.Android.Cecil.dll</_XamarinAndroidCecilPath>
Expand All @@ -18,32 +19,18 @@
<JICoreLibVersion>$(JINetCoreLibVersion)</JICoreLibVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</BuildToolOutputFullPath>
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</ToolOutputFullPath>
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)\</TestOutputFullPath>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
<_XamarinAndroidCecilPath Condition=" '$(CecilSourceDirectory)' != '' And Exists('$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll') ">$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll</_XamarinAndroidCecilPath>
<JIUtilityVersion>$(JIOldToolVersion)</JIUtilityVersion>
<JICoreLibVersion>$(JIOldCoreLibVersion)</JICoreLibVersion>
</PropertyGroup>

<PropertyGroup>
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(BuildToolOutputFullPath)jnienv-gen.dll</_JNIEnvGenPath>
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(BuildToolOutputFullPath)jnienv-gen.exe</_JNIEnvGenPath>
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(DotnetToolPath) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
<_JNIEnvGenPath>$(BuildToolOutputFullPath)jnienv-gen.dll</_JNIEnvGenPath>
<_RunJNIEnvGen>$(DotnetToolPath) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
</PropertyGroup>

<!-- The net6.0 versions of these are stricter and require overloads not available in .NET Framework, so start with just .NET Framework -->
<PropertyGroup Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">
<PropertyGroup>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<WarningsAsErrors>$(WarningsAsErrors);CA1307;CA1309;CA1310</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">
<PropertyGroup>
<NoWarn>$(NoWarn);CA1307;CA1309;CA1310</NoWarn>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
<Import Project="..\..\TargetFrameworkDependentValues.props" />

<PropertyGroup>
<OutputPath>$(BuildToolOutputFullPath)</OutputPath>
</PropertyGroup>

<PropertyGroup>
<OutputPath>$(BuildToolOutputFullPath)</OutputPath>
<OutputPath>$(BuildToolOutputFullPathNoTF)</OutputPath>
<GitDefaultBranch>main</GitDefaultBranch>
<GitThisAssembly>false</GitThisAssembly>
</PropertyGroup>
Expand Down
103 changes: 3 additions & 100 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variables:
RunningOnCI: true
Build.Configuration: Release
MaxJdkVersion: 8
DotNetCoreVersion: 7.0.100-rc.1.22431.12
DotNetCoreVersion: 7.x
DotNetTargetFramework: net7.0
NetCoreTargetFrameworkPathSuffix: -$(DotNetTargetFramework)
1ESWindowsPool: AzurePipelines-EO
Expand All @@ -31,56 +31,8 @@ variables:
DisablePipelineConfigDetector: true

jobs:
- job: windows_build
displayName: Windows - .NET Framework
pool:
name: $(1ESWindowsPool)
demands:
- ImageOverride -equals $(1ESWindowsImage)
timeoutInMinutes: 20
workspace:
clean: all
steps:
- checkout: self
submodules: recursive

- template: templates\install-dependencies.yaml

- task: MSBuild@1
displayName: MSBuild Java.Interop.sln /t:Restore
inputs:
solution: Java.Interop.sln
configuration: $(Build.Configuration)
msbuildArguments: /t:Restore /p:RestoreConfigFile=$(System.DefaultWorkingDirectory)\external\xamarin-android-tools\NuGet.config

- task: MSBuild@1
displayName: MSBuild Java.Interop.sln /t:Prepare
inputs:
solution: Java.Interop.sln
configuration: $(Build.Configuration)
msbuildArguments: /restore /t:Prepare

- task: MSBuild@1
displayName: MSBuild Java.Interop.sln
inputs:
solution: Java.Interop.sln
configuration: $(Build.Configuration)
msbuildArguments: /restore

- task: MSBuild@1
displayName: MSBuild RunNUnitTests.targets
inputs:
solution: build-tools/scripts/RunNUnitTests.targets
configuration: $(Build.Configuration)
msbuildArguments: /p:TestAssembly="bin\Test$(Build.Configuration)\generator-Tests.dll;bin\Test$(Build.Configuration)\Java.Interop.Tools.JavaCallableWrappers-Tests.dll;bin\Test$(Build.Configuration)\logcat-parse-Tests.dll;bin\Test$(Build.Configuration)\Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll;bin\Test$(Build.Configuration)\Java.Interop.Tools.JavaTypeSystem-Tests.dll;bin\Test$(Build.Configuration)\Xamarin.Android.Tools.Bytecode-Tests.dll;bin\Test$(Build.Configuration)\Java.Interop.Tools.Generator-Tests.dll;bin\Test$(Build.Configuration)\Xamarin.SourceWriter-Tests.dll"
condition: succeededOrFailed()

- template: templates\publish-test-results.yaml
parameters:
platformName: .NET Framework - Windows

- job: windows_dotnet_build
displayName: Windows - .NET Core
displayName: Windows - .NET
pool:
name: $(1ESWindowsPool)
demands:
Expand Down Expand Up @@ -121,57 +73,8 @@ jobs:
ArtifactName: debug
condition: succeededOrFailed()

- job: mac_build
displayName: Mac - Mono
pool:
name: $(1ESMacPool)
vmImage: $(1ESMacImage)
timeoutInMinutes: 20
workspace:
clean: all
steps:
- checkout: self
submodules: recursive

- template: templates\install-dependencies.yaml

- script: >
dotnet tool install --global boots &&
boots https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.145.macos10.xamarin.universal.pkg
displayName: Install Mono

- template: templates\core-build.yaml

- script: |
r=0
make run-all-tests CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion) || r=$?
jar cf xatb.jar -C tests/Xamarin.Android.Tools.Bytecode-Tests/obj/*/classes .
zip -r bin.zip bin
exit $r
displayName: Run Tests

- template: templates\publish-test-results.yaml
parameters:
platformName: Mono - Mac

- task: CopyFiles@2
displayName: 'Copy Files to: Artifact Staging Directory'
inputs:
SourceFolder: $(System.DefaultWorkingDirectory)
Contents: |
xatb.jar
bin.zip
TargetFolder: $(Build.ArtifactStagingDirectory)
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: debug'
inputs:
ArtifactName: debug
condition: succeededOrFailed()

- job: mac_dotnet_build
displayName: Mac - .NET Core
displayName: Mac - .NET
pool:
name: $(1ESMacPool)
vmImage: $(1ESMacImage)
Expand Down
20 changes: 0 additions & 20 deletions build-tools/automation/templates/core-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@ steps:
arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Xamarin.SourceWriter-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop'
condition: eq('${{ parameters.runNativeTests }}', 'true')
inputs:
command: test
testRunTitle: Java.Interop (netstandard2.0 - ${{ parameters.platformName }})
arguments: bin/Test$(Build.Configuration)/Java.Interop-Tests.dll
continueOnError: true
retryCountOnTaskFailure: 1

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop'
condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
Expand Down Expand Up @@ -136,16 +126,6 @@ steps:
continueOnError: true
retryCountOnTaskFailure: 1

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop-Performance-net472'
condition: eq('${{ parameters.runNativeTests }}', 'true')
inputs:
command: test
testRunTitle: Java.Interop-Performance (net472 - ${{ parameters.platformName }})
arguments: bin/Test$(Build.Configuration)/Java.Interop-PerformanceTests.dll
continueOnError: true
retryCountOnTaskFailure: 1

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop-Performance-$(DotNetTargetFramework)'
condition: eq('${{ parameters.runNativeTests }}', 'true')
Expand Down
3 changes: 1 addition & 2 deletions build-tools/automation/templates/install-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ parameters:

steps:
- task: UseDotNet@2
displayName: Use .NET Core $(DotNetCoreVersion)
displayName: Use .NET $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)
includePreviewVersions: true
2 changes: 1 addition & 1 deletion build-tools/jnienv-gen/jnienv-gen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/Java.Interop.Dynamic/Java.Interop.Dynamic.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
<LangVersion>8.0</LangVersion>
<ProjectGuid>{AD4468F8-8883-434B-9D4C-E1801BB3B52A}</ProjectGuid>
<Nullable>enable</Nullable>
<Nullable>annotations</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
Expand Down
2 changes: 1 addition & 1 deletion src/Java.Interop.Export/Java.Interop.Export.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
<LangVersion>9.0</LangVersion>
<ProjectGuid>{B501D075-6183-4E1D-92C9-F7B5002475B1}</ProjectGuid>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
<ProjectGuid>{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly>
Expand All @@ -20,12 +20,7 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Java.Interop\Java.Interop.csproj">
<Project>{94BD81F7-B06F-4295-9636-F8A3B6BDC762}</Project>
<Name>Java.Interop</Name>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<AdditionalProperties>TargetFramework=netstandard2.0</AdditionalProperties>
</ProjectReference>
<ProjectReference Include="..\Java.Interop\Java.Interop.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
Expand Down
9 changes: 9 additions & 0 deletions src/Java.Interop.Localization/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Java.Interop.Localization/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ The following terms should not be translated: Metadata.xml.</comment>
<value>Invalid namespace transform '{0}'</value>
<comment>{0} - XML transform. (example: '&lt;ns-replace source="example" replacement="Example" /&gt;')</comment>
</data>
<data name="Generator_BG8A08" xml:space="preserve">
<value>Metadata.xml element '{0}' is missing the 'path' attribute.</value>
<comment>{0} - XML transform. (example: '&lt;remove-node path="/api/package[@name='javax.sql']"')
The following terms should not be translated: Metadata.xml, path.</comment>
</data>
<data name="Generator_BG8B00" xml:space="preserve">
<value>Unknown generic argument constraint type '{0}' for member '{1}'.</value>
<comment>{0} - .NET type name
Expand Down
10 changes: 5 additions & 5 deletions src/Java.Interop.Tools.Generator/Enumification/ConstantEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ public static ConstantEntry FromElement (XElement elem)
var entry = new ConstantEntry {
Action = ConstantAction.None,
ApiLevel = NamingConverter.ParseApiLevel (elem),
JavaSignature = elem.Parent.Parent.Attribute ("name").Value,
JavaSignature = elem.Parent?.Parent?.Attribute ("name")?.Value,
Value = elem.Attribute ("value")?.Value,
};

var java_package = elem.Parent.Parent.Attribute ("name").Value.Replace ('.', '/');
var java_type = elem.Parent.Attribute ("name").Value.Replace ('.', '$');
var java_member = elem.Attribute ("name").Value;
var java_package = elem.Parent?.Parent?.Attribute ("name")?.Value.Replace ('.', '/');
var java_type = elem.Parent?.Attribute ("name")?.Value.Replace ('.', '$');
var java_member = elem.Attribute ("name")?.Value;

entry.JavaSignature = $"{java_package}/{java_type}.{java_member}".TrimStart ('/');

// Interfaces get an "I:" prefix
if (elem.Parent.Name.LocalName == "interface")
if (elem.Parent?.Name.LocalName == "interface")
entry.JavaSignature = "I:" + entry.JavaSignature;

return entry;
Expand Down
Loading