Skip to content

Commit 991ab7c

Browse files
committed
Enable SA1638 code fix
1 parent a71c67d commit 991ab7c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1638UnitTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,28 @@ public async Task TestCopyrightElementWithMismatchingFileAttributeAsync()
2525
// Copyright (c) FooCorp. All rights reserved.
2626
// </copyright>
2727
28+
namespace Bar
29+
{
30+
}
31+
";
32+
var fixedCode = @"// <copyright file=""Test0.cs"" company=""FooCorp"">
33+
// Copyright (c) FooCorp. All rights reserved.
34+
// </copyright>
35+
2836
namespace Bar
2937
{
3038
}
3139
";
3240

3341
var expectedDiagnostic = this.CSharpDiagnostic(FileHeaderAnalyzers.SA1638Descriptor).WithLocation(1, 4);
3442
await this.VerifyCSharpDiagnosticAsync(testCode, expectedDiagnostic, CancellationToken.None).ConfigureAwait(false);
43+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
44+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
3545
}
3646

3747
protected override CodeFixProvider GetCSharpCodeFixProvider()
3848
{
39-
throw new System.NotImplementedException();
49+
return new FileHeaderCodeFixProvider();
4050
}
4151
}
4252
}

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/FileHeaderCodeFixProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ internal class FileHeaderCodeFixProvider : CodeFixProvider
3636
FileHeaderAnalyzers.SA1634Descriptor.Id,
3737
FileHeaderAnalyzers.SA1635Descriptor.Id,
3838
FileHeaderAnalyzers.SA1636Descriptor.Id,
39+
FileHeaderAnalyzers.SA1638Descriptor.Id,
3940
FileHeaderAnalyzers.SA1640Descriptor.Id,
4041
FileHeaderAnalyzers.SA1641Descriptor.Id);
4142

0 commit comments

Comments
 (0)