Commit 7b16e97
[Xamarin.Android.Build.Tasks] Add support for $(AndroidEnableObsoleteOverrideInheritance). (#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/cs06721 parent 2958ae6 commit 7b16e97
4 files changed
Lines changed: 15 additions & 0 deletions
File tree
- Documentation/guides/building-apps
- src/Xamarin.Android.Build.Tasks
- MSBuild/Xamarin/Android
- Microsoft.Android.Sdk/targets
- Tasks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
472 | 481 | | |
473 | 482 | | |
474 | 483 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
220 | 224 | | |
221 | 225 | | |
222 | 226 | | |
| |||
0 commit comments