Skip to content

Commit

Permalink
feat: support assertions on property of object
Browse files Browse the repository at this point in the history
  • Loading branch information
Meir017 committed Aug 21, 2023
1 parent d68e26d commit b502cae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public class TestType3
Id = CollectionShouldNotBeEmptyAnalyzer.DiagnosticId,
Message = CollectionShouldNotBeEmptyAnalyzer.Message,
Severity = DiagnosticSeverity.Info,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 8, 9) }
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 12, 9) }
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ protected virtual Diagnostic AnalyzeExpression(ExpressionSyntax expression, Sema
var variableNameExtractor = new VariableNameExtractor(semanticModel);
expression.Accept(variableNameExtractor);

if (variableNameExtractor.VariableIdentifierName == null) return null;
var typeInfo = semanticModel.GetTypeInfo(variableNameExtractor.VariableIdentifierName);
if (!ShouldAnalyzeVariableTypeCore(typeInfo.Type, semanticModel)) return null;
if (variableNameExtractor.PropertiesAccessed
.ConvertAll(identifier => semanticModel.GetTypeInfo(identifier))
.TrueForAll(typeInfo => !ShouldAnalyzeVariableTypeCore(typeInfo.Type, semanticModel))) {
return null;
}

foreach (var visitor in Visitors)
{
Expand Down

0 comments on commit b502cae

Please sign in to comment.