New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[One .NET] implement $(SupportedPlatformOSVersion) for minSdkVersion #6111
[One .NET] implement $(SupportedPlatformOSVersion) for minSdkVersion #6111
Conversation
b4c3a27
to
635f2f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok
This broke a lot of tests:
I'm a bit confused on why I didn't see it locally, looking into it... |
Context: xamarin#6107 (comment) In .NET 6, we are wanting `AndroidManifest.xml` in project templates to no longer contain: <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" /> This is because we can define these values such as: <TargetFramework>net6.0-android30</TargetFramework> <SupportedPlatformOSVersion>21.0</SupportedPlatformOSVersion> There is not really a reason to put this information in two places. `$(SupportedPlatformOSVersion)` is also required for enabling C# compiler warnings such as: MainActivity.cs(28,4): warning CA1416: This call site is reachable on: 'Android' 21.0 and later. 'View.AccessibilityTraversalAfter.get' is only supported on: 'android' 22.0 and later. This is an example of calling an API from 22, with a `$(SupportedPlatformOSVersion)` for 21. If `<uses-sdk/>` is still *used* in `AndroidManifest.xml` in a project, it will be preferred as the final source of truth. One other improvement is that `$(SupportedPlatformOSVersion)` is expected to include `.0`, or you get the warning: UnnamedProject.AssemblyInfo.cs(21,12): warning CA1418: Version '21' is not valid for platform 'Android'. Use a version with 2-4 parts for this platform. Android unique in that this value is always an integer. In order for users to be able to specify `21`, I added a check in `Microsoft.Android.Sdk.DefaultProperties.targets` so that we append `.0` when needed. I added some tests around this scenario.
635f2f3
to
0033d2f
Compare
The problem before was I needed to check if <!-- $(SupportedOSPlatformVersion) must be '21.0', but we should support integer values like '21' -->
<SupportedOSPlatformVersion Condition=" '$(SupportedOSPlatformVersion)' != '' and !$(SupportedOSPlatformVersion.Contains('.')) ">$(SupportedOSPlatformVersion).0</SupportedOSPlatformVersion> |
…amarin#6111) Context: xamarin#6107 (comment) In .NET 6, we are wanting `AndroidManifest.xml` in project templates to no longer contain: <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" /> This is because we can define these values such as: <TargetFramework>net6.0-android30</TargetFramework> <SupportedPlatformOSVersion>21.0</SupportedPlatformOSVersion> There is not really a reason to put this information in two places. `$(SupportedPlatformOSVersion)` is also required for enabling C# compiler warnings such as: MainActivity.cs(28,4): warning CA1416: This call site is reachable on: 'Android' 21.0 and later. 'View.AccessibilityTraversalAfter.get' is only supported on: 'android' 22.0 and later. This is an example of calling an API from 22, with a `$(SupportedPlatformOSVersion)` for 21. If `<uses-sdk/>` is still *used* in `AndroidManifest.xml` in a project, it will be preferred as the final source of truth. One other improvement is that `$(SupportedPlatformOSVersion)` is expected to include `.0`, or you get the warning: UnnamedProject.AssemblyInfo.cs(21,12): warning CA1418: Version '21' is not valid for platform 'Android'. Use a version with 2-4 parts for this platform. Android unique in that this value is always an integer. In order for users to be able to specify `21`, I added a check in `Microsoft.Android.Sdk.DefaultProperties.targets` so that we append `.0` when needed. I added some tests around this scenario.
…6111) Context: #6107 (comment) In .NET 6, we are wanting `AndroidManifest.xml` in project templates to no longer contain: <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" /> This is because we can define these values such as: <TargetFramework>net6.0-android30</TargetFramework> <SupportedPlatformOSVersion>21.0</SupportedPlatformOSVersion> There is not really a reason to put this information in two places. `$(SupportedPlatformOSVersion)` is also required for enabling C# compiler warnings such as: MainActivity.cs(28,4): warning CA1416: This call site is reachable on: 'Android' 21.0 and later. 'View.AccessibilityTraversalAfter.get' is only supported on: 'android' 22.0 and later. This is an example of calling an API from 22, with a `$(SupportedPlatformOSVersion)` for 21. If `<uses-sdk/>` is still *used* in `AndroidManifest.xml` in a project, it will be preferred as the final source of truth. One other improvement is that `$(SupportedPlatformOSVersion)` is expected to include `.0`, or you get the warning: UnnamedProject.AssemblyInfo.cs(21,12): warning CA1418: Version '21' is not valid for platform 'Android'. Use a version with 2-4 parts for this platform. Android unique in that this value is always an integer. In order for users to be able to specify `21`, I added a check in `Microsoft.Android.Sdk.DefaultProperties.targets` so that we append `.0` when needed. I added some tests around this scenario.
https://github.com/dotnet/designs/blob/main/accepted/2021/net6.0-tfms/net6.0-tfms.md For Android class libraries, you can put In the future, you might consider opening an issue instead of commenting on an old PR or comment in the #android channel on Discord. You might get a quicker response that way, thanks! |
Context: #6107 (comment)
In .NET 6, we are wanting
AndroidManifest.xml
in project templatesto no longer contain:
This is because we can define these values such as:
There is not really a reason to put this information in two places.
$(SupportedPlatformOSVersion)
is also required for enabling C#compiler warnings such as:
This is an example of calling an API from 22, with a
$(SupportedPlatformOSVersion)
for 21.If
<uses-sdk/>
is still used inAndroidManifest.xml
in aproject, it will be preferred as the final source of truth.
One other improvement is that
$(SupportedPlatformOSVersion)
isexpected to include
.0
, or you get the warning:Android unique in that this value is always an integer. In order for
users to be able to specify
21
, I added a check inMicrosoft.Android.Sdk.DefaultProperties.targets
so that we append.0
when needed.I added some tests around this scenario.