Skip to content

Make MetadataDisplayFormat public #72844

@tmat

Description

@tmat

Background and Motivation

After a compilation is emitted and the resulting image is loaded, we need to find a type in the loaded Assembly that corresponds to a source INamedTypeSymbol defined in the compilation.
 

Proposed API

namespace Microsoft.CodeAnalysis;

public class SymbolDisplayFormat
{
+   SymbolDisplayFormat MetadataDisplayFormat { get; }
}

Implemented like so:

private static readonly SymbolDisplayFormat s_metadataDisplayFormat =
SymbolDisplayFormat.QualifiedNameArityFormat.AddCompilerInternalOptions(SymbolDisplayCompilerInternalOptions.UsePlusForNestedTypes);

Usage Examples

var qualifiedTypeName = typeSymbol.ToDisplayString(SymbolDisplayFormat.MetadataDisplayFormat);
var type = Assembly.GetType(qualifiedTypeName);

Alternative Designs

Risks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.Feature Requestapi-needs-workAPI needs work before it is approved, it is NOT ready for implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions