Skip to content

Experimental attribute C# 12.0correctness

An annotation attribute to signal areas that are experimental.

The ObsoleteAttribute has existed in C# since the beginning to indicate that a feature is deprecated.

C# 12.0 introduces the ExperimentalAttribute to signal that a feature is experimental and therefore subject to change and emits similar compiler warnings.

Code

C#
[Experimental("MyAdvancedConnections")]
public Connection StartConnection(ConnectionSpecification specification) => new Connection(specification);

#pragma warning disable MyAdvancedConnections
var connection = StartConnection(specification);
C#
/// <summary>
/// Warning: This feature is experimental and may change in future versions.
/// </summary>
public Connection StartConnection(ConnectionSpecification specification) => new Connection(specification);

var connection = StartConnection(specification);

More information