Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add support for ExperimentalAttribute
  • Loading branch information
Julien Couvreur committed Jun 21, 2023
commit 58f7312dc57b9e845dc02daace539983ec61ea0e
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));
Copy link
Member

@jjonescz jjonescz Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is FormattedSymbol necessary? Isn't CSharpErrorMessageFormat the default? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified. Thanks

}

// 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