Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxGenerator doesn't support generation of record types #67335

Closed
ViktorHofer opened this issue Mar 16, 2023 · 0 comments · Fixed by #67337
Closed

SyntaxGenerator doesn't support generation of record types #67335

ViktorHofer opened this issue Mar 16, 2023 · 0 comments · Fixed by #67337
Assignees
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@ViktorHofer
Copy link
Member

Version Used: 4.6.0-2.23081.23

SyntaxGenerator doesn't support generation of record types. The expected behavior below (compile input) is instead transformed to a class.

https://github.com/dotnet/roslyn/blob/main/src/Compilers/Core/Portable/Symbols/TypeKind.cs

The TypeKind enum does not contain record kind. For records INamedTypeSymbol.TypeKind is set to Class. That said, there is a field bool ITypeSymbol.IsRecord.

Expected Behavior:

public record GraphBuildOptions
{
    public bool Build { get; init; } = true;
}

Actual Behavior:

/// results of the roslyn-based GenAPI
public class GraphBuildOptions : System.IEquatable<GraphBuildOptions>
{
    public bool Build { get; set; } = true;

    protected virtual System.Type EqualityContract { get; }
}

cc @CyrusNajmabadi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants