-
Notifications
You must be signed in to change notification settings - Fork 63
Comparing changes
Open a pull request
base repository: dotnet/java-interop
base: 3894cd76
head repository: dotnet/java-interop
compare: a8f68e56
- 7 commits
- 31 files changed
- 3 contributors
Commits on Jan 11, 2021
-
[global.json] Update Microsoft.Build.NoTargets to 2.0.1. (#775)
Java.Interop is using [`Microsoft.Build.NoTargets` v1.0.110][0], while xamarin/xamarin-android uses [v2.0.1][1]`. This causes some build warnings when building xamarin-android: …/xamarin-android/external/Java.Interop/tools/java-source-utils/java-source-utils.csproj : warning MSB4240: Multiple versions of the same SDK "Microsoft.Build.NoTargets" cannot be specified. The previously resolved SDK version "2.0.1" from location "…/xamarin-android/src/java-runtime/java-runtime.csproj" will be used and the version "1.0.110" will be ignored. Fix this warning by moving the version number from the individual `.csproj` files into a `global.json` with a version matching the value in xamarin-android's `global.json`. [0]: https://www.nuget.org/packages/Microsoft.Build.NoTargets/1.0.110 [1]: https://www.nuget.org/packages/Microsoft.Build.NoTargets/2.0.1
Configuration menu - View commit details
-
Copy full SHA for d1b872a - Browse repository at this point
Copy the full SHA d1b872aView commit details -
[generator] Add [SupportedOSPlatform] in assemblies using ApiSince (#773
) Context: dotnet/android#5338 .NET 5 provides a new [`System.Runtime.Versioning.SupportedOSPlatformAttribute`][0] custom attribute which is used to specify on which platforms and platform versions an API is available. This is used to build analyzers to give users warnings if they are trying to use an API when it will not be available on their target platform. `SupportedOSPlatformAttribute` is fundamentally the same as our existing `RegisterAttribute.ApiSince` property, except tooling has actually been built to consume the information. As such, we need `generator` support to put this information into `Mono.Android.dll`: partial class Activity { // Metadata.xml XPath method reference: path="/api/package[@name='android.app']/class[@name='Activity']/method[@name='dismissKeyboardShortcutsHelper' and count(parameter)=0]" [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android24.0")] [Register ("dismissKeyboardShortcutsHelper", "()V", "", ApiSince = 24)] public unsafe void DismissKeyboardShortcutsHelper () { … } } Some interesting notes: - `SupportedOSPlatformAttribute` is only available in .NET 5+, so we include a local version for earlier frameworks so we can compile without needing to `#ifdef` every attribute use. - The local version is marked as `[Conditional ("NEVER")]` so the attributes will not actually get compiled into the resulting pre-NET5.0 assembly. - The attribute cannot be placed on interfaces or fields, so we aren't able to annotate them. - Our minimum supported API for .NET 6 is 21, so we only write attributes for API added in versions newer than 21, as API added earlier are always available. [0]: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.versioning.supportedosplatformattribute?view=net-5.0
Configuration menu - View commit details
-
Copy full SHA for da12df4 - Browse repository at this point
Copy the full SHA da12df4View commit details -
[Java.Interop] Conditionally call ManagedPeer.Init() (#761)
Context: dotnet/android#5400 Context: dotnet/android#5444 Don't call `ManagedPeer.Init()` from the `JniRuntime` constructor when `XA_JI_EXCLUDE` is `#define`d. The presence of `ManagedPeer.Init()` requires that *all* Xamarin.Android apps contain `System.Linq.Expressions` types after linking, because `ManagedPeer.Construct()` calls `JniEnvironment.Runtime.MarshalMemberBuilder.CreateConstructActivationPeerFunc()` which pulls in all the `System.Linq.Expressions` infrastructure. Currently, *nothing* requires `ManagedPeer` *at all*; Java.Interop- "style" "Java Activation" (8c83f64) is not used outside of unit tests. Consequently, there is no need to pay the cost of System.Linq.Expressions within all Xamarin.Android apps. Wrap the `ManagedPeer.Init()` invocation with `XA_JI_EXCLUDE` so that the Xamarin.Android build of `Java.Interop.dll` (893562c) *excludes* the `ManagedPeer.Init()` invocation. This allows every Xamarin.Android app to link out System.Linq.Expressions, unless the app is otherwise using that namespace. `XA_JI_EXCLUDE` is intended to be set by `$(JavaInteropDefineConstants)` MSBUild property within the optional file `bin/Build$(Configuration)/XAConfig.props`, which the xamarin-android build will create before building `Java.Interop.csproj`. Cleanup the `src/Java.Interop` source code to remove use of the `XA_INTEGRATION` symbol. This symbol is no longer of use, and now only adds noise.
Configuration menu - View commit details
-
Copy full SHA for a77aa33 - Browse repository at this point
Copy the full SHA a77aa33View commit details
Commits on Jan 13, 2021
-
[build] use $(RollForward)=Major for console apps (#778)
Context: https://natemcmaster.com/blog/2019/01/09/netcore-primitives-3/ Context: https://github.com/dotnet/designs/blob/main/accepted/2019/runtime-binding.md#rollforward I've seen an error on a CI machine that has only .NET 5 & 6 installed: Task "BindingsGenerator" ... It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '3.1.0' was not found. - The following frameworks were found: 5.0.1 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 6.0.0-alpha.1.20560.10 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] You can resolve the problem by installing the specified framework and/or SDK. - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=osx.10.15-x64 Xamarin.Android.Bindings.ClassParse.targets(35,5): error MSB6006: "dotnet" exited with code 150. By default, a .NET Core app will only "roll forward" to a patchx release, and as `generator.csproj` targets `netcoreapp3.1`, it would only successfully run on .NET Core 3.1.x. To change this behavior you can add the `rollForward` value to `generator.runtimeconfig.json`: { "runtimeOptions": { "tfm": "netcoreapp3.1", "rollForward": "Major", "framework": { "name": "Microsoft.NETCore.App", "version": "3.1.0" } } } `Major` appears to be what we want to enable it to pick a newer dotnet runtime/sdk. This would allow a .NET Core 3.x to be used or some newer version if no .NET Core 3.x is found: > `RollForward` can have the following values: > > * `LatestPatch` -- Roll forward to the highest patch version. > This disables minor version roll forward. > * `Minor` -- Roll forward to the lowest higher minor version, if > requested minor version is missing. If the requested minor > version is present, then the `LatestPatch` policy is used. > * `Major` -- Roll forward to lowest higher major version, and > lowest minor version, if requested major version is missing. > If the requested major version is present, then the `Minor` > policy is used. We can also use the `$(RollForward)` MSBuild property as an alternative to editing the `*.runtimeconfig.json` file. I think it's likely best to just use this value across the board, as there isn't a reason we *wouldn't* want `generator` or the other command-line tools to run on newer .NET versions.
Configuration menu - View commit details
-
Copy full SHA for 44192fa - Browse repository at this point
Copy the full SHA 44192faView commit details
Commits on Jan 14, 2021
-
[generator] Wrap SupportedOSPlatformAttribute in NET (#779)
Fixes: #777 Commit da12df4 updated `generator` to emit and use a `SupportedOSPlatformAttribute`, wrapping it in `NET5_0_OR_GREATER` to prevent it from being defined in .NET 6: #if !NET5_0_OR_GREATER namespace System.Runtime.Versioning { partial class SupportedOSPlatformAttribute { } } #endif `NET5_0_OR_GREATER` was chosen because, at the time, we believed that it would be defined when building code targeting .NET 5+. Unfortunately, this is not yet the case; it's only in the [design stage][0]. Consequently, when building on xamarin-android CI, [unit tests fail][1] because the `SupportedOSPlatformAttribute` type is defined when it shouldn't be defined: …/DotNetBuildandroid.21-armandroid.21-arm64android.21-x86android.21-x64False/obj/Debug/net6.0-android/UnnamedProject.AssemblyInfo.cs(21,38): warning CS0436: The type 'SupportedOSPlatformAttribute' in '…/DotNetBuildandroid.21-armandroid.21-arm64android.21-x86android.21-x64False/obj/Debug/net6.0-android/generated/src/__NamespaceMapping__.cs' conflicts with the imported type 'SupportedOSPlatformAttribute' in 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Using the type defined in '…/DotNetBuildandroid.21-armandroid.21-arm64android.21-x86android.21-x64False/obj/Debug/net6.0-android/generated/src/__NamespaceMapping__.cs'. (It's a warning, but the containing test asserts that there are no build warnings, hence the failing unit test.) Instead, wrap `SupportedOSPlatformAttribute` in `NET`, which is currently defined when building code for .NET 5+, but *not* defined when building code targeting the Xamarin.Android target frameworks or the `net472` target framework moniker. #if !NET namespace System.Runtime.Versioning { partial class SupportedOSPlatformAttribute { } } #endif [0]: https://github.com/dotnet/designs/blob/6149aa6df1567d4d69e1219247a1e423b775457f/accepted/2020/or-greater-defines/or-greater-defines.md [1]: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4370096&view=ms.vss-test-web.build-test-results-tab&runId=18107834&resultId=100055&paneView=attachments
Configuration menu - View commit details
-
Copy full SHA for a33084b - Browse repository at this point
Copy the full SHA a33084bView commit details -
[generator] Disable [SupportedOSPlatform] until .NET 5/6. (#781)
Context: da12df4 Context: a33084b Context: dotnet/android#5497 (review) We cannot currently build `net5.0` or `net6.0` assemblies in our xamarin-android tree; we instead do some workaround that involves compiling with `netcoreapp3.1` while referencing the 5.0 BCL. This creates a conflict between the local `[SupportedOSPlatform]` we create in `Mono.Android.dll` built for `netcoreapp3.1` , and the real one in the 5.0 BCL. error CS0433: The type 'SupportedOSPlatformAttribute' exists in both 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [/Users/runner/work/1/s/tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop-Tests.NET.csproj] Disable generating `SupportedOSPlatformAttribute` until we can build `Mono.Android.dll` with `NET` defined, in which case it will not contain the local attribute, and we can re-enable da12df4.
Configuration menu - View commit details
-
Copy full SHA for 00862ad - Browse repository at this point
Copy the full SHA 00862adView commit details
Commits on Jan 15, 2021
-
Use
constinstead ofstatic readonly(#782)Context: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1802 To fix this error and improve performance a bit: error CA1802: Field 'invalidStateMessage' is declared as 'readonly' but is initialized with a constant value. Mark this field as 'const' instead. We can't use an interpolated string, or we get the following error on older compilers: error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. We can just use the `+` operator and `const`.
Configuration menu - View commit details
-
Copy full SHA for a8f68e5 - Browse repository at this point
Copy the full SHA a8f68e5View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff 3894cd76...a8f68e56