[API Proposal]: Allow abstract
static
members on classes, not only interfaces.
#6685
Replies: 6 comments 6 replies
-
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Beta Was this translation helpful? Give feedback.
-
I think the label would be "area-Microsoft.CSharp", but honestly i have no ideia, neither have write-permissions. |
Beta Was this translation helpful? Give feedback.
-
This feature request is also related to an "issue" with the new abstract static member feature. For example, I can do this:
But I can not do something like this:
I think it makes sense to allow abstract classes to delegate the implementation of abstract static members. |
Beta Was this translation helpful? Give feedback.
-
Shouldn't this use the |
Beta Was this translation helpful? Give feedback.
-
I must havent tested it before, but @jkindwall actually works for me, as it enables "override-like" behaviour, even tough it uses the opposite keyword "new".
|
Beta Was this translation helpful? Give feedback.
-
Currently this behavior is vital for my upcoming public API, especially with respect to One of my API's features allows binding C# classes to Java classes by name, for interoperability with legacy software. To achieve this, I have an interface I recently ran into a strange behavior with the interface implementation. My class hierarchy is as follows for this scenario:
When writing a method to access this public static JavaClass ByInnerName<TOuter>(string name) where TOuter : IJavaClass {
return ByName($"{TOuter.Class.Name}${name}");
} The call This behavior is potentially an error on its own (it implies that the static |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background and motivation
I was really excited for the feature of statically accessible abstract members that was announced in .NET 7.0 (documented more commonly as Generic Math) . But once i started testing, i realized that only interfaces can declare abstract static members, abstract classes get a compile error instead (CS0112).
This is a request for allowing abstract static members on abstract classes and classes.
I have since implemented some sort of workaround, but its not very intuitive and likely consumes more resources than necessary.
API Proposal
API Usage
Alternative Designs
My current workaround for this issue:
Risks
No response
Beta Was this translation helpful? Give feedback.
All reactions