Skip to content

Commit

Permalink
Add support for ExperimentalAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Jun 21, 2023
1 parent 55e3953 commit 58f7312
Show file tree
Hide file tree
Showing 15 changed files with 1,095 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/Compilers/CSharp/Portable/Symbols/ObsoleteAttributeHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ internal static ObsoleteDiagnosticKind GetObsoleteDiagnosticKind(Symbol symbol,
case ObsoleteAttributeKind.None:
return ObsoleteDiagnosticKind.NotObsolete;
case ObsoleteAttributeKind.Experimental:
case ObsoleteAttributeKind.NewExperimental:
return ObsoleteDiagnosticKind.Diagnostic;
case ObsoleteAttributeKind.Uninitialized:
// If we haven't cracked attributes on the symbol at all or we haven't
Expand Down Expand Up @@ -162,6 +163,16 @@ static DiagnosticInfo createObsoleteDiagnostic(Symbol symbol, BinderFlags locati
return new CSDiagnosticInfo(ErrorCode.WRN_Experimental, new FormattedSymbol(symbol, SymbolDisplayFormat.CSharpErrorMessageFormat));
}

if (data.Kind == ObsoleteAttributeKind.NewExperimental)
{
Debug.Assert(data.Message is null);
Debug.Assert(!data.IsError);

// Provide an explicit format for fully-qualified type names.
return new CustomObsoleteDiagnosticInfo(MessageProvider.Instance, (int)ErrorCode.WRN_Experimental,
data, new FormattedSymbol(symbol, SymbolDisplayFormat.CSharpErrorMessageFormat));
}

// Issue a specialized diagnostic for add methods of collection initializers
var isColInit = location.Includes(BinderFlags.CollectionInitializerAddMethod);
Debug.Assert(!isColInit || symbol.Name == WellKnownMemberNames.CollectionInitializerAddMethodName);
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Symbols/Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,7 @@ internal ThreeState ObsoleteState
{
case ObsoleteAttributeKind.None:
case ObsoleteAttributeKind.Experimental:
case ObsoleteAttributeKind.NewExperimental:
return ThreeState.False;
case ObsoleteAttributeKind.Uninitialized:
return ThreeState.Unknown;
Expand Down
4 changes: 4 additions & 0 deletions src/Compilers/CSharp/Portable/Symbols/Symbol_Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ internal static bool EarlyDecodeDeprecatedOrExperimentalOrObsoleteAttribute(
{
kind = ObsoleteAttributeKind.Experimental;
}
else if (CSharpAttributeData.IsTargetEarlyAttribute(type, syntax, AttributeDescription.NewExperimentalAttribute))
{
kind = ObsoleteAttributeKind.NewExperimental;
}
else
{
obsoleteData = null;
Expand Down
Loading

0 comments on commit 58f7312

Please sign in to comment.