Training
Module
Learn coding practices to help prevent the occurrence of NullReferenceException.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
.NET 6 previews a new feature where static
interface members can be marked as abstract
. This feature involves several changes to the ECMA 335 spec to allow intermediate language (IL) metadata patterns that were previously considered illegal. For more information, see dotnet/runtime#49558.
If a static interface was marked as abstract
:
Starting in .NET 6, static interface members can be marked as abstract
and will compile successfully. In addition, the IL metadata patterns that are generated are now considered legal due to changes in the ECMA 335 spec.
The implementation of static abstract
interface members is provided by types that implement the interface.
Note
For .NET 6, you must enable preview features in your project to be able to mark an interface member as static abstract
.
Since this is a newly legal IL pattern, existing tooling may incorrectly process the associated metadata and have unexpected behavior. It's likely that tooling will encounter the new metadata pattern, because interfaces with static abstract
members now appear on the primitive types, for example, System.Int32.
.NET 6
This change can affect binary compatibility.
This change was introduced because there was no way to abstract over static members and write generalized code that applies across types that define those static members. This was particularly problematic for member kinds that only exist in a static form, for example, operators.
Update any tooling that consumes .NET binaries or C# source code to account for the new concept of static abstract
interface members, including those that now exist on the .NET primitive types.
N/A
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Training
Module
Learn coding practices to help prevent the occurrence of NullReferenceException.