-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d58a7c
commit e36afc8
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/Tests/SourceGeneratorTest/DiagnosticSuppressorTests.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,35 @@ | ||
using System.Threading.Tasks; | ||
using Generator; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SourceGeneratorTest.Helpers; | ||
|
||
namespace SourceGeneratorTest; | ||
|
||
[TestClass] | ||
public sealed class DiagnosticSuppressorTests | ||
{ | ||
public static readonly DiagnosticResult IDE0300 = DiagnosticResult.CompilerWarning("IDE0300"); | ||
|
||
[TestMethod] | ||
public async Task CollectionExpression_IDE0300_ArrayInitializer_TargetingArray_NotSuppressed() | ||
{ | ||
await new CSharpSuppressorTest<CollectionExpressionIDE0300Suppressor>( | ||
""" | ||
class TestClass | ||
{ | ||
private int[] f = {|IDE0300:{|} 1, 2, 3 }; | ||
|
||
void TestMethod() | ||
{ | ||
int[] a = {|IDE0300:{|} 1, 2, 3 }; | ||
} | ||
|
||
public int[] P { get; } = {|IDE0300:{|} 1, 2, 3 }; | ||
} | ||
""") | ||
.WithAnalyzer("Microsoft.CodeAnalysis.CSharp.UseCollectionExpression.CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer, Microsoft.CodeAnalysis.CSharp.CodeStyle") | ||
.WithSpecificDiagnostics(IDE0300) | ||
.RunAsync(); | ||
} | ||
} |
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