Skip to content

Make ObsoleteAttributeData public #82356

@ericstj

Description

@ericstj

Background and Motivation

We have tools that operate on API and use the roslyn symbol model to analyze it. We'd like those tools to treat experimental and obsolete API differently. To do so today, we'd need to recalculate this, with similar rules to what roslyn has today.

See dotnet/sdk#50637

Proposed API

namespace Microsoft.CodeAnalysis
{

-    internal enum ObsoleteAttributeKind
+    public enum ObsoleteAttributeKind
    {
        None,
        Uninitialized,
        Obsolete,
        Deprecated,
        WindowsExperimental,
        Experimental,
    }
-    internal sealed class ObsoleteAttributeData { ... }
+    public sealed class ObsoleteAttributeData { ... }

// plus additional plumbing to expose from internal symbol model to public symbol model

Usage Examples

if (someSymbol?.ObsoleteAttributeData?.Kind == ObsoleteAttributeKind.Experimental && skipComparingExperimentalAPI)
{
    return; 
}

Alternative Designs

New api on symbol, or symbol helper static/extension API that could just provide an answer to the question, would avoid the need for any new types and could be added entirely on the side.

  public static class ObsoleteHelperExtensions
  {
      public bool IsExperimental(this ISymbol symbol) {}
      public bool IsObsolete(this ISymbol symbol) {}
  }

Risks

Low risk - just exposing existing types / data.

Metadata

Metadata

Assignees

Labels

Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions