Skip to content

Commit e4d3bab

Browse files
authored
bugfix: fix DiagnosticId for AssertIsFalse & AssertIsTrue (#231)
* #160 fix DiagnosticId for AssertIsFalse & AssertIsTrue * verify code-fixer diagnistics matches code analyzer * fix AssertNotEqualCodeFix FixableDiagnosticIds
1 parent 1d4960c commit e4d3bab

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ private static void VerifyFix(string language, DiagnosticAnalyzer analyzer, Code
161161
}
162162
}
163163

164+
codeFixProvider.FixableDiagnosticIds.Should().BeEquivalentTo(analyzer.SupportedDiagnostics.Select(d => d.Id));
165+
164166
//after applying all of the code fixes, compare the resulting string to the inputted one
165167
var actual = GetStringFromDocument(document);
166168
actual.Should().Be(newSource);

src/FluentAssertions.Analyzers/Tips/MsTest/AssertIsFalse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public AssertIsFalseSyntaxVisitor() : base(new MemberValidator("IsFalse"))
3636
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(AssertIsFalseCodeFix)), Shared]
3737
public class AssertIsFalseCodeFix : MsTestAssertCodeFixProvider
3838
{
39-
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(CollectionShouldBeEmptyAnalyzer.DiagnosticId);
39+
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(AssertIsFalseAnalyzer.DiagnosticId);
4040

4141
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
4242
=> RenameMethodAndReplaceWithSubjectShould(expression, "IsFalse", "BeFalse");

src/FluentAssertions.Analyzers/Tips/MsTest/AssertIsTrue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public AssertIsTrueSyntaxVisitor() : base(new MemberValidator("IsTrue"))
3636
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(AssertIsTrueCodeFix)), Shared]
3737
public class AssertIsTrueCodeFix : MsTestAssertCodeFixProvider
3838
{
39-
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(CollectionShouldBeEmptyAnalyzer.DiagnosticId);
39+
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(AssertIsTrueAnalyzer.DiagnosticId);
4040

4141
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
4242
=> RenameMethodAndReplaceWithSubjectShould(expression, "IsTrue", "BeTrue");

src/FluentAssertions.Analyzers/Tips/Xunit/AssertNotEqual.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public AssertObjectNotEqualSyntaxVisitor() : base(
7777
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(AssertNotEqualCodeFix)), Shared]
7878
public class AssertNotEqualCodeFix : XunitCodeFixProvider
7979
{
80-
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(AssertEqualAnalyzer.DiagnosticId);
80+
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(AssertNotEqualAnalyzer.DiagnosticId);
8181

8282
protected override ExpressionSyntax GetNewExpression(
8383
ExpressionSyntax expression,

0 commit comments

Comments
 (0)