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
[Xamarin.Android.Build.Tasks] Set .NET6 defaults for bindings projects. #6066
Conversation
7f99d6a
to
3f6adcb
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.
This looks good :)
We do need to document the three new properties in https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/building-apps/build-properties.md though as they are public. This is in addition to the docs you added here already.
Time for our favorite past-time, bikeshedding names! The names in play: The semantics are a tad odd with
Thus, I'm not fond of these names. The actual semantic changes aren't hinted at; it's impossible to know what they actually mean without reading the docs. I would instead suggest:
Though I do wonder if we need this much granularity in a "public-facing" manner. The real question is, are we emitting C#7-compatible interfaces, in which interfaces only contain properties, events and method declarations, or are we emitting C#8-required interfaces, in which interfaces can also contain fields, static methods, methods with bodies, nested types, etc. Thus, should we "unify" them into a single property, e.g. |
Capturing some discussion:
|
Fixes: #4657.
With .NET 6 we want to turn on the following binding project enhancements added with C# 8 by default:
However, each of these features previously had a workaround that we performed so the code could be used by .NET. This means that users who are updating their existing bindings may find API breaks as we now use the new method instead of the workaround. Thus each of these needs a way for the user to opt out of the new behavior to preserve API compatibility.
New MSBuild Properties
<AndroidBoundInterfacesContainConstants>
- Controls whether constants on interfaces will be supported, or the old workaround of creating aIMyInterfaceConsts
class will be used.<AndroidBoundInterfacesContainTypes>
- Controls whether types nested in interfaces will be supported, or the old workaround of creating a non-nested type likeIMyInterfaceMyNestedClass
.<AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods>
- Controls whether default and static members on interfaces will be supported, or the old workaround of creating a sibling class containing static members likeabstract class MyInterface
..NET 6
For .NET 6, the above properties all default to
true
if not explicitly set by the user.Legacy
For legacy, the above properties all default to
false
. The "legacy" way of enabling these features was a single preview flag<_EnableInterfaceMembers>
. We will continue to support this flag for legacy only, and it will enable all the above flags, unless a user has explicitly set one of the flags.AndroidCodegenTarget
.NET 6 binding projects will only support
XAJavaInterop1
, so other values are ignored.