Skip to content

Commit

Permalink
Update ClassDataAttributeMustPointAtValidClass to support xUnit1037/1…
Browse files Browse the repository at this point in the history
…038/1039/1040 for v3 projects using TheoryDataRow<> on ClassData
  • Loading branch information
bradwilson committed May 23, 2024
1 parent 9869bce commit cdb9352
Show file tree
Hide file tree
Showing 4 changed files with 590 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,21 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
if (semanticModel is null)
return;

var typeOfExpression = root.FindNode(context.Span).FirstAncestorOrSelf<TypeOfExpressionSyntax>();
// The context wraps "ClassData(typeof(T))", which is an attribute syntax
var attribute = root.FindNode(context.Span);

// Dig in to find the attribute arguments
var attributeArgumentList = attribute.ChildNodes().OfType<AttributeArgumentListSyntax>().FirstOrDefault();
if (attributeArgumentList is null)
return;

// Dig into that to get the attribute argument
var attributeArgument = attributeArgumentList.ChildNodes().OfType<AttributeArgumentSyntax>().FirstOrDefault();
if (attributeArgument is null)
return;

// And finally, dig in to get the typeof expression
var typeOfExpression = attributeArgument.ChildNodes().OfType<TypeOfExpressionSyntax>().FirstOrDefault();
if (typeOfExpression is null)
return;

Expand Down
Loading

0 comments on commit cdb9352

Please sign in to comment.