Skip to content

[Mono.Android] Enable constants on interfaces. #4372

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

Merged
merged 1 commit into from
Mar 13, 2020

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Mar 9, 2020

Context: dotnet/java-interop#509

Beginning with C#8, interfaces may now contain constants. This allows us to better match the android.jar we are binding.

This PR:

  • Enables the generator flag: --lang-features=interface-constants, which will generates constants on interfaces using C#8.
  • This does not remove any previously created constants. We will need to [Obsolete] them in a future PR.

API diff between master API-30 and this PR: https://gist.github.com/jpobst/31c692a67a7f0389895b59cca92480ff

@jonpryor
Copy link
Contributor

API diff is yuge.

@jpobst
Copy link
Contributor Author

jpobst commented Mar 13, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jpobst jpobst marked this pull request as ready for review March 13, 2020 18:00
@jpobst jpobst requested a review from jonpryor as a code owner March 13, 2020 18:00
@jonpryor jonpryor merged commit ccf5023 into master Mar 13, 2020
@jonpryor jonpryor deleted the monoandroid-constants branch March 13, 2020 19:26
jonpryor pushed a commit that referenced this pull request Mar 15, 2020
Context: dotnet/java-interop#509
Context: https://gist.github.com/jpobst/31c692a67a7f0389895b59cca92480ff

Beginning with C#8, interfaces may now contain constants.  This allows
us to better match the `android.jar` we are binding. 

To enable `generator` to emit interfaces which contain constants,
update `$(_LangFeatures)` to contain
`--lang-features=interface-constants` when `$(AndroidApiLeve)` >= 30,
e.g. for API-R preview bindings.

This does not remove any previously created constants.  We will need
to `[Obsolete]` them in a future PR.
@brendanzagaeski
Copy link
Contributor

brendanzagaeski commented Mar 19, 2020

Draft release note

This sounds like it might be interesting to mention under the Preview bindings for Android 11 Developer Preview section that will be in the release notes.

Here's what I'm thinking of adding for this PR:

### Preview bindings for Android 11 Developer Preview

<!-- ... the other notes about this new API level ... -->

A new feature of these bindings is that they take advantage of C# 8.0's support
for static fields on interfaces to provide constants at locations that match the
original Android APIs. For example,
`Android.Views.TextClassifiers.TextClassifierConsts.HintTextIsEditable` is now
available as `Android.Views.TextClassifiers.ITextClassifier.HintTextIsEditable`.

Additionally, default and static interface members from the Android API are now 
available on the C# interfaces.

As a result, in the API-R binding *only*, the `TextClassifierConsts` class has been 
removed, as it has been `[Obsolete]` for 5+ years.  The alternate `TextClassifier` 
*class* where these interface constants and static members have lived has been marked 
`[Obsolete]` in favor of the actual interface.

To suggest something different or to recommend excluding it from the release notes, feel free to reply in this PR or add a Documentation/release-notes/4372.md file with the new suggestion. Thanks in advance!

@jpobst
Copy link
Contributor Author

jpobst commented Mar 19, 2020

@brendanzagaeski Good call, I modified your comment to add some more details.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 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.

3 participants