Skip to content

Commit 3416c21

Browse files
authored
updated NuGet packages versions (#39)
* update NuGet packages versions * fixed NullConditionalAssertionAnalyzer
1 parent 44abed0 commit 3416c21

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/FluentAssertions.Analyzers.Tests/FluentAssertions.Analyzers.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="FluentAssertions" Version="5.1.1" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
12-
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
13-
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
10+
<PackageReference Include="FluentAssertions" Version="5.3.2" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
12+
<PackageReference Include="MSTest.TestAdapter" Version="1.3.1" />
13+
<PackageReference Include="MSTest.TestFramework" Version="1.3.1" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

src/FluentAssertions.Analyzers/FluentAssertions.Analyzers.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard1.3</TargetFramework>
55
<RootNamespace>FluentAssertions.Analyzers</RootNamespace>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" />
10-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.6.1" />
9+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.8.2" />
1110
<PackageReference Include="Microsoft.Composition" Version="1.0.31" />
1211
</ItemGroup>
1312

src/FluentAssertions.Analyzers/Tips/NullConditionalAssertionAnalyzer.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,25 @@ protected virtual Diagnostic AnalyzeExpression(ExpressionSyntax expression)
6262

6363
private class ConditionalAccessExpressionVisitor : CSharpSyntaxWalker
6464
{
65-
public bool CodeSmells { get; private set; }
65+
private bool _foundConditionalAccess;
66+
private bool _foundShouldMethod;
67+
68+
public bool CodeSmells => _foundShouldMethod && _foundConditionalAccess;
6669
public Location ConditionalAccess { get; private set; }
6770

6871
public override void VisitConditionalAccessExpression(ConditionalAccessExpressionSyntax node)
6972
{
70-
if (CodeSmells) return;
71-
72-
CodeSmells = node.WhenNotNull is InvocationExpressionSyntax invocation
73-
&& invocation.Expression is MemberAccessExpressionSyntax memberAccess && memberAccess.IsKind(SyntaxKind.SimpleMemberAccessExpression)
74-
&& memberAccess.Expression is InvocationExpressionSyntax shouldInvocation
75-
&& shouldInvocation.Expression is MemberBindingExpressionSyntax memberBinding
76-
&& memberBinding.Name.Identifier.ValueText == "Should";
77-
if (CodeSmells)
73+
if (!_foundConditionalAccess)
74+
{
75+
_foundConditionalAccess = true;
76+
}
77+
base.VisitConditionalAccessExpression(node);
78+
}
79+
public override void VisitIdentifierName(IdentifierNameSyntax node)
80+
{
81+
if(_foundConditionalAccess && node.Identifier.ValueText == "Should")
7882
{
79-
ConditionalAccess = node.GetLocation();
83+
_foundShouldMethod = true;
8084
}
8185
}
8286
}

0 commit comments

Comments
 (0)