Skip to content

Commit 6b253be

Browse files
committed
Also generate [DebuggerNonUserCode] in transitive members
1 parent 5802e2f commit 6b253be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/TransitiveMembersGenerator.Execute.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ public static void ProcessMemberDeclarations(
6868
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(generatorType.Assembly.GetName().Version.ToString())))))))
6969
.WithLeadingTrivia(member.GetLeadingTrivia());
7070

71+
// [DebuggerNonUserCode] is not supported on interfaces, fields and event
72+
if (member.Kind() is not (SyntaxKind.InterfaceDeclaration or SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration))
73+
{
74+
member = member.AddAttributeLists(AttributeList(SingletonSeparatedList(Attribute(IdentifierName("global::System.Diagnostics.DebuggerNonUserCode")))));
75+
}
76+
7177
// [ExcludeFromCodeCoverage] is not supported on interfaces and fields
72-
if (member.Kind() is not SyntaxKind.InterfaceDeclaration and not SyntaxKind.FieldDeclaration)
78+
if (member.Kind() is not (SyntaxKind.InterfaceDeclaration or SyntaxKind.FieldDeclaration))
7379
{
7480
member = member.AddAttributeLists(AttributeList(SingletonSeparatedList(Attribute(IdentifierName("global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage")))));
7581
}

0 commit comments

Comments
 (0)