Skip to content
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

[generator] Add [SupportedOSPlatform] attributes to bound constant fields. #1038

Merged
merged 1 commit into from
Oct 20, 2022

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Sep 15, 2022

Context: #1037

Currently we do not add [SupportedOSPlatform] attributes to bound const fields, which can lead to users using them on platforms where they are not supported:

[Register("ACTION_POST_CALL", ApiSince=30)]
public const string ActionPostCall = "android.telecom.action.POST_CALL";

This commit fixes this:

[Register("ACTION_POST_CALL", ApiSince=30)]
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android30.0")]
public const string ActionPostCall = "android.telecom.action.POST_CALL";

Note this does not address the enum part of #1037, which will require a much more involved fix.

@jpobst jpobst changed the title [generator] Add [SupportedOSPlatform] attributes to bounds constant fields. [generator] Add [SupportedOSPlatform] attributes to bound constant fields. Sep 15, 2022
@jpobst jpobst marked this pull request as ready for review October 20, 2022 14:37
@jonpryor jonpryor merged commit 7dfbab6 into main Oct 20, 2022
@jonpryor jonpryor deleted the supported-os-consts branch October 20, 2022 15:45
jonpryor pushed a commit to dotnet/android that referenced this pull request Nov 1, 2022
Fixes: dotnet/java-interop#1034
Fixes: dotnet/java-interop#1051

Context: 938b2cb

Changes: dotnet/java-interop@e1ee4b1...5318261

  * dotnet/java-interop@53182615: [build] Update Microsoft.* NuGet package versions (dotnet/java-interop#1055)
  * dotnet/java-interop@8e18c909: [generator] Avoid C#11 delegate cache overhead. (dotnet/java-interop#1053)
  * dotnet/java-interop@2d8b6d24: [generator] More AttributeTargets on SupportedOSPlatformAttribute (dotnet/java-interop#1054)
  * dotnet/java-interop@7dfbab67: [generator] Add [SupportedOSPlatform] to bound constant fields (dotnet/java-interop#1038)
  * dotnet/java-interop@1720628a: [generator] Mark generated .cs files as generated (dotnet/java-interop#1052)
  * dotnet/java-interop@f498fcf5: [Java.Interop] Avoid some method group conversions (dotnet/java-interop#1050)
  * dotnet/java-interop@16e1ecd4: [build] Use $(VSINSTALLDIR), not $(VSINSTALLROOT) (dotnet/java-interop#1048)
  * dotnet/java-interop@8e4c7d20: [Hello-Core] Add "low level" sample. (dotnet/java-interop#1047)

Additionally, remove `$(LangVersion)`=10 from `Mono.Android.csproj`,
which was a hack to work around a size regression due to delegate
caching in C# 11; see also 938b2cb, dotnet/java-interop@8e18c909.

Co-authored-by: Jonathan Pobst <jonathan.pobst@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants