diff --git a/src/Quoter.Tests/Tests.cs b/src/Quoter.Tests/Tests.cs index 14ca058..8850e65 100644 --- a/src/Quoter.Tests/Tests.cs +++ b/src/Quoter.Tests/Tests.cs @@ -848,6 +848,25 @@ public void TestBinaryLiteral() Test("0b_0010_1010", NodeKind.Expression); } + [Fact] + public void TestRecordStruct() + { + Test("record struct A();", + @"RecordDeclaration( + SyntaxKind.RecordStructDeclaration, + Token(SyntaxKind.RecordKeyword), + Identifier(""A"")) +.WithClassOrStructKeyword( + Token(SyntaxKind.StructKeyword)) +.WithParameterList( + ParameterList()) +.WithSemicolonToken( + Token(SyntaxKind.SemicolonToken)) +.NormalizeWhitespace()", + shortenCodeWithUsingStatic: true, + nodeKind: NodeKind.MemberDeclaration); + } + private void Test( string sourceText, string expected, diff --git a/src/Quoter/Quoter.cs b/src/Quoter/Quoter.cs index 0f0690a..9c6c79c 100644 --- a/src/Quoter/Quoter.cs +++ b/src/Quoter/Quoter.cs @@ -239,6 +239,7 @@ node is ClassOrStructConstraintSyntax || node is CheckedExpressionSyntax || node is CheckedStatementSyntax || node is ConstructorInitializerSyntax || + node is DocumentationCommentTriviaSyntax || node is GotoStatementSyntax || node is InitializerExpressionSyntax || node is LiteralExpressionSyntax || @@ -246,7 +247,7 @@ node is MemberAccessExpressionSyntax || node is OrderingSyntax || node is PostfixUnaryExpressionSyntax || node is PrefixUnaryExpressionSyntax || - node is DocumentationCommentTriviaSyntax || + node is RecordDeclarationSyntax || node is YieldStatementSyntax) { result.Add(new ApiCall("Kind", "SyntaxKind." + node.Kind().ToString())); @@ -1079,6 +1080,13 @@ private MethodInfo PickFactoryMethodToCreateNode(SyntaxNode node) } } + if (node is RecordDeclarationSyntax) + { + // for records, pick the overload that specifies the SyntaxKind, + // see https://github.com/KirillOsenkov/RoslynQuoter/issues/82 + minParameterCount = 3; + } + MethodInfo factory = null; if ((node is BaseTypeDeclarationSyntax ||