Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] Add support for $(AndroidEnableObsolete…
…OverrideInheritance). (#8393) Context: dotnet/java-interop@8e63cc8 Context: dotnet/java-interop@d0231c5 dotnet/java-interop@d0231c5c updated generator output so that `[Obsolete]` would automagically "flow" to derived types and method overrides, so that [warning CS0672][0] would not be emitted. Before dotnet/java-interop@d0231c5c, we would emit: public class Context { [Obsolete] public virtual void SetWallpaper () { … } } public class ContextWrapper : Context { [ObsoletedOSPlatform ("android23.0")] public override void SetWallpaper () { … } } `ContextWrapper.SetWallpaper()` would elicit a CS0672 warning: warning CS0672: Member 'ContextWrapper.SetWallpaper()' overrides obsolete member 'Context.SetWallpaper()'. Add the Obsolete attribute to 'ContextWrapper.SetWallpaper()' With dotnet/java-interop@d0231c5c, we now emit the following, which no longer emits CS0672: public class Context { [Obsolete] public virtual void SetWallpaper () { … } } public class ContextWrapper : Context { [Obsolete] public override void SetWallpaper () { … } } While we feel that this is a nice improvement, this broke some customers who didn't want their bindings to automatically gain `[Obsolete]` "just because" they were overriding `[Obsolete]` types or members. In dotnet/java-interop@8e63cc8d, we added the ability to globally *opt-out* of this new behavior by using `generator --lang-features=do-not-fix-obsolete-overrides`. Add a new `$(AndroidEnableObsoleteOverrideInheritance)` MSBuild property. When False, this adds `generator --lang-features=do-not-fix-obsolete-overrides`, preventing the automatic CS0672 fix behavior. By default `$(AndroidEnableObsoleteOverrideInheritance)` is True. [0]: https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0672
- Loading branch information