|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules
|
5 | 5 | {
|
| 6 | + using System.Threading; |
| 7 | + using System.Threading.Tasks; |
| 8 | + using StyleCop.Analyzers.MaintainabilityRules; |
6 | 9 | using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules;
|
| 10 | + using Xunit; |
| 11 | + |
| 12 | + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< |
| 13 | + StyleCop.Analyzers.MaintainabilityRules.SA1404CodeAnalysisSuppressionMustHaveJustification, |
| 14 | + StyleCop.Analyzers.MaintainabilityRules.SA1404CodeFixProvider>; |
7 | 15 |
|
8 | 16 | public partial class SA1404CSharp11UnitTests : SA1404CSharp10UnitTests
|
9 | 17 | {
|
| 18 | + // NOTE: This tests a fix for a c# 10 feature, but the Roslyn API used to solve it wasn't available in the version |
| 19 | + // we use in the c# 10 test project, so the test was added here instead. |
| 20 | + [Fact] |
| 21 | + [WorkItem(3594, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3594")] |
| 22 | + public async Task TestUsingNameChangeInGlobalUsingInAnotherFileAsync() |
| 23 | + { |
| 24 | + var testCode1 = @" |
| 25 | +global using MySuppressionAttribute = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute;"; |
| 26 | + |
| 27 | + var testCode2 = @" |
| 28 | +public class Foo |
| 29 | +{ |
| 30 | + [[|MySuppression(null, null)|]] |
| 31 | + public void Bar() |
| 32 | + { |
| 33 | +
|
| 34 | + } |
| 35 | +}"; |
| 36 | + |
| 37 | + var fixedCode2 = @" |
| 38 | +public class Foo |
| 39 | +{ |
| 40 | + [MySuppression(null, null, Justification = """ + SA1404CodeAnalysisSuppressionMustHaveJustification.JustificationPlaceholder + @""")] |
| 41 | + public void Bar() |
| 42 | + { |
| 43 | +
|
| 44 | + } |
| 45 | +}"; |
| 46 | + |
| 47 | + await new CSharpTest() |
| 48 | + { |
| 49 | + TestSources = { testCode1, testCode2 }, |
| 50 | + FixedSources = { testCode1, fixedCode2 }, |
| 51 | + RemainingDiagnostics = |
| 52 | + { |
| 53 | + Diagnostic().WithLocation("/0/Test1.cs", 4, 32), |
| 54 | + }, |
| 55 | + NumberOfIncrementalIterations = 2, |
| 56 | + NumberOfFixAllIterations = 2, |
| 57 | + }.RunAsync(CancellationToken.None).ConfigureAwait(false); |
| 58 | + } |
10 | 59 | }
|
11 | 60 | }
|
0 commit comments