From 749ad0350b434045fcc453f8c5f8058b569f9115 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Fri, 1 Dec 2017 22:04:26 -0800 Subject: [PATCH] User Roslyn analyzers in all projects The build system used to allow projects to opt out of anaylzers by setting the property `$(UseRoslynAnalyzers)` to false before importing Settings.props. This meant it occured at the top of the file above all other elements, including the main property group block. This doesn't really have an equivalent approach in the new SDK. There is no way to pass a property value from the project file to the Directory.Build.props file as it's implicitly imported. The correct approach in the new SDK would be to do the following: 1. Define `$(UseRoslynAnalyzers)` in main property group block 1. Use the Roslyn analyzers as a `` declaration in the `Imports.targets` file and have it condition on `$(UseRoslynAnalyzers)` not being false. Doing that is a pretty siginificant rework of our build though. As a test I just disabled the analyzers everywhere and found we had a total of three warnings. Decided to just fix those as it was very straight forward to do. --- .../CSharp/ConsoleClassifier/ConsoleClassifierCS.csproj | 5 +---- src/Samples/CSharp/MakeConst/Impl/MakeConstCS.csproj | 5 +---- .../ConsoleClassifier/ConsoleClassifierVB.vbproj | 3 --- src/Samples/VisualBasic/ConsoleClassifier/Program.vb | 6 +++--- src/Samples/VisualBasic/MakeConst/Impl/MakeConstVB.vbproj | 5 +---- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Samples/CSharp/ConsoleClassifier/ConsoleClassifierCS.csproj b/src/Samples/CSharp/ConsoleClassifier/ConsoleClassifierCS.csproj index 8ad48391e6e..e46c5f65b91 100644 --- a/src/Samples/CSharp/ConsoleClassifier/ConsoleClassifierCS.csproj +++ b/src/Samples/CSharp/ConsoleClassifier/ConsoleClassifierCS.csproj @@ -1,9 +1,6 @@  - - false - true @@ -33,4 +30,4 @@ - \ No newline at end of file + diff --git a/src/Samples/CSharp/MakeConst/Impl/MakeConstCS.csproj b/src/Samples/CSharp/MakeConst/Impl/MakeConstCS.csproj index e36e9d29121..d3abb63a216 100644 --- a/src/Samples/CSharp/MakeConst/Impl/MakeConstCS.csproj +++ b/src/Samples/CSharp/MakeConst/Impl/MakeConstCS.csproj @@ -1,9 +1,6 @@  - - false - @@ -56,4 +53,4 @@ - \ No newline at end of file + diff --git a/src/Samples/VisualBasic/ConsoleClassifier/ConsoleClassifierVB.vbproj b/src/Samples/VisualBasic/ConsoleClassifier/ConsoleClassifierVB.vbproj index 6592446dc83..09aa2d983df 100644 --- a/src/Samples/VisualBasic/ConsoleClassifier/ConsoleClassifierVB.vbproj +++ b/src/Samples/VisualBasic/ConsoleClassifier/ConsoleClassifierVB.vbproj @@ -1,9 +1,6 @@  - - false - AnyCPU diff --git a/src/Samples/VisualBasic/ConsoleClassifier/Program.vb b/src/Samples/VisualBasic/ConsoleClassifier/Program.vb index 98343b3ed54..217048fe00b 100644 --- a/src/Samples/VisualBasic/ConsoleClassifier/Program.vb +++ b/src/Samples/VisualBasic/ConsoleClassifier/Program.vb @@ -21,10 +21,10 @@ Sub Main() WriteLine(""Hello, World!"") End Sub End Module") - document = Await Formatter.FormatAsync(document) - Dim text As SourceText = Await document.GetTextAsync() + document = Await Formatter.FormatAsync(document).ConfigureAwait(true) + Dim text As SourceText = Await document.GetTextAsync().ConfigureAwait(true) - Dim classifiedSpans As IEnumerable(Of ClassifiedSpan) = Await Classifier.GetClassifiedSpansAsync(document, TextSpan.FromBounds(0, text.Length)) + Dim classifiedSpans As IEnumerable(Of ClassifiedSpan) = Await Classifier.GetClassifiedSpansAsync(document, TextSpan.FromBounds(0, text.Length)).ConfigureAwait(true) Console.BackgroundColor = ConsoleColor.Black Dim ranges = From span As ClassifiedSpan In classifiedSpans diff --git a/src/Samples/VisualBasic/MakeConst/Impl/MakeConstVB.vbproj b/src/Samples/VisualBasic/MakeConst/Impl/MakeConstVB.vbproj index c444a0d6b98..04b27ffc67b 100644 --- a/src/Samples/VisualBasic/MakeConst/Impl/MakeConstVB.vbproj +++ b/src/Samples/VisualBasic/MakeConst/Impl/MakeConstVB.vbproj @@ -1,9 +1,6 @@  - - false - @@ -64,4 +61,4 @@ - \ No newline at end of file + -- GitLab