Skip to content

Commit 5086cc0

Browse files
committed
Update to Microsoft.CodeAnalysis.Testing 1.0.0-beta1-63310-01
1 parent 7781c99 commit 5086cc0

30 files changed

+172
-97
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1119CodeFixProvider.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal class SA1119CodeFixProvider : CodeFixProvider
2727
{
2828
/// <inheritdoc/>
2929
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
30-
ImmutableArray.Create(SA1119StatementMustNotUseUnnecessaryParenthesis.DiagnosticId);
30+
ImmutableArray.Create(SA1119StatementMustNotUseUnnecessaryParenthesis.DiagnosticId, SA1119StatementMustNotUseUnnecessaryParenthesis.ParenthesesDiagnosticId);
3131

3232
/// <inheritdoc/>
3333
public override FixAllProvider GetFixAllProvider()
@@ -42,6 +42,11 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
4242

4343
foreach (var diagnostic in context.Diagnostics)
4444
{
45+
if (diagnostic.Id != SA1119StatementMustNotUseUnnecessaryParenthesis.DiagnosticId)
46+
{
47+
continue;
48+
}
49+
4550
SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true, findInsideTrivia: true);
4651
if (node.IsMissing)
4752
{

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/InheritdocCodeFixProviderUnitTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules
66
using System.Threading;
77
using System.Threading.Tasks;
88
using Microsoft.CodeAnalysis;
9+
using Microsoft.CodeAnalysis.Testing;
910
using StyleCop.Analyzers.DocumentationRules;
1011
using Xunit;
1112
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
@@ -193,6 +194,7 @@ public class ChildClass : ParentClass
193194
Diagnostic(SA1600).WithLocation(12, 35),
194195
},
195196
FixedCode = testCode,
197+
FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll },
196198
NumberOfIncrementalIterations = 1,
197199
NumberOfFixAllIterations = 1,
198200
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
@@ -230,6 +232,7 @@ public class ChildClass : ParentClass
230232
Diagnostic(SA1600).WithLocation(12, 35),
231233
},
232234
FixedCode = testCode,
235+
FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll },
233236
NumberOfIncrementalIterations = 1,
234237
NumberOfFixAllIterations = 1,
235238
}.RunAsync(CancellationToken.None).ConfigureAwait(false);

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1600UnitTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,14 @@ private static Task VerifyCSharpFixAsync(LanguageVersion languageVersion, string
14211421
FixedCode = fixedSource,
14221422
};
14231423

1424+
if (source == fixedSource)
1425+
{
1426+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
1427+
test.FixedState.MarkupHandling = MarkupMode.Allow;
1428+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
1429+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
1430+
}
1431+
14241432
test.ExpectedDiagnostics.AddRange(expected);
14251433
return test.RunAsync(cancellationToken);
14261434
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1609UnitTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,14 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
417417
},
418418
};
419419

420+
if (source == fixedSource)
421+
{
422+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
423+
test.FixedState.MarkupHandling = MarkupMode.Allow;
424+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
425+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
426+
}
427+
420428
test.ExpectedDiagnostics.AddRange(expected);
421429
return test.RunAsync(cancellationToken);
422430
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1610UnitTests.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,22 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
417417
},
418418
};
419419

420-
test.ExpectedDiagnostics.AddRange(expected);
421-
422-
if (offerEmptyFixer && fixedSource == source)
420+
if (source == fixedSource)
423421
{
424-
test.NumberOfIncrementalIterations = 1;
425-
test.NumberOfFixAllIterations = 1;
422+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
423+
test.FixedState.MarkupHandling = MarkupMode.Allow;
424+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
425+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
426+
427+
if (offerEmptyFixer)
428+
{
429+
test.NumberOfIncrementalIterations = 1;
430+
test.NumberOfFixAllIterations = 1;
431+
}
426432
}
427433

434+
test.ExpectedDiagnostics.AddRange(expected);
435+
428436
return test.RunAsync(cancellationToken);
429437
}
430438
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1616UnitTests.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,18 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
615615
},
616616
};
617617

618-
if (offerEmptyFixer && fixedSource == source)
618+
if (source == fixedSource)
619619
{
620-
test.NumberOfIncrementalIterations = 1;
621-
test.NumberOfFixAllIterations = 1;
620+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
621+
test.FixedState.MarkupHandling = MarkupMode.Allow;
622+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
623+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
624+
625+
if (offerEmptyFixer)
626+
{
627+
test.NumberOfIncrementalIterations = 1;
628+
test.NumberOfFixAllIterations = 1;
629+
}
622630
}
623631

624632
test.ExpectedDiagnostics.AddRange(expected);

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1617UnitTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
362362
},
363363
};
364364

365+
if (source == fixedSource)
366+
{
367+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
368+
test.FixedState.MarkupHandling = MarkupMode.Allow;
369+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
370+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
371+
}
372+
365373
test.ExpectedDiagnostics.AddRange(expected);
366374
return test.RunAsync(cancellationToken);
367375
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1629UnitTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,14 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
872872
test.TestCode = source;
873873
test.FixedCode = fixedSource;
874874

875+
if (source == fixedSource)
876+
{
877+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
878+
test.FixedState.MarkupHandling = MarkupMode.Allow;
879+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
880+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
881+
}
882+
875883
return test.RunAsync(cancellationToken);
876884
}
877885

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,14 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
12251225
test.TestCode = source;
12261226
test.FixedCode = fixedSource;
12271227

1228+
if (source == fixedSource)
1229+
{
1230+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
1231+
test.FixedState.MarkupHandling = MarkupMode.Allow;
1232+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
1233+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
1234+
}
1235+
12281236
return test.RunAsync(cancellationToken);
12291237
}
12301238

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1643UnitTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec
346346
test.TestCode = source;
347347
test.FixedCode = fixedSource;
348348

349+
if (source == fixedSource)
350+
{
351+
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
352+
test.FixedState.MarkupHandling = MarkupMode.Allow;
353+
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll;
354+
test.BatchFixedState.MarkupHandling = MarkupMode.Allow;
355+
}
356+
349357
return test.RunAsync(cancellationToken);
350358
}
351359

0 commit comments

Comments
 (0)