Skip to content

Add support for the implicit conversion operator generation to the SyntaxGenerator #11848

@andriipatsula

Description

@andriipatsula

The SyntaxGenerator.Declaration(ISymbol symbol) does not handles SymbolKind.Method with MethodKind.Conversion as a result the exception ArgumentException("Symbol cannot be converted to a declaration") is thrown.

SyntaxGenerator.cs#L575

var method = (IMethodSymbol)symbol;
+if (method.MethodKind == MethodKind.Conversion)
+{
+    return ConversionMethodDeclaration(method, method.Name);
+}

//...

+ private static SyntaxNode ConversionMethodDeclaration(IMethodSymbol method, string name) {}

Examples:

public readonly partial struct Memory<T>
{
    public static implicit operator System.Memory<T> (T[] array) { throw null; }
}

Metadata

Metadata

Assignees

Labels

area-product-constructionIssues owned by the Product Construction team. Used to label epics and untriaged, loose issues.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions