You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
We should also [Obsolete(error:true)] all of the nested InterfaceConsts types, such as Android.OS.Binder.InterfaceConsts.
For API-30, we should [Obsolete(error:true)] "interface proxy" types such as Android.Content.ComponentCallbacks2, which contains fields for the android.content.ComponentCallbacks2 interface and lives "alongside" the Android.Content.IComponentCallbacks2 interface. Additionally, all of these fields should be moved into the appropriate C# interface, e.g. every field within Android.Content.ComponentCallbacks2 should reside in the Android.Content.IComponentCallbacks2 type, using C#8 default interface members.
^^ This was done in #600. We did not make them an error to allow a smoother migration path, as the new members would not be available in API-29.
We should also [Obsolete(error:true)] all members which are already [Obsolete].
^^ I'm not aware of any additional members that need to be changed.
I am somewhat concerned about removing the InterfaceConsts classes. The scenario they "fix" is allowing the constants on an inherited interface to be accessed through the implementing class.
For example:
interface IFoo { public const int Bar = 3; }
class Baz : IFoo { }
In Java, you can access this as an "inherited constant" like this:
new Baz ().Bar
Because we didn't have interface constants in C#, the constant is moved to a class, which we cannot inherit from or we break the inheritance hierarchy:
class Foo { public const int Bar = 3; }
class Baz : Java.Lang.Object
Obviously new Baz ().Bar doesn't work here. The workaround was to create the nested InterfaceConsts which theoretically makes it slightly more findable, in that you can do this:
new Baz ().InterfaceConsts.Bar
With C#8, we now have interface constants, but the way they work in C# means they are only available on the interface and are not accessible via inheritance, thus new Baz ().Bar still doesn't work, even though Baz inherits an interface with a Bar constant. It is only accessible as IFoo.Bar.
Thus, we have not eliminated the problem InterfaceConsts were trying to fix in the first place: we still do not allow a literal translation from Java code.
One can argue that InterfaceConsts should be removed just because it's a bad solution in the first place, but we should not remove it simply because we think C#8 fixes the problem it attempts to solve.
Activity
jpobst commentedon Apr 14, 2020
I am somewhat concerned about removing the
InterfaceConstsclasses. The scenario they "fix" is allowing the constants on an inherited interface to be accessed through the implementing class.For example:
In Java, you can access this as an "inherited constant" like this:
Because we didn't have interface constants in C#, the constant is moved to a class, which we cannot inherit from or we break the inheritance hierarchy:
Obviously
new Baz ().Bardoesn't work here. The workaround was to create the nestedInterfaceConstswhich theoretically makes it slightly more findable, in that you can do this:With C#8, we now have interface constants, but the way they work in C# means they are only available on the interface and are not accessible via inheritance, thus
new Baz ().Barstill doesn't work, even thoughBazinherits an interface with aBarconstant. It is only accessible asIFoo.Bar.Thus, we have not eliminated the problem
InterfaceConstswere trying to fix in the first place: we still do not allow a literal translation from Java code.One can argue that
InterfaceConstsshould be removed just because it's a bad solution in the first place, but we should not remove it simply because we think C#8 fixes the problem it attempts to solve.jpobst commentedon Apr 15, 2020
We have decided not to proceed with this and will leave the
InterfaceConstsclasses as-is.