diff options
author | Tlakaelel Axayakatl Ceja <tlakaelel.ceja@microsoft.com> | 2021-02-05 01:07:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 01:07:02 +0300 |
commit | 9b71e7b1e0827aee8fb43baa1e599e35cdeeed03 (patch) | |
tree | f55cf2bcad5696464df27d3fe69d8df3c8bc17c7 /test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs | |
parent | 92f927ebcbd06da82f1987879c180253e8e81642 (diff) |
RequiresAssemblyFilesAttribute resource manager changes (#1790)
* Change resource file to have a default message and accept arguments
* Add test for RequiresAssemblyFilesAttribute with Url named argument only
* Add IL3XXX warning codes to the master error code registry
* Throw whenever a named argument is passed in ExpectedWarning
Diffstat (limited to 'test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs')
-rw-r--r-- | test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs b/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs index 466f81db8..9aca417f4 100644 --- a/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs +++ b/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs @@ -48,7 +48,8 @@ class C } }"; return VerifyRequiresAssemblyFilesAnalyzer (TestRequiresAssemblyFieldsOnEvent, - VerifyCS.Diagnostic ().WithSpan (25, 17, 25, 18).WithArguments ("C.E")); + // (25,17): warning IL3002: Using member 'C.E' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. + VerifyCS.Diagnostic ().WithSpan (25, 17, 25, 18).WithArguments ("C.E", "", "")); } [Fact] @@ -68,7 +69,8 @@ class C } }"; return VerifyRequiresAssemblyFilesAnalyzer (TestRequiresAssemblyFilesOnMethod, - VerifyCS.Diagnostic ().WithSpan (27, 3, 27, 7).WithArguments ("C.M2()")); + // (27,3): warning IL3002: Using member 'C.M1()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. + VerifyCS.Diagnostic ().WithSpan (27, 3, 27, 7).WithArguments ("C.M1()", "", "")); } [Fact] @@ -87,8 +89,10 @@ class C } }"; return VerifyRequiresAssemblyFilesAnalyzer (TestRequiresAssemblyFilesOnProperty, - VerifyCS.Diagnostic ().WithSpan (25, 3, 25, 4).WithArguments ("C.P"), - VerifyCS.Diagnostic ().WithSpan (26, 12, 26, 13).WithArguments ("C.P")); + // (25,3): warning IL3002: Using member 'C.P' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. + VerifyCS.Diagnostic ().WithSpan (25, 3, 25, 4).WithArguments ("C.P", "", ""), + // (26,12): warning IL3002: Using member 'C.P' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. + VerifyCS.Diagnostic ().WithSpan (26, 12, 26, 13).WithArguments ("C.P", "", "")); } [Fact] @@ -108,7 +112,29 @@ class C } }"; return VerifyRequiresAssemblyFilesAnalyzer (TestRequiresAssemblyFilesWithMessageAndUrl, - VerifyCS.Diagnostic ().WithSpan (27, 3, 27, 7).WithArguments ("C.M2()", "Message from attribute", "https://helpurl")); + // (27,3): warning IL3002: Using member 'C.M1()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. Message from attribute. https://helpurl + VerifyCS.Diagnostic ().WithSpan (27, 3, 27, 7).WithArguments ("C.M1()", " Message from attribute.", " https://helpurl")); + } + + [Fact] + public Task RequiresAssemblyFilesWithUrlOnly () + { + var TestRequiresAssemblyFilesWithMessageAndUrl = @" +class C +{ + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFiles (Url = ""https://helpurl"")] + void M1() + { + } + + void M2() + { + M1(); + } +}"; + return VerifyRequiresAssemblyFilesAnalyzer (TestRequiresAssemblyFilesWithMessageAndUrl, + // (27,3): warning IL3002: Using member 'C.M1()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. https://helpurl + VerifyCS.Diagnostic ().WithSpan (27, 3, 27, 7).WithArguments ("C.M1()", "", " https://helpurl")); } [Fact] @@ -146,7 +172,8 @@ class C } }"; return VerifyRequiresAssemblyFilesAnalyzer (TestNoDiagnosticIsProducedIfCallerIsAnnotated, - VerifyCS.Diagnostic ().WithSpan (22, 3, 22, 7).WithArguments ("C.M2()", "Warn from M2")); + // (22,3): warning IL3002: Using member 'C.M2()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. Warn from M2. + VerifyCS.Diagnostic ().WithSpan (22, 3, 22, 7).WithArguments ("C.M2()", " Warn from M2.", "")); } } } |