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

Support generating records in syntax generator #67337

Merged
merged 5 commits into from
Mar 19, 2023

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #67335

@@ -4,6 +4,7 @@

using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Roslyn.Utilities;
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
using Roslyn.Utilities;

@@ -32,15 +33,19 @@ public partial class SyntaxFactory
}

public static RecordDeclarationSyntax RecordDeclaration(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, SyntaxToken keyword, SyntaxToken identifier,
TypeParameterListSyntax typeParameterList, ParameterListSyntax parameterList, BaseListSyntax baseList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, SyntaxList<MemberDeclarationSyntax> members)
TypeParameterListSyntax? typeParameterList, ParameterListSyntax? parameterList, BaseListSyntax? baseList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, SyntaxList<MemberDeclarationSyntax> members)
{
Copy link
Member Author

Choose a reason for hiding this comment

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

this was a bridge method for back compat. But actually trying to use it produces terrible results. For example, if you specify any members, you get: record C public string ToString(); (without braces).

Copy link
Member

@cston cston Mar 17, 2023

Choose a reason for hiding this comment

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

Consider adding a test to SyntaxFactoryTests.cs.

Copy link
Member Author

Choose a reason for hiding this comment

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

will do. thanks :)

@@ -32,15 +33,19 @@ public partial class SyntaxFactory
}

public static RecordDeclarationSyntax RecordDeclaration(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, SyntaxToken keyword, SyntaxToken identifier,
TypeParameterListSyntax typeParameterList, ParameterListSyntax parameterList, BaseListSyntax baseList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, SyntaxList<MemberDeclarationSyntax> members)
TypeParameterListSyntax? typeParameterList, ParameterListSyntax? parameterList, BaseListSyntax? baseList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, SyntaxList<MemberDeclarationSyntax> members)
Copy link
Member Author

Choose a reason for hiding this comment

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

the api change is just making these three members optional. Obviously, and correctly, the type-params/param-list and base list of a record are all optional. This also matches all the other overloads in this file. This appears to just be an errant mistake that does not impact anyone to fix.

@333fred for confirmation.

@CyrusNajmabadi
Copy link
Member Author

@roslyn-compiler @dotnet/roslyn-ide ptal.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Compiler change LGTM (commit 3)

@CyrusNajmabadi
Copy link
Member Author

@jcouv ptal :)

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

Changes under Compilers (LGTM). Just a reminder that we ask to squash commits while merging.

@CyrusNajmabadi
Copy link
Member Author

Just a reminder that we ask to squash commits while merging.

Thanks for the reminder! :)

@CyrusNajmabadi
Copy link
Member Author

Direct syntax factory tests added.

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge (squash) March 17, 2023 21:10
Copy link
Member

@cston cston left a comment

Choose a reason for hiding this comment

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

Compiler changes LGTM.

@CyrusNajmabadi
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@CyrusNajmabadi CyrusNajmabadi merged commit e625bee into dotnet:main Mar 19, 2023
@ghost ghost added this to the Next milestone Mar 19, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the syntaxGeneratorRecords branch March 19, 2023 20:05
@allisonchou allisonchou modified the milestones: Next, 17.6 P3 Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SyntaxGenerator doesn't support generation of record types
5 participants