forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reporting of EnC (and other) diagnostics (dotnet#11447)
* Fix reporting of EnC diagnostics * Keep original overloads on DocumentDiagnosticAnalyzer for compat with TS and F#
- Loading branch information
Showing
11 changed files
with
271 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Compilers/Core/CodeAnalysisTest/Diagnostics/CompilationWithAnalyzersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Roslyn.Test.Utilities; | ||
using Roslyn.Utilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.UnitTests.Diagnostics | ||
{ | ||
using SimpleDiagnostic = Diagnostic.SimpleDiagnostic; | ||
|
||
public class CompilationWithAnalyzersTests : TestBase | ||
{ | ||
[Fact] | ||
public void GetEffectiveDiagnostics_Errors() | ||
{ | ||
var c = CSharpCompilation.Create("c"); | ||
var ds = new[] { default(Diagnostic) }; | ||
|
||
Assert.Throws<ArgumentNullException>(() => CompilationWithAnalyzers.GetEffectiveDiagnostics(default(ImmutableArray<Diagnostic>), c)); | ||
Assert.Throws<ArgumentNullException>(() => CompilationWithAnalyzers.GetEffectiveDiagnostics(default(IEnumerable<Diagnostic>), c)); | ||
Assert.Throws<ArgumentNullException>(() => CompilationWithAnalyzers.GetEffectiveDiagnostics(ds, null)); | ||
} | ||
|
||
[Fact] | ||
public void GetEffectiveDiagnostics() | ||
{ | ||
var c = CSharpCompilation.Create("c", options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary). | ||
WithSpecificDiagnosticOptions( | ||
new[] { KeyValuePair.Create($"CS{(int)ErrorCode.WRN_AlwaysNull:D4}", ReportDiagnostic.Suppress) })); | ||
|
||
var d1 = SimpleDiagnostic.Create(MessageProvider.Instance, (int)ErrorCode.WRN_AlignmentMagnitude); | ||
var d2 = SimpleDiagnostic.Create(MessageProvider.Instance, (int)ErrorCode.WRN_AlwaysNull); | ||
var ds = new[] { default(Diagnostic), d1, d2 }; | ||
|
||
var filtered = CompilationWithAnalyzers.GetEffectiveDiagnostics(ds, c); | ||
|
||
// overwrite the original value to test eagerness: | ||
ds[1] = default(Diagnostic); | ||
|
||
AssertEx.Equal(new[] { d1 }, filtered); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.