diff --git a/Directory.Build.targets b/Directory.Build.targets index 73942b31d..c27995809 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -65,9 +65,9 @@ - - - + + + $(DefineConstants);ROSLYN_4_8;ROSLYN_4_2_OR_GREATER;ROSLYN_4_4_OR_GREATER;ROSLYN_4_6_OR_GREATER;ROSLYN_4_8_OR_GREATER @@ -79,12 +79,12 @@ - - - + + + - $(DefineConstants);ROSLYN4_4;ROSLYN_4_2_OR_GREATER;ROSLYN_4_4_OR_GREATER;ROSLYN_4_5_OR_GREATER;ROSLYN_4_6_OR_GREATER;ROSLYN_4_8_OR_GREATER + $(DefineConstants);ROSLYN4_8;ROSLYN_4_2_OR_GREATER;ROSLYN_4_4_OR_GREATER;ROSLYN_4_5_OR_GREATER;ROSLYN_4_6_OR_GREATER;ROSLYN_4_8_OR_GREATER $(DefineConstants);CSHARP9_OR_GREATER;CSHARP10_OR_GREATER;CSHARP11_OR_GREATER;CSHARP12_OR_GREATER $(NoWarn);CS0618 diff --git a/src/ListDotNetTypes/ListDotNetTypes.csproj b/src/ListDotNetTypes/ListDotNetTypes.csproj index ad8e86f05..0b7b78267 100644 --- a/src/ListDotNetTypes/ListDotNetTypes.csproj +++ b/src/ListDotNetTypes/ListDotNetTypes.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj b/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj index c9e5cf76f..bf37b29a3 100644 --- a/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj +++ b/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj @@ -38,7 +38,7 @@ analyzers - + all analyzers diff --git a/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj b/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj index 379f8f45a..a384acb62 100644 --- a/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj +++ b/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj @@ -26,17 +26,17 @@ + + all analyzers - + all analyzers - - diff --git a/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs b/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs index 958620eac..df9cb9beb 100644 --- a/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs +++ b/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs @@ -27,17 +27,17 @@ public async Task ValidateAsync() { if (DiagnosticAnalyzer == null) { - Assert.True(false, "DiagnosticAnalyzer is not configured"); + Assert.Fail("DiagnosticAnalyzer is not configured"); } if (ExpectedFixedCode != null && CodeFixProvider == null) { - Assert.True(false, "CodeFixProvider is not configured"); + Assert.Fail("CodeFixProvider is not configured"); } if (ExpectedDiagnosticResults == null) { - Assert.True(false, "ExpectedDiagnostic is not configured"); + Assert.Fail("ExpectedDiagnostic is not configured"); } await VerifyDiagnostic(ExpectedDiagnosticResults).ConfigureAwait(false); @@ -76,7 +76,7 @@ private void VerifyDiagnosticResults(IEnumerable actualResults, ILis { var diagnosticsOutput = actualResults.Any() ? FormatDiagnostics(analyzers, actualResults.ToArray()) : " NONE."; - Assert.True(false, $"Mismatch between number of diagnostics returned, expected \"{expectedCount}\" actual \"{actualCount}\"\r\n\r\nDiagnostics:\r\n{diagnosticsOutput}\r\n"); + Assert.Fail($"Mismatch between number of diagnostics returned, expected \"{expectedCount}\" actual \"{actualCount}\"\r\n\r\nDiagnostics:\r\n{diagnosticsOutput}\r\n"); } for (var i = 0; i < expectedResults.Count; i++) @@ -88,8 +88,7 @@ private void VerifyDiagnosticResults(IEnumerable actualResults, ILis { if (actual.Location != Location.None) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected:\nA project diagnostic with No location\nActual:\n{0}", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected:\nA project diagnostic with No location\nActual:\n{0}", FormatDiagnostics(analyzers, actual))); } } @@ -100,8 +99,7 @@ private void VerifyDiagnosticResults(IEnumerable actualResults, ILis if (additionalLocations.Length != expected.Locations.Count - 1) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n", expected.Locations.Count - 1, additionalLocations.Length, FormatDiagnostics(analyzers, actual))); @@ -115,22 +113,19 @@ private void VerifyDiagnosticResults(IEnumerable actualResults, ILis if (expected.Id != null && !string.Equals(actual.Id, expected.Id, StringComparison.Ordinal)) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected diagnostic id to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected diagnostic id to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", expected.Id, actual.Id, FormatDiagnostics(analyzers, actual))); } if (expected.Severity != null && actual.Severity != expected.Severity) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected diagnostic severity to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected diagnostic severity to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", expected.Severity, actual.Severity, FormatDiagnostics(analyzers, actual))); } if (expected.Message != null && !string.Equals(actual.GetMessage(CultureInfo.InvariantCulture), expected.Message, StringComparison.Ordinal)) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected diagnostic message to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected diagnostic message to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", expected.Message, actual.GetMessage(CultureInfo.InvariantCulture), FormatDiagnostics(analyzers, actual))); } } @@ -297,7 +292,7 @@ private async Task GetSortedDiagnosticsFromDocuments(IList d.Severity == DiagnosticSeverity.Error)) + Environment.NewLine + sourceCode); + Assert.Fail("The code doesn't compile. " + string.Join(Environment.NewLine, result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error)) + Environment.NewLine + sourceCode); } } @@ -423,8 +418,7 @@ private static void VerifyDiagnosticLocation(IList analyzers { if (actualLinePosition.Line + 1 != expected.LineStart) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", expected.LineStart, actualLinePosition.Line + 1, FormatDiagnostics(analyzers, diagnostic))); } } @@ -434,8 +428,7 @@ private static void VerifyDiagnosticLocation(IList analyzers { if (actualLinePosition.Character + 1 != expected.ColumnStart) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", expected.ColumnStart, actualLinePosition.Character + 1, FormatDiagnostics(analyzers, diagnostic))); } } @@ -449,8 +442,7 @@ private static void VerifyDiagnosticLocation(IList analyzers { if (actualLinePosition.Line + 1 != expected.LineEnd) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to end on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to end on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", expected.LineStart, actualLinePosition.Line + 1, FormatDiagnostics(analyzers, diagnostic))); } } @@ -460,8 +452,7 @@ private static void VerifyDiagnosticLocation(IList analyzers { if (actualLinePosition.Character + 1 != expected.ColumnEnd) { - Assert.True(false, - string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to end at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", + Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Expected diagnostic to end at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", expected.ColumnStart, actualLinePosition.Character + 1, FormatDiagnostics(analyzers, diagnostic))); } } @@ -486,7 +477,7 @@ private async Task VerifyFix(IList analyzers, CodeFixProvide { if (!codeFixProvider.FixableDiagnosticIds.Any(id => string.Equals(diagnostic.Id, id, StringComparison.Ordinal))) { - Assert.True(false, $"The CodeFixProvider is not valid for the DiagnosticAnalyzer. DiagnosticId: {diagnostic.Id}, Supported diagnostics: {string.Join(",", codeFixProvider.FixableDiagnosticIds)}"); + Assert.Fail($"The CodeFixProvider is not valid for the DiagnosticAnalyzer. DiagnosticId: {diagnostic.Id}, Supported diagnostics: {string.Join(",", codeFixProvider.FixableDiagnosticIds)}"); } } @@ -557,7 +548,7 @@ private async Task ApplyFix(Document document, CodeAction codeAction, sourceCode = (await document.GetSyntaxRootAsync().ConfigureAwait(false)).ToFullString(); } - Assert.True(false, "The fixed code doesn't compile. " + string.Join(Environment.NewLine, result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error)) + Environment.NewLine + sourceCode); + Assert.Fail("The fixed code doesn't compile. " + string.Join(Environment.NewLine, result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error)) + Environment.NewLine + sourceCode); } } diff --git a/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj b/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj index fdd9f77e3..4f07f2c6c 100644 --- a/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj +++ b/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj @@ -17,10 +17,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + +