diff --git a/eng/Versions.props b/eng/Versions.props
index 400ead2786..ffa5db2ba9 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -24,6 +24,9 @@
2.6.1
2.0.0-pre-20160714
+
+ 1.0.0-beta1-63230-04
+
1.3.1
1.4.2
diff --git a/src/MetaCompilation.Analyzers/UnitTests/Verifiers/DiagnosticVerifier.cs b/src/MetaCompilation.Analyzers/UnitTests/Verifiers/DiagnosticVerifier.cs
index f25b59520a..8d6b5de71e 100644
--- a/src/MetaCompilation.Analyzers/UnitTests/Verifiers/DiagnosticVerifier.cs
+++ b/src/MetaCompilation.Analyzers/UnitTests/Verifiers/DiagnosticVerifier.cs
@@ -6,6 +6,7 @@
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -122,7 +123,7 @@ private static void VerifyDiagnosticResults(IEnumerable actualResult
Diagnostic actual = actualResults.ElementAt(i);
DiagnosticResult expected = expectedResults[i];
- if (expected.Line == -1 && expected.Column == -1)
+ if (expected.HasLocation)
{
if (actual.Location != Location.None)
{
@@ -133,20 +134,20 @@ private static void VerifyDiagnosticResults(IEnumerable actualResult
}
else
{
- VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First());
+ VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Spans[0]);
Location[] additionalLocations = actual.AdditionalLocations.ToArray();
- if (additionalLocations.Length != expected.Locations.Length - 1)
+ if (additionalLocations.Length != expected.Spans.Length - 1)
{
Assert.True(false,
string.Format("Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n",
- expected.Locations.Length - 1, additionalLocations.Length,
+ expected.Spans.Length - 1, additionalLocations.Length,
FormatDiagnostics(analyzer, actual)));
}
for (int j = 0; j < additionalLocations.Length; ++j)
{
- VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]);
+ VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Spans[j + 1]);
}
}
@@ -180,7 +181,7 @@ private static void VerifyDiagnosticResults(IEnumerable actualResult
/// The diagnostic that was found in the code
/// The Location of the Diagnostic found in the code
/// The DiagnosticResultLocation that should have been found
- private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, DiagnosticResultLocation expected)
+ private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, FileLinePositionSpan expected)
{
FileLinePositionSpan actualSpan = actual.GetLineSpan();
@@ -191,24 +192,24 @@ private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagno
Microsoft.CodeAnalysis.Text.LinePosition actualLinePosition = actualSpan.StartLinePosition;
// Only check line position if there is an actual line in the real diagnostic
- if (actualLinePosition.Line > 0)
+ if (expected.StartLinePosition.Line > 0)
{
- if (actualLinePosition.Line + 1 != expected.Line)
+ if (actualLinePosition.Line + 1 != expected.StartLinePosition.Line)
{
Assert.True(false,
string.Format("Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
- expected.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzer, diagnostic)));
+ expected.StartLinePosition.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzer, diagnostic)));
}
}
// Only check column position if there is an actual column position in the real diagnostic
if (actualLinePosition.Character > 0)
{
- if (actualLinePosition.Character + 1 != expected.Column)
+ if (actualLinePosition.Character + 1 != expected.StartLinePosition.Character)
{
Assert.True(false,
string.Format("Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
- expected.Column, actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic)));
+ expected.StartLinePosition.Character, actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic)));
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/FixAnalyzers/FixerWithFixAllAnalyzerTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/FixAnalyzers/FixerWithFixAllAnalyzerTests.cs
index 988dad9779..a43cde50fe 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/FixAnalyzers/FixerWithFixAllAnalyzerTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/FixAnalyzers/FixerWithFixAllAnalyzerTests.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.Fixers;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -735,52 +736,44 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpOverrideCodeActionEquivalenceKeyExpectedDiagnostic(int line, int column, string customCodeActionName)
{
string message = string.Format(CodeAnalysisDiagnosticsResources.OverrideCodeActionEquivalenceKeyMessage, customCodeActionName, "EquivalenceKey");
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, FixerWithFixAllAnalyzer.OverrideCodeActionEquivalenceKeyRule.Id, message);
+ return GetExpectedDiagnostic(line, column, FixerWithFixAllAnalyzer.OverrideCodeActionEquivalenceKeyRule.Id, message);
}
private static DiagnosticResult GetBasicOverrideCodeActionEquivalenceKeyExpectedDiagnostic(int line, int column, string customCodeActionName)
{
string message = string.Format(CodeAnalysisDiagnosticsResources.OverrideCodeActionEquivalenceKeyMessage, customCodeActionName, "EquivalenceKey");
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, FixerWithFixAllAnalyzer.OverrideCodeActionEquivalenceKeyRule.Id, message);
+ return GetExpectedDiagnostic(line, column, FixerWithFixAllAnalyzer.OverrideCodeActionEquivalenceKeyRule.Id, message);
}
private static DiagnosticResult GetCSharpCreateCodeActionWithEquivalenceKeyExpectedDiagnostic(int line, int column)
{
string message = string.Format(CodeAnalysisDiagnosticsResources.CreateCodeActionWithEquivalenceKeyMessage, "equivalenceKey");
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, FixerWithFixAllAnalyzer.CreateCodeActionEquivalenceKeyRule.Id, message);
+ return GetExpectedDiagnostic(line, column, FixerWithFixAllAnalyzer.CreateCodeActionEquivalenceKeyRule.Id, message);
}
private static DiagnosticResult GetBasicCreateCodeActionWithEquivalenceKeyExpectedDiagnostic(int line, int column)
{
string message = string.Format(CodeAnalysisDiagnosticsResources.CreateCodeActionWithEquivalenceKeyMessage, "equivalenceKey");
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, FixerWithFixAllAnalyzer.CreateCodeActionEquivalenceKeyRule.Id, message);
+ return GetExpectedDiagnostic(line, column, FixerWithFixAllAnalyzer.CreateCodeActionEquivalenceKeyRule.Id, message);
}
private static DiagnosticResult GetCSharpOverrideGetFixAllProviderExpectedDiagnostic(int line, int column, string codeFixProviderTypeName)
{
string message = string.Format(CodeAnalysisDiagnosticsResources.OverrideGetFixAllProviderMessage, codeFixProviderTypeName);
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, FixerWithFixAllAnalyzer.OverrideGetFixAllProviderRule.Id, message);
+ return GetExpectedDiagnostic(line, column, FixerWithFixAllAnalyzer.OverrideGetFixAllProviderRule.Id, message);
}
private static DiagnosticResult GetBasicOverrideGetFixAllProviderExpectedDiagnostic(int line, int column, string codeFixProviderTypeName)
{
string message = string.Format(CodeAnalysisDiagnosticsResources.OverrideGetFixAllProviderMessage, codeFixProviderTypeName);
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, FixerWithFixAllAnalyzer.OverrideGetFixAllProviderRule.Id, message);
+ return GetExpectedDiagnostic(line, column, FixerWithFixAllAnalyzer.OverrideGetFixAllProviderRule.Id, message);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string id, string message)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, string id, string message)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = id,
- Message = message,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(id, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(message);
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/InternalImplementationOnlyTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/InternalImplementationOnlyTests.cs
index bbcb134cfa..19ef74dcea 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/InternalImplementationOnlyTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/InternalImplementationOnlyTests.cs
@@ -2,7 +2,9 @@
using System.Diagnostics;
using System.Linq;
+using Analyzer.Utilities;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -233,7 +235,7 @@ private void VerifyAcrossTwoAssemblies(string source1, string source2, string la
.AddProjectReference(new ProjectReference(project1.Id));
DiagnosticAnalyzer analyzer = language == LanguageNames.CSharp ? GetCSharpDiagnosticAnalyzer() : GetBasicDiagnosticAnalyzer();
- GetSortedDiagnostics(analyzer, project2.Documents.ToArray()).Verify(analyzer, expected);
+ GetSortedDiagnostics(analyzer, project2.Documents.ToArray()).Verify(analyzer, GetDefaultPath(language), expected);
}
private void VerifyCSharpAcrossTwoAssemblies(string source1, string source2, params DiagnosticResult[] expected)
@@ -258,27 +260,20 @@ protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string typeName, string interfaceName)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, typeName, interfaceName);
+ return GetExpectedDiagnostic(line, column, typeName, interfaceName);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, string typeName, string interfaceName)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, typeName, interfaceName);
+ return GetExpectedDiagnostic(line, column, typeName, interfaceName);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string typeName, string interfaceName)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, string typeName, string interfaceName)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.InternalImplementationOnlyRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.InternalImplementationOnlyMessage, typeName, interfaceName),
- Severity = DiagnosticSeverity.Error,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.InternalImplementationOnlyRuleId, DiagnosticSeverity.Error)
+ .WithLocation(line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.InternalImplementationOnlyMessage)
+ .WithArguments(typeName, interfaceName);
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/AddLanguageSupportToAnalyzerRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/AddLanguageSupportToAnalyzerRuleTests.cs
index e66e82e546..08040a1512 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/AddLanguageSupportToAnalyzerRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/AddLanguageSupportToAnalyzerRuleTests.cs
@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -191,27 +192,20 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string analyzerTypeName, string missingLanguageName)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, analyzerTypeName, missingLanguageName);
+ return GetExpectedDiagnostic(line, column, analyzerTypeName, missingLanguageName);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, string analyzerTypeName, string missingLanguageName)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, analyzerTypeName, missingLanguageName);
+ return GetExpectedDiagnostic(line, column, analyzerTypeName, missingLanguageName);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string analyzerTypeName, string missingLanguageName)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, string analyzerTypeName, string missingLanguageName)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.AddLanguageSupportToAnalyzerRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.AddLanguageSupportToAnalyzerMessage, analyzerTypeName, missingLanguageName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.AddLanguageSupportToAnalyzerRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.AddLanguageSupportToAnalyzerMessage)
+ .WithArguments(analyzerTypeName, missingLanguageName);
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs
index c13d890651..be6ba162c3 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs
@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
using Xunit;
@@ -941,39 +942,40 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string analyzerTypeName, string violatingTypes)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, analyzerTypeName, violatingIndirectTypesOpt: null, violatingTypes: violatingTypes);
+ return GetExpectedDiagnostic(line, column, analyzerTypeName, violatingIndirectTypesOpt: null, violatingTypes: violatingTypes);
}
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string analyzerTypeName, string violatingIndirectTypes, string violatingTypes)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, analyzerTypeName, violatingIndirectTypes, violatingTypes);
+ return GetExpectedDiagnostic(line, column, analyzerTypeName, violatingIndirectTypes, violatingTypes);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, string analyzerTypeName, string violatingTypes)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, analyzerTypeName, violatingIndirectTypesOpt: null, violatingTypes: violatingTypes);
+ return GetExpectedDiagnostic(line, column, analyzerTypeName, violatingIndirectTypesOpt: null, violatingTypes: violatingTypes);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, string analyzerTypeName, string violatingIndirectTypes, string violatingTypes)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, analyzerTypeName, violatingIndirectTypes, violatingTypes);
+ return GetExpectedDiagnostic(line, column, analyzerTypeName, violatingIndirectTypes, violatingTypes);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string analyzerTypeName, string violatingIndirectTypesOpt, string violatingTypes)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, string analyzerTypeName, string violatingIndirectTypesOpt, string violatingTypes)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
+ var result = new DiagnosticResult(DiagnosticIds.DoNotUseTypesFromAssemblyRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column);
+ if (violatingIndirectTypesOpt is null)
{
- Id = DiagnosticIds.DoNotUseTypesFromAssemblyRuleId,
- Message = violatingIndirectTypesOpt == null ?
- string.Format(CodeAnalysisDiagnosticsResources.DoNotUseTypesFromAssemblyRuleDirectMessage, analyzerTypeName, violatingTypes) :
- string.Format(CodeAnalysisDiagnosticsResources.DoNotUseTypesFromAssemblyRuleIndirectMessage, analyzerTypeName, violatingIndirectTypesOpt, violatingTypes),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return result
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.DoNotUseTypesFromAssemblyRuleDirectMessage)
+ .WithArguments(analyzerTypeName, violatingTypes);
+ }
+ else
+ {
+ return result
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.DoNotUseTypesFromAssemblyRuleIndirectMessage)
+ .WithArguments(analyzerTypeName, violatingIndirectTypesOpt, violatingTypes);
+ }
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzerTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzerTests.cs
index 417dd32a06..b1eeec7b80 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzerTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzerTests.cs
@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -850,105 +851,62 @@ private static DiagnosticResult GetBasicRS1020ExpectedDiagnostic(int line, int c
private static DiagnosticResult GetRS1007ExpectedDiagnostic(string language, int line, int column)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.UseLocalizableStringsInDescriptorRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.UseLocalizableStringsInDescriptorMessage, DiagnosticAnalyzerCorrectnessAnalyzer.LocalizableStringFullName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.UseLocalizableStringsInDescriptorRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.UseLocalizableStringsInDescriptorMessage)
+ .WithArguments(DiagnosticAnalyzerCorrectnessAnalyzer.LocalizableStringFullName);
}
private static DiagnosticResult GetRS1015ExpectedDiagnostic(string language, int line, int column)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.ProvideHelpUriInDescriptorRuleId,
- Message = CodeAnalysisDiagnosticsResources.ProvideHelpUriInDescriptorMessage,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.ProvideHelpUriInDescriptorRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.ProvideHelpUriInDescriptorMessage);
}
private static DiagnosticResult GetRS1017ExpectedDiagnostic(string language, int line, int column, string descriptorName)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.DiagnosticIdMustBeAConstantRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.DiagnosticIdMustBeAConstantMessage, descriptorName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.DiagnosticIdMustBeAConstantRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.DiagnosticIdMustBeAConstantMessage)
+ .WithArguments(descriptorName);
}
private static DiagnosticResult GetRS1018ExpectedDiagnostic(string language, int line, int column, string diagnosticId, string category, string format, string additionalFile)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.DiagnosticIdMustBeInSpecifiedFormatRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.DiagnosticIdMustBeInSpecifiedFormatMessage, diagnosticId, category, format, additionalFile),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.DiagnosticIdMustBeInSpecifiedFormatRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.DiagnosticIdMustBeInSpecifiedFormatMessage)
+ .WithArguments(diagnosticId, category, format, additionalFile);
}
private static DiagnosticResult GetRS1019ExpectedDiagnostic(string language, int line, int column, string duplicateId, string otherAnalyzerName)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.UseUniqueDiagnosticIdRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.UseUniqueDiagnosticIdMessage, duplicateId, otherAnalyzerName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.UseUniqueDiagnosticIdRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.UseUniqueDiagnosticIdMessage)
+ .WithArguments(duplicateId, otherAnalyzerName);
}
private static DiagnosticResult GetRS1020ExpectedDiagnostic(string language, int line, int column, string category, string additionalFile)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.UseCategoriesFromSpecifiedRangeRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.UseCategoriesFromSpecifiedRangeMessage, category, additionalFile),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.UseCategoriesFromSpecifiedRangeRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.UseCategoriesFromSpecifiedRangeMessage)
+ .WithArguments(category, additionalFile);
}
private static DiagnosticResult GetRS1021ExpectedDiagnostic(int line, int column, string invalidEntry, string additionalFile)
{
- return new DiagnosticResult
- {
- Id = DiagnosticIds.AnalyzerCategoryAndIdRangeFileInvalidRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.AnalyzerCategoryAndIdRangeFileInvalidMessage, invalidEntry, additionalFile),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(AdditionalFileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.AnalyzerCategoryAndIdRangeFileInvalidRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(AdditionalFileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.AnalyzerCategoryAndIdRangeFileInvalidMessage)
+ .WithArguments(invalidEntry, additionalFile);
}
private const string AdditionalFileName = "DiagnosticCategoryAndIdRanges.txt";
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs
index 18eca43e30..39c147a8c5 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs
@@ -6,6 +6,7 @@
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
@@ -282,16 +283,10 @@ private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column,
private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string violatingTypeName)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.DoNotStorePerCompilationDataOntoFieldsRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.DoNotStorePerCompilationDataOntoFieldsMessage, violatingTypeName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.DoNotStorePerCompilationDataOntoFieldsRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.DoNotStorePerCompilationDataOntoFieldsMessage)
+ .WithArguments(violatingTypeName);
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs
index 953c337203..221e153a83 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs
@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
using Xunit;
@@ -294,16 +295,10 @@ private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column,
private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string unsupportedDescriptorName)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.InvalidReportDiagnosticRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.InvalidReportDiagnosticMessage, unsupportedDescriptorName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.InvalidReportDiagnosticRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.InvalidReportDiagnosticMessage)
+ .WithArguments(unsupportedDescriptorName);
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs
index 02a5e71ee4..f7e2517860 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
using Xunit;
@@ -207,27 +208,20 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string typeArgumentName, string registerMethodName)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, typeArgumentName, registerMethodName);
+ return GetExpectedDiagnostic(line, column, typeArgumentName, registerMethodName);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, string typeArgumentName, string registerMethodName)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, typeArgumentName, registerMethodName);
+ return GetExpectedDiagnostic(line, column, typeArgumentName, registerMethodName);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string typeArgumentName, string registerMethodName)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, string typeArgumentName, string registerMethodName)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.InvalidSyntaxKindTypeArgumentRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.InvalidSyntaxKindTypeArgumentMessage, typeArgumentName, DiagnosticAnalyzerCorrectnessAnalyzer.TLanguageKindEnumName, registerMethodName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.InvalidSyntaxKindTypeArgumentRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.InvalidSyntaxKindTypeArgumentMessage)
+ .WithArguments(typeArgumentName, DiagnosticAnalyzerCorrectnessAnalyzer.TLanguageKindEnumName, registerMethodName);
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingDiagnosticAnalyzerAttributeRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingDiagnosticAnalyzerAttributeRuleTests.cs
index b00be219c7..63ae97c1c9 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingDiagnosticAnalyzerAttributeRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingDiagnosticAnalyzerAttributeRuleTests.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers.Fixers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers.CodeFixes;
using Test.Utilities;
using Xunit;
@@ -240,27 +241,20 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column);
+ return GetExpectedDiagnostic(line, column);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column);
+ return GetExpectedDiagnostic(line, column);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.MissingDiagnosticAnalyzerAttributeRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.MissingAttributeMessage, DiagnosticAnalyzerCorrectnessAnalyzer.DiagnosticAnalyzerAttributeFullName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.MissingDiagnosticAnalyzerAttributeRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.MissingAttributeMessage)
+ .WithArguments(DiagnosticAnalyzerCorrectnessAnalyzer.DiagnosticAnalyzerAttributeFullName);
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs
index 8b9c7f78e5..4ec322f898 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
using Xunit;
@@ -240,15 +241,15 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, MissingKindArgument kind)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, kind);
+ return GetExpectedDiagnostic(line, column, kind);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, MissingKindArgument kind)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, kind);
+ return GetExpectedDiagnostic(line, column, kind);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, MissingKindArgument kind)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, MissingKindArgument kind)
{
string message;
switch (kind)
@@ -269,17 +270,9 @@ private static DiagnosticResult GetExpectedDiagnostic(string language, int line,
throw new ArgumentException("Unsupported argument kind", nameof(kind));
}
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.MissingKindArgumentToRegisterActionRuleId,
- Message = message,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.MissingKindArgumentToRegisterActionRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(message);
}
private enum MissingKindArgument
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs
index 03b32378b5..ef60eb1d5f 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
using Xunit;
@@ -547,16 +548,9 @@ private static DiagnosticResult GetExpectedDiagnostic(string language, int line,
string message = string.Format(CodeAnalysisDiagnosticsResources.StartActionWithNoRegisteredActionsMessage, parameterName, arg2);
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.StartActionWithNoRegisteredActionsRuleId,
- Message = message,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.StartActionWithNoRegisteredActionsRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(message);
}
private enum StartActionKind
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs
index f90b0ddb7f..7a7d2e79e8 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
using Xunit;
@@ -348,15 +349,15 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string parameterName, StartActionKind kind)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, parameterName, kind);
+ return GetExpectedDiagnostic(line, column, parameterName, kind);
}
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, string parameterName, StartActionKind kind)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, parameterName, kind);
+ return GetExpectedDiagnostic(line, column, parameterName, kind);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string parameterName, StartActionKind kind)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, string parameterName, StartActionKind kind)
{
string endActionName;
string statelessActionName;
@@ -387,17 +388,9 @@ private static DiagnosticResult GetExpectedDiagnostic(string language, int line,
string message = string.Format(CodeAnalysisDiagnosticsResources.StartActionWithOnlyEndActionMessage, parameterName, endActionName, statelessActionName, arg4);
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.StartActionWithOnlyEndActionRuleId,
- Message = message,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.StartActionWithOnlyEndActionRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(message);
}
private enum StartActionKind
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs
index 6c41f2600e..6ead0e368a 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs
@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers;
using Test.Utilities;
using Xunit;
@@ -271,16 +272,10 @@ private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column,
private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, SymbolKind unsupportedSymbolKind)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.UnsupportedSymbolKindArgumentRuleId,
- Message = string.Format(CodeAnalysisDiagnosticsResources.UnsupportedSymbolKindArgumentToRegisterActionMessage, unsupportedSymbolKind.ToString()),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.UnsupportedSymbolKindArgumentRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.UnsupportedSymbolKindArgumentToRegisterActionMessage)
+ .WithArguments(unsupportedSymbolKind.ToString());
}
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs
index c81787a4f2..cd65f08b93 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs
@@ -4,6 +4,7 @@
using Analyzer.Utilities;
using Microsoft.CodeAnalysis.CSharp.Analyzers;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic.Analyzers;
using Test.Utilities;
using Xunit;
@@ -103,21 +104,16 @@ End Sub
}
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column)
- => GetExpectedDiagnostic(LanguageNames.CSharp, line, column);
+ => GetExpectedDiagnostic(line, column);
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column)
- => GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column);
-
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column)
- => new DiagnosticResult
- {
- Id = DiagnosticIds.UpgradeMSBuildWorkspaceRuleId,
- Message = CodeAnalysisDiagnosticsResources.UpgradeMSBuildWorkspaceMessage,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb", line, column)
- }
- };
+ => GetExpectedDiagnostic(line, column);
+
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column)
+ {
+ return new DiagnosticResult(DiagnosticIds.UpgradeMSBuildWorkspaceRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.UpgradeMSBuildWorkspaceMessage);
+ }
}
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UseReturnValueFromImmutableObjectMethodTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UseReturnValueFromImmutableObjectMethodTests.cs
index 12e5b64700..de355b8f9e 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UseReturnValueFromImmutableObjectMethodTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/UseReturnValueFromImmutableObjectMethodTests.cs
@@ -1,9 +1,10 @@
// 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 Analyzer.Utilities;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Analyzers;
using Microsoft.CodeAnalysis.Diagnostics;
-using Analyzer.Utilities;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -120,16 +121,10 @@ private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column
private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string objectName, string methodName)
{
string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DiagnosticIds.DoNotIgnoreReturnValueOnImmutableObjectMethodInvocation,
- Message = string.Format(CodeAnalysisDiagnosticsResources.DoNotIgnoreReturnValueOnImmutableObjectMethodInvocationMessage, objectName, methodName),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DiagnosticIds.DoNotIgnoreReturnValueOnImmutableObjectMethodInvocation, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(fileName, line, column)
+ .WithMessageFormat(CodeAnalysisDiagnosticsResources.DoNotIgnoreReturnValueOnImmutableObjectMethodInvocationMessage)
+ .WithArguments(objectName, methodName);
}
}
}
diff --git a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Design/ValidateArgumentsOfPublicMethodsTests.cs b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Design/ValidateArgumentsOfPublicMethodsTests.cs
index 845237f21f..02d813b6aa 100644
--- a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Design/ValidateArgumentsOfPublicMethodsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Design/ValidateArgumentsOfPublicMethodsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.Exp.Design;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Globalization/DoNotPassLiteralsAsLocalizedParametersTests.cs b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Globalization/DoNotPassLiteralsAsLocalizedParametersTests.cs
index 2c7e17ae0a..4cfb0112c3 100644
--- a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Globalization/DoNotPassLiteralsAsLocalizedParametersTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Globalization/DoNotPassLiteralsAsLocalizedParametersTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.Exp.Globalization;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Maintainability/AvoidDeadConditionalCode_NullAnalysis.cs b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Maintainability/AvoidDeadConditionalCode_NullAnalysis.cs
index f072d4416a..b5fa7c5554 100644
--- a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Maintainability/AvoidDeadConditionalCode_NullAnalysis.cs
+++ b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Maintainability/AvoidDeadConditionalCode_NullAnalysis.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.Exp.Maintainability;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Reliability/DisposeObjectsBeforeLosingScopeTests.cs b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Reliability/DisposeObjectsBeforeLosingScopeTests.cs
index f236c552b9..559df5e541 100644
--- a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Reliability/DisposeObjectsBeforeLosingScopeTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Reliability/DisposeObjectsBeforeLosingScopeTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.Exp.Reliability;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Security/ReviewSQLQueriesForSecurityVulnerabilitiesTests.cs b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Security/ReviewSQLQueriesForSecurityVulnerabilitiesTests.cs
index 6328163350..f1b81f00f5 100644
--- a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Security/ReviewSQLQueriesForSecurityVulnerabilitiesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Security/ReviewSQLQueriesForSecurityVulnerabilitiesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.Exp.Security;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposableFieldsShouldBeDisposedTests.cs b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposableFieldsShouldBeDisposedTests.cs
index bda11e355c..63e6bc7403 100644
--- a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposableFieldsShouldBeDisposedTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposableFieldsShouldBeDisposedTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.Exp.Usage;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposeMethodsShouldCallBaseClassDisposeTests.cs b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposeMethodsShouldCallBaseClassDisposeTests.cs
index 9493b33aad..860bc46f8e 100644
--- a/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposeMethodsShouldCallBaseClassDisposeTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers.Exp/UnitTests/Usage/DisposeMethodsShouldCallBaseClassDisposeTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.Exp.Usage;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructorsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructorsTests.cs
index 3f1adfdf7c..393e723ad0 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructorsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructorsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AvoidEmptyInterfacesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AvoidEmptyInterfacesTests.cs
index 53796bb8c0..f63579320b 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AvoidEmptyInterfacesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/AvoidEmptyInterfacesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CancellationTokenParametersMustComeLastTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CancellationTokenParametersMustComeLastTests.cs
index 20b9f5e3d4..8ca11be8dd 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CancellationTokenParametersMustComeLastTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CancellationTokenParametersMustComeLastTests.cs
@@ -1,8 +1,7 @@
// 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 Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
-using Analyzer.Utilities;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -29,17 +28,7 @@ void M(CancellationToken t, int i)
{
}
}";
- var expected = new DiagnosticResult
- {
- Id = CancellationTokenParametersMustComeLastAnalyzer.RuleId,
- Message = string.Format(MicrosoftApiDesignGuidelinesAnalyzersResources.CancellationTokenParametersMustComeLastMessage, "T.M(System.Threading.CancellationToken, int)"),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation("Test0.cs", 5, 10)
- }
- };
-
+ var expected = new DiagnosticResult(CancellationTokenParametersMustComeLastAnalyzer.Rule).WithLocation(5, 10).WithArguments("T.M(System.Threading.CancellationToken, int)");
VerifyCSharp(source, expected);
}
@@ -144,17 +133,7 @@ protected override void M(CancellationToken t, int i) { }
}";
// One diagnostic for the virtual, but none for the override.
- var expected = new DiagnosticResult
- {
- Id = CancellationTokenParametersMustComeLastAnalyzer.RuleId,
- Message = string.Format(MicrosoftApiDesignGuidelinesAnalyzersResources.CancellationTokenParametersMustComeLastMessage, "B.M(System.Threading.CancellationToken, int)"),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation("Test0.cs", 5, 28)
- }
- };
-
+ var expected = new DiagnosticResult(CancellationTokenParametersMustComeLastAnalyzer.Rule).WithLocation(5, 28).WithArguments("B.M(System.Threading.CancellationToken, int)");
VerifyCSharp(test, expected);
}
@@ -174,17 +153,7 @@ public void M(CancellationToken t, int i) { }
}";
// One diagnostic for the interface, but none for the implementation.
- var expected = new DiagnosticResult
- {
- Id = CancellationTokenParametersMustComeLastAnalyzer.RuleId,
- Message = string.Format(MicrosoftApiDesignGuidelinesAnalyzersResources.CancellationTokenParametersMustComeLastMessage, "I.M(System.Threading.CancellationToken, int)"),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation("Test0.cs", 5, 10)
- }
- };
-
+ var expected = new DiagnosticResult(CancellationTokenParametersMustComeLastAnalyzer.Rule).WithLocation(5, 10).WithArguments("I.M(System.Threading.CancellationToken, int)");
VerifyCSharp(test, expected);
}
@@ -204,17 +173,7 @@ void I.M(CancellationToken t, int i) { }
}";
// One diagnostic for the interface, but none for the implementation.
- var expected = new DiagnosticResult
- {
- Id = CancellationTokenParametersMustComeLastAnalyzer.RuleId,
- Message = string.Format(MicrosoftApiDesignGuidelinesAnalyzersResources.CancellationTokenParametersMustComeLastMessage, "I.M(System.Threading.CancellationToken, int)"),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation("Test0.cs", 5, 10)
- }
- };
-
+ var expected = new DiagnosticResult(CancellationTokenParametersMustComeLastAnalyzer.Rule).WithLocation(5, 10).WithArguments("I.M(System.Threading.CancellationToken, int)");
VerifyCSharp(test, expected);
}
@@ -244,17 +203,7 @@ public static void M1(this object p1, CancellationToken p2, object p3)
}
}";
- var expected = new DiagnosticResult
- {
- Id = CancellationTokenParametersMustComeLastAnalyzer.RuleId,
- Message = string.Format(MicrosoftApiDesignGuidelinesAnalyzersResources.CancellationTokenParametersMustComeLastMessage, "C1.M1(object, System.Threading.CancellationToken, object)"),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation("Test0.cs", 5, 24)
- }
- };
-
+ var expected = new DiagnosticResult(CancellationTokenParametersMustComeLastAnalyzer.Rule).WithLocation(5, 24).WithArguments("C1.M1(object, System.Threading.CancellationToken, object)");
VerifyCSharp(test, expected);
}
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnlyTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnlyTests.cs
index d1a3016bab..4ba3289ca2 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnlyTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnlyTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionsShouldImplementGenericInterfaceTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionsShouldImplementGenericInterfaceTests.cs
index 4d1b5105d0..7fd11325f9 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionsShouldImplementGenericInterfaceTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/CollectionsShouldImplementGenericInterfaceTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DeclareTypesInNamespacesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DeclareTypesInNamespacesTests.cs
index 75d163e184..b4ea0e626b 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DeclareTypesInNamespacesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DeclareTypesInNamespacesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DefineAccessorsForAttributeArgumentsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DefineAccessorsForAttributeArgumentsTests.cs
index 804c684ac1..b0a03ac2e2 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DefineAccessorsForAttributeArgumentsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DefineAccessorsForAttributeArgumentsTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.ApiDesignGuidelines;
using Microsoft.CodeQuality.VisualBasic.Analyzers.ApiDesignGuidelines;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotDirectlyAwaitATaskTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotDirectlyAwaitATaskTests.cs
index 5a72c5b47c..702b43c2cb 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotDirectlyAwaitATaskTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotDirectlyAwaitATaskTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotHideBaseClassMethodsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotHideBaseClassMethodsTests.cs
index 9b3b5a817b..fd46beb889 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotHideBaseClassMethodsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotHideBaseClassMethodsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocationsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocationsTests.cs
index e4f58052ed..658589411a 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocationsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocationsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.ApiDesignGuidelines;
using Microsoft.CodeQuality.VisualBasic.Analyzers.ApiDesignGuidelines;
using Test.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/EnumWithFlagsAttributeTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/EnumWithFlagsAttributeTests.cs
index 122fbfefbd..b9623357b8 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/EnumWithFlagsAttributeTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/EnumWithFlagsAttributeTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ExceptionsShouldBePublicTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ExceptionsShouldBePublicTests.cs
index 8c147739c1..53bfa00903 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ExceptionsShouldBePublicTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ExceptionsShouldBePublicTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCaseTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCaseTests.cs
index 0c10b532c7..9ff16eb400 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCaseTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCaseTests.cs
@@ -3,6 +3,7 @@
using System;
using System.Linq;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefixTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefixTests.cs
index b920a2338b..304fdbcb56 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefixTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefixTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffixTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffixTests.cs
index c0f5505d21..a6d2f0a2ea 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffixTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffixTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNamesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNamesTests.cs
index f6cc772515..8240139fea 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNamesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNamesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs
index 7eae89cb30..44b1cc7a76 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs
@@ -3,6 +3,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -870,7 +871,7 @@ private void Verify(string source, string language, DiagnosticAnalyzer analyzer,
{
var sources = new[] { source };
var diagnostics = GetSortedDiagnostics(sources.ToFileAndSource(), language, analyzer, compilationOptions: null, parseOptions: null, referenceFlags: ReferenceFlags.None, projectName: testProjectName);
- diagnostics.Verify(analyzer, expected);
+ diagnostics.Verify(analyzer, GetDefaultPath(language), expected);
}
private static string GetApproriateMessage(SymbolKind symbolKind)
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywordsNamespaceRuleTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywordsNamespaceRuleTests.cs
index 6f35dd1e58..26fe3ff60c 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywordsNamespaceRuleTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywordsNamespaceRuleTests.cs
@@ -2,6 +2,7 @@
using System;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -164,13 +165,7 @@ End Namespace
private DiagnosticResult GetResultNoLocation(DiagnosticDescriptor rule, params object[] messageArguments)
{
- return new DiagnosticResult
- {
- Locations = Array.Empty(),
- Id = rule.Id,
- Severity = rule.DefaultSeverity,
- Message = string.Format(rule.MessageFormat.ToString(), messageArguments)
- };
+ return new DiagnosticResult(rule).WithArguments(messageArguments);
}
}
}
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementIDisposableCorrectlyTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementIDisposableCorrectlyTests.cs
index fd648cee7e..c85afcf513 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementIDisposableCorrectlyTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementIDisposableCorrectlyTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementStandardExceptionConstructorsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementStandardExceptionConstructorsTests.cs
index 136fbe4652..8817539d5f 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementStandardExceptionConstructorsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ImplementStandardExceptionConstructorsTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.ApiDesignGuidelines;
using Microsoft.CodeQuality.VisualBasic.Analyzers.ApiDesignGuidelines;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypesTests.cs
index 59da223513..9c0e78c049 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithAssemblyVersionTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithAssemblyVersionTests.cs
index 26261f575d..cf89a07828 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithAssemblyVersionTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithAssemblyVersionTests.cs
@@ -3,6 +3,7 @@
using Analyzer.Utilities;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -151,11 +152,7 @@ static void Main(string[] args)
");
}
- private static readonly DiagnosticResult s_diagnostic = new DiagnosticResult
- {
- Id = MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1016RuleId,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Message = MicrosoftApiDesignGuidelinesAnalyzersResources.MarkAssembliesWithAssemblyVersionMessage
- };
+ private static readonly DiagnosticResult s_diagnostic = new DiagnosticResult(MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1016RuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithMessageFormat(MicrosoftApiDesignGuidelinesAnalyzersResources.MarkAssembliesWithAssemblyVersionMessage);
}
}
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithClsCompliantTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithClsCompliantTests.cs
index ab1f7730d2..563bc80431 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithClsCompliantTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithClsCompliantTests.cs
@@ -3,6 +3,7 @@
using Analyzer.Utilities;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -188,18 +189,8 @@ static void Main(string[] args)
s_diagnosticCA1016, s_diagnosticCA1014);
}
- private static readonly DiagnosticResult s_diagnosticCA1014 = new DiagnosticResult
- {
- Id = MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1014RuleId,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Message = MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1014Rule.MessageFormat.ToString()
- };
+ private static readonly DiagnosticResult s_diagnosticCA1014 = new DiagnosticResult(MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1014Rule);
- private static readonly DiagnosticResult s_diagnosticCA1016 = new DiagnosticResult
- {
- Id = MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1016RuleId,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Message = MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1016Rule.MessageFormat.ToString()
- };
+ private static readonly DiagnosticResult s_diagnosticCA1016 = new DiagnosticResult(MarkAssembliesWithAttributesDiagnosticAnalyzer.CA1016Rule);
}
}
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithComVisibleTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithComVisibleTests.cs
index b720c36e2b..e08a1ef69d 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithComVisibleTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAssembliesWithComVisibleTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAttributesWithAttributeUsageTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAttributesWithAttributeUsageTests.cs
index c5f594cf09..c2310243dc 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAttributesWithAttributeUsageTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MarkAttributesWithAttributeUsageTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MovePInvokesToNativeMethodsClassTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MovePInvokesToNativeMethodsClassTests.cs
index 594e25001f..2eed49ad37 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MovePInvokesToNativeMethodsClassTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/MovePInvokesToNativeMethodsClassTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/NestedTypesShouldNotBeVisibleTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/NestedTypesShouldNotBeVisibleTests.cs
index 93f513559a..427975fc95 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/NestedTypesShouldNotBeVisibleTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/NestedTypesShouldNotBeVisibleTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternatesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternatesTests.cs
index 80bc1b0292..b951498141 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternatesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternatesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEqualsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEqualsTests.cs
index ea274090cb..6ed65ca4ce 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEqualsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEqualsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypesTests.cs
index c8555f9bd6..592c220a07 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypesTests.cs
@@ -2,6 +2,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -398,37 +399,30 @@ protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpOverrideEqualsDiagnostic(int line, int column, string typeName)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageEquals);
+ return GetExpectedDiagnostic(line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageEquals);
}
private static DiagnosticResult GetCSharpOperatorEqualsDiagnostic(int line, int column, string typeName)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageOpEquality);
+ return GetExpectedDiagnostic(line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageOpEquality);
}
private static DiagnosticResult GetBasicOverrideEqualsDiagnostic(int line, int column, string typeName)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageEquals);
+ return GetExpectedDiagnostic(line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageEquals);
}
private static DiagnosticResult GetBasicOperatorEqualsDiagnostic(int line, int column, string typeName)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageOpEquality);
+ return GetExpectedDiagnostic(line, column, typeName, MicrosoftApiDesignGuidelinesAnalyzersResources.OverrideEqualsAndOperatorEqualsOnValueTypesMessageOpEquality);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, string typeName, string messageFormat)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column, string typeName, string messageFormat)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = OverrideEqualsAndOperatorEqualsOnValueTypesAnalyzer.RuleId,
- Message = string.Format(messageFormat, typeName),
- Severity = OverrideEqualsAndOperatorEqualsOnValueTypesAnalyzer.EqualsRule.DefaultSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(OverrideEqualsAndOperatorEqualsOnValueTypesAnalyzer.EqualsRule)
+ .WithLocation(line, column)
+ .WithMessageFormat(messageFormat)
+ .WithArguments(typeName);
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideMethodsOnComparableTypesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideMethodsOnComparableTypesTests.cs
index 3d5f5430e4..f465f61b62 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideMethodsOnComparableTypesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/OverrideMethodsOnComparableTypesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclarationTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclarationTests.cs
index 759e938b66..9e7f074ce2 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclarationTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclarationTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStringsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStringsTests.cs
index 4a55042eb3..11d5dd958a 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStringsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStringsTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.ApiDesignGuidelines;
using Microsoft.CodeQuality.VisualBasic.Analyzers.ApiDesignGuidelines;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnlyTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnlyTests.cs
index ccfe4b40d3..99647bc733 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnlyTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnlyTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotReturnArraysTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotReturnArraysTests.cs
index 0a1b3d0888..593419fdc6 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotReturnArraysTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertiesShouldNotReturnArraysTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethodsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethodsTests.cs
index 1822b4502f..5c936df605 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethodsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethodsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ProvideObsoleteAttributeMessageTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ProvideObsoleteAttributeMessageTests.cs
index f5fa4b9fdc..e46abfa09b 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ProvideObsoleteAttributeMessageTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/ProvideObsoleteAttributeMessageTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/StaticHolderTypeTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/StaticHolderTypeTests.cs
index 38f543556d..b21ce7ebce 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/StaticHolderTypeTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/StaticHolderTypeTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespacesTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespacesTests.cs
index 47e4c16ff9..5ea21d73e2 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespacesTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespacesTests.cs
@@ -3,6 +3,7 @@
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -95,8 +96,7 @@ public class Sdk
Project project = document.Project.AddMetadataReference(MetadataReference.CreateFromFile(typeof(Xunit.Sdk.AllException).Assembly.Location));
DiagnosticAnalyzer analyzer = GetCSharpDiagnosticAnalyzer();
GetSortedDiagnostics(analyzer, project.Documents.Single())
- .Verify(analyzer,
- CSharpDefaultResultAt(2, 14, "Sdk", "Xunit.Sdk"));
+ .Verify(analyzer, GetDefaultPath(LanguageNames.CSharp), CSharpDefaultResultAt(2, 14, "Sdk", "Xunit.Sdk"));
}
[Fact, WorkItem(1673,"https://github.com/dotnet/roslyn-analyzers/issues/1673")]
@@ -284,8 +284,7 @@ Public Class Sdk
Project project = document.Project.AddMetadataReference(MetadataReference.CreateFromFile(typeof(Xunit.Sdk.AllException).Assembly.Location));
DiagnosticAnalyzer analyzer = GetCSharpDiagnosticAnalyzer();
GetSortedDiagnostics(analyzer, project.Documents.Single())
- .Verify(analyzer,
- BasicDefaultResultAt(2, 14, "Sdk", "Xunit.Sdk"));
+ .Verify(analyzer, GetDefaultPath(LanguageNames.VisualBasic), BasicDefaultResultAt(2, 14, "Sdk", "Xunit.Sdk"));
}
}
}
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposableTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposableTests.cs
index 39c69d19bd..001988c754 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposableTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposableTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.ApiDesignGuidelines;
using Microsoft.CodeQuality.VisualBasic.Analyzers.ApiDesignGuidelines;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriParametersShouldNotBeStringsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriParametersShouldNotBeStringsTests.cs
index 9fc7faf453..e97ae7b5c3 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriParametersShouldNotBeStringsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriParametersShouldNotBeStringsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriPropertiesShouldNotBeStringsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriPropertiesShouldNotBeStringsTests.cs
index c155dc7ea9..be983caa7d 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriPropertiesShouldNotBeStringsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriPropertiesShouldNotBeStringsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriReturnValuesShouldNotBeStringsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriReturnValuesShouldNotBeStringsTests.cs
index 3dae19d5af..a78f13fa18 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriReturnValuesShouldNotBeStringsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UriReturnValuesShouldNotBeStringsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexersTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexersTests.cs
index 7172fb8961..d33bb3a838 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexersTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexersTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UsePropertiesWhereAppropriateTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UsePropertiesWhereAppropriateTests.cs
index e899ef782e..d060d2f62b 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UsePropertiesWhereAppropriateTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/UsePropertiesWhereAppropriateTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Documentation/AvoidUsingCrefTagsWithAPrefixTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Documentation/AvoidUsingCrefTagsWithAPrefixTests.cs
index ec5e4baa18..c2b575927b 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Documentation/AvoidUsingCrefTagsWithAPrefixTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Documentation/AvoidUsingCrefTagsWithAPrefixTests.cs
@@ -1,9 +1,10 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
-using Test.Utilities;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.Documentation;
using Microsoft.CodeQuality.VisualBasic.Analyzers.Documentation;
+using Test.Utilities;
using Xunit;
namespace Microsoft.CodeQuality.Analyzers.Documentation.UnitTests
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/AvoidUnusedPrivateFieldsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/AvoidUnusedPrivateFieldsTests.cs
index 9081a833d2..cd65f90967 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/AvoidUnusedPrivateFieldsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/AvoidUnusedPrivateFieldsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/CodeMetricsAnalyzerTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/CodeMetricsAnalyzerTests.cs
index d8936a3c26..7b72f1d195 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/CodeMetricsAnalyzerTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/CodeMetricsAnalyzerTests.cs
@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -658,120 +659,86 @@ protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpCA1501ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold, string baseTypes)
{
- return GetCA1501ExpectedDiagnostic(LanguageNames.CSharp, line, column, symbolName, metricValue, threshold, baseTypes);
+ return GetCA1501ExpectedDiagnostic(line, column, symbolName, metricValue, threshold, baseTypes);
}
private static DiagnosticResult GetBasicCA1501ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold, string baseTypes)
{
- return GetCA1501ExpectedDiagnostic(LanguageNames.VisualBasic, line, column, symbolName, metricValue, threshold, baseTypes);
+ return GetCA1501ExpectedDiagnostic(line, column, symbolName, metricValue, threshold, baseTypes);
}
private static DiagnosticResult GetCSharpCA1502ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold)
{
- return GetCA1502ExpectedDiagnostic(LanguageNames.CSharp, line, column, symbolName, metricValue, threshold);
+ return GetCA1502ExpectedDiagnostic(line, column, symbolName, metricValue, threshold);
}
private static DiagnosticResult GetBasicCA1502ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold)
{
- return GetCA1502ExpectedDiagnostic(LanguageNames.VisualBasic, line, column, symbolName, metricValue, threshold);
+ return GetCA1502ExpectedDiagnostic(line, column, symbolName, metricValue, threshold);
}
private static DiagnosticResult GetCSharpCA1505ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold)
{
- return GetCA1505ExpectedDiagnostic(LanguageNames.CSharp, line, column, symbolName, metricValue, threshold);
+ return GetCA1505ExpectedDiagnostic(line, column, symbolName, metricValue, threshold);
}
private static DiagnosticResult GetBasicCA1505ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold)
{
- return GetCA1505ExpectedDiagnostic(LanguageNames.VisualBasic, line, column, symbolName, metricValue, threshold);
+ return GetCA1505ExpectedDiagnostic(line, column, symbolName, metricValue, threshold);
}
private static DiagnosticResult GetCSharpCA1506ExpectedDiagnostic(int line, int column, string symbolName, int coupledTypesCount, int namespaceCount, int threshold)
{
- return GetCA1506ExpectedDiagnostic(LanguageNames.CSharp, line, column, symbolName, coupledTypesCount, namespaceCount, threshold);
+ return GetCA1506ExpectedDiagnostic(line, column, symbolName, coupledTypesCount, namespaceCount, threshold);
}
private static DiagnosticResult GetBasicCA1506ExpectedDiagnostic(int line, int column, string symbolName, int coupledTypesCount, int namespaceCount, int threshold)
{
- return GetCA1506ExpectedDiagnostic(LanguageNames.VisualBasic, line, column, symbolName, coupledTypesCount, namespaceCount, threshold);
+ return GetCA1506ExpectedDiagnostic(line, column, symbolName, coupledTypesCount, namespaceCount, threshold);
}
// '{0}' has an object hierarchy '{1}' levels deep within the defining module. If possible, eliminate base classes within the hierarchy to decrease its hierarchy level below '{2}': '{3}'
- private static DiagnosticResult GetCA1501ExpectedDiagnostic(string language, int line, int column, string symbolName, int metricValue, int threshold, string baseTypes)
+ private static DiagnosticResult GetCA1501ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold, string baseTypes)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = CodeMetricsAnalyzer.CA1501RuleId,
- Message = string.Format(MicrosoftMaintainabilityAnalyzersResources.AvoidExcessiveInheritanceMessage, symbolName, metricValue, threshold, baseTypes),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(CodeMetricsAnalyzer.CA1501RuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(MicrosoftMaintainabilityAnalyzersResources.AvoidExcessiveInheritanceMessage)
+ .WithArguments(symbolName, metricValue, threshold, baseTypes);
}
// '{0}' has a cyclomatic complexity of '{1}'. Rewrite or refactor the code to decrease its complexity below '{2}'.
- private static DiagnosticResult GetCA1502ExpectedDiagnostic(string language, int line, int column, string symbolName, int metricValue, int threshold)
+ private static DiagnosticResult GetCA1502ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = CodeMetricsAnalyzer.CA1502RuleId,
- Message = string.Format(MicrosoftMaintainabilityAnalyzersResources.AvoidExcessiveComplexityMessage, symbolName, metricValue, threshold),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(CodeMetricsAnalyzer.CA1502RuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(MicrosoftMaintainabilityAnalyzersResources.AvoidExcessiveComplexityMessage)
+ .WithArguments(symbolName, metricValue, threshold);
}
// '{0}' has a maintainability index of '{1}'. Rewrite or refactor the code to increase its maintainability index (MI) above '{2}'.
- private static DiagnosticResult GetCA1505ExpectedDiagnostic(string language, int line, int column, string symbolName, int metricValue, int threshold)
+ private static DiagnosticResult GetCA1505ExpectedDiagnostic(int line, int column, string symbolName, int metricValue, int threshold)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = CodeMetricsAnalyzer.CA1505RuleId,
- Message = string.Format(MicrosoftMaintainabilityAnalyzersResources.AvoidUnmantainableCodeMessage, symbolName, metricValue, threshold),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(CodeMetricsAnalyzer.CA1505RuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(MicrosoftMaintainabilityAnalyzersResources.AvoidUnmantainableCodeMessage)
+ .WithArguments(symbolName, metricValue, threshold);
}
// '{0}' is coupled with '{1}' different types from '{2}' different namespaces. Rewrite or refactor the code to decrease its class coupling below '{3}'.
- private static DiagnosticResult GetCA1506ExpectedDiagnostic(string language, int line, int column, string symbolName, int coupledTypesCount, int namespaceCount, int threshold)
+ private static DiagnosticResult GetCA1506ExpectedDiagnostic(int line, int column, string symbolName, int coupledTypesCount, int namespaceCount, int threshold)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = CodeMetricsAnalyzer.CA1506RuleId,
- Message = string.Format(MicrosoftMaintainabilityAnalyzersResources.AvoidExcessiveClassCouplingMessage, symbolName, coupledTypesCount, namespaceCount, threshold),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(CodeMetricsAnalyzer.CA1506RuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(line, column)
+ .WithMessageFormat(MicrosoftMaintainabilityAnalyzersResources.AvoidExcessiveClassCouplingMessage)
+ .WithArguments(symbolName, coupledTypesCount, namespaceCount, threshold);
}
private static DiagnosticResult GetCA1509ExpectedDiagnostic(int line, int column, string entry, string additionalFile)
{
- return new DiagnosticResult
- {
- Id = CodeMetricsAnalyzer.CA1509RuleId,
- Message = string.Format(MicrosoftMaintainabilityAnalyzersResources.InvalidEntryInCodeMetricsConfigFileMessage, entry, additionalFile),
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(AdditionalFileName, line, column)
- }
- };
+ return new DiagnosticResult(CodeMetricsAnalyzer.CA1509RuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
+ .WithLocation(AdditionalFileName, line, column)
+ .WithMessageFormat(MicrosoftMaintainabilityAnalyzersResources.InvalidEntryInCodeMetricsConfigFileMessage)
+ .WithArguments(entry, additionalFile);
}
private const string AdditionalFileName = "CodeMetricsConfig.txt";
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/DoNotIgnoreMethodResultsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/DoNotIgnoreMethodResultsTests.cs
index 9b693853d3..8264bd7bb1 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/DoNotIgnoreMethodResultsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/DoNotIgnoreMethodResultsTests.cs
@@ -2,6 +2,7 @@
using System;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Test.Utilities.MinimalImplementations;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/ReviewUnusedParametersTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/ReviewUnusedParametersTests.cs
index 80830b079b..bf052b9da7 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/ReviewUnusedParametersTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/ReviewUnusedParametersTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/UseNameOfInPlaceOfStringTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/UseNameOfInPlaceOfStringTests.cs
index 9c20473a12..af63bac9ee 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/UseNameOfInPlaceOfStringTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/Maintainability/UseNameOfInPlaceOfStringTests.cs
@@ -2,6 +2,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.VisualBasic;
using Microsoft.CodeQuality.CSharp.Analyzers.Maintainability;
using Microsoft.CodeQuality.VisualBasic.Analyzers.Maintainability;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/AvoidDuplicateElementInitializationTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/AvoidDuplicateElementInitializationTests.cs
index 59615ad1bd..d4959da19e 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/AvoidDuplicateElementInitializationTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/AvoidDuplicateElementInitializationTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.QualityGuidelines;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/DoNotCallOverridableMethodsInConstructorsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/DoNotCallOverridableMethodsInConstructorsTests.cs
index 2340c6d0a9..465ebce9e9 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/DoNotCallOverridableMethodsInConstructorsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/DoNotCallOverridableMethodsInConstructorsTests.cs
@@ -3,6 +3,7 @@
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/MarkMembersAsStaticTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/MarkMembersAsStaticTests.cs
index 61d778b076..45fca3b963 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/MarkMembersAsStaticTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/MarkMembersAsStaticTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Test.Utilities.MinimalImplementations;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/PreferJaggedArraysOverMultidimensionalTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/PreferJaggedArraysOverMultidimensionalTests.cs
index f67666fe2e..3fd05fd80b 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/PreferJaggedArraysOverMultidimensionalTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/PreferJaggedArraysOverMultidimensionalTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RemoveEmptyFinalizersTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RemoveEmptyFinalizersTests.cs
index 5ae64afd24..e7bef77f83 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RemoveEmptyFinalizersTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RemoveEmptyFinalizersTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.QualityGuidelines;
using Microsoft.CodeQuality.VisualBasic.Analyzers.QualityGuidelines;
using Test.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RethrowToPreserveStackDetailsTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RethrowToPreserveStackDetailsTests.cs
index 07d745e258..8cfb81166d 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RethrowToPreserveStackDetailsTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/RethrowToPreserveStackDetailsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.CSharp.Analyzers.QualityGuidelines;
using Microsoft.CodeQuality.VisualBasic.Analyzers.QualityGuidelines;
using Test.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/UseLiteralsWhereAppropriateTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/UseLiteralsWhereAppropriateTests.cs
index 1dad8170e1..245738fe4b 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/UseLiteralsWhereAppropriateTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/QualityGuidelines/UseLiteralsWhereAppropriateTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValueTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValueTests.cs
index ac1c03e52f..f9d10d7ae5 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValueTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValueTests.cs
@@ -2,6 +2,7 @@
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Test.Utilities.MinimalImplementations;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/InteropServices/PInvokeDiagnosticAnalyzerTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/InteropServices/PInvokeDiagnosticAnalyzerTests.cs
index cf4f94b6f3..9f7124b784 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/InteropServices/PInvokeDiagnosticAnalyzerTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/InteropServices/PInvokeDiagnosticAnalyzerTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AttributeStringLiteralsShouldParseCorrectlyTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AttributeStringLiteralsShouldParseCorrectlyTests.cs
index 384df39367..526674ed3d 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AttributeStringLiteralsShouldParseCorrectlyTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AttributeStringLiteralsShouldParseCorrectlyTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidUnsealedAttributesTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidUnsealedAttributesTests.cs
index 56e91c4e2b..95a3c3adeb 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidUnsealedAttributesTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidUnsealedAttributesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidZeroLengthArrayAllocationsTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidZeroLengthArrayAllocationsTests.cs
index cfd5e5b5b9..4324443d84 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidZeroLengthArrayAllocationsTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/AvoidZeroLengthArrayAllocationsTests.cs
@@ -4,6 +4,7 @@
using System.Reflection;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.NetCore.CSharp.Analyzers.Runtime;
using Microsoft.NetCore.VisualBasic.Analyzers.Runtime;
using Test.Utilities;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/CallGCSuppressFinalizeCorrectlyTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/CallGCSuppressFinalizeCorrectlyTests.cs
index 72263d5534..9295a39d43 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/CallGCSuppressFinalizeCorrectlyTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/CallGCSuppressFinalizeCorrectlyTests.cs
@@ -2,6 +2,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DisposableTypesShouldDeclareFinalizerTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DisposableTypesShouldDeclareFinalizerTests.cs
index bfbb7fcbef..cf1f68c575 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DisposableTypesShouldDeclareFinalizerTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DisposableTypesShouldDeclareFinalizerTests.cs
@@ -2,6 +2,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -500,27 +501,17 @@ protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
private static DiagnosticResult GetCSharpDiagnostic(int line, int column)
{
- return GetExpectedDiagnostic(LanguageNames.CSharp, line, column);
+ return GetExpectedDiagnostic(line, column);
}
private static DiagnosticResult GetBasicDiagnostic(int line, int column)
{
- return GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column);
+ return GetExpectedDiagnostic(line, column);
}
- private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column)
+ private static DiagnosticResult GetExpectedDiagnostic(int line, int column)
{
- string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb";
- return new DiagnosticResult
- {
- Id = DisposableTypesShouldDeclareFinalizerAnalyzer.RuleId,
- Message = SystemRuntimeAnalyzersResources.DisposableTypesShouldDeclareFinalizerMessage,
- Severity = DisposableTypesShouldDeclareFinalizerAnalyzer.Rule.DefaultSeverity,
- Locations = new[]
- {
- new DiagnosticResultLocation(fileName, line, column)
- }
- };
+ return new DiagnosticResult(DisposableTypesShouldDeclareFinalizerAnalyzer.Rule).WithLocation(line, column);
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotLockOnObjectsWithWeakIdentityTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotLockOnObjectsWithWeakIdentityTests.cs
index 93a0e488f6..46e8bebf79 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotLockOnObjectsWithWeakIdentityTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotLockOnObjectsWithWeakIdentityTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotRaiseReservedExceptionTypesTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotRaiseReservedExceptionTypesTests.cs
index 723233c12f..521209b0d1 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotRaiseReservedExceptionTypesTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotRaiseReservedExceptionTypesTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.NetCore.CSharp.Analyzers.Runtime;
using Microsoft.NetCore.VisualBasic.Analyzers.Runtime;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectlyTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectlyTests.cs
index 6e11fe6ddb..97388583ef 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectlyTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectlyTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InitializeStaticFieldsInlineTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InitializeStaticFieldsInlineTests.cs
index 6c14bf2ef8..ab635f6ae9 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InitializeStaticFieldsInlineTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InitializeStaticFieldsInlineTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.NetCore.CSharp.Analyzers.Runtime;
using Microsoft.NetCore.VisualBasic.Analyzers.Runtime;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InstantiateArgumentExceptionsCorrectlyTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InstantiateArgumentExceptionsCorrectlyTests.cs
index 4955670b8c..cdbf10b2ab 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InstantiateArgumentExceptionsCorrectlyTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/InstantiateArgumentExceptionsCorrectlyTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/NormalizeStringsToUppercaseTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/NormalizeStringsToUppercaseTests.cs
index a37f9d085b..ab1dc3b072 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/NormalizeStringsToUppercaseTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/NormalizeStringsToUppercaseTests.cs
@@ -2,6 +2,7 @@
using System.Globalization;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs
index cdda35965a..dcd0761c3b 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyIFormatProviderTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyIFormatProviderTests.cs
index 0ff253b0fb..c799d217d3 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyIFormatProviderTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyIFormatProviderTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyStringComparisonTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyStringComparisonTests.cs
index 98684f4e7e..d6af598ad5 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyStringComparisonTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/SpecifyStringComparisonTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForEmptyStringsUsingStringLengthTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForEmptyStringsUsingStringLengthTests.cs
index 15b5051b43..bf86156763 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForEmptyStringsUsingStringLengthTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForEmptyStringsUsingStringLengthTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForNaNCorrectlyTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForNaNCorrectlyTests.cs
index 27367d98b3..6b261e9a70 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForNaNCorrectlyTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/TestForNaNCorrectlyTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/UseOrdinalStringComparisonTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/UseOrdinalStringComparisonTests.cs
index 8457ff14b5..032768b2f3 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/UseOrdinalStringComparisonTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Runtime/UseOrdinalStringComparisonTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.NetCore.CSharp.Analyzers.Runtime;
using Microsoft.NetCore.VisualBasic.Analyzers.Runtime;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Tasks/DoNotCreateTasksWithoutPassingATaskSchedulerTests.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Tasks/DoNotCreateTasksWithoutPassingATaskSchedulerTests.cs
index 5b329670bc..378949f143 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Tasks/DoNotCreateTasksWithoutPassingATaskSchedulerTests.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Tasks/DoNotCreateTasksWithoutPassingATaskSchedulerTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotCatchCorruptedStateExceptionsTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotCatchCorruptedStateExceptionsTests.cs
index 51d06259f5..4b24fc5e33 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotCatchCorruptedStateExceptionsTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotCatchCorruptedStateExceptionsTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs
index 67d56b54e7..40089bb73e 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs
index 602cfed2ca..61d0fba3f4 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs
index 342bad028f..4f16466653 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs
index 0134ffccde..236f0d4321 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.NetFramework.CSharp.Analyzers;
using Microsoft.NetFramework.VisualBasic.Analyzers;
-using Microsoft.CodeAnalysis.Diagnostics;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs
index 008350f72d..3ee2a17c55 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs
index 1b608772fd..87c36ac150 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs
index 9a5a9e716e..b81d695dca 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
@@ -460,13 +461,8 @@ End Class
[Fact]
public void XmlTextReaderDerivedTypeParseAndUrlResolverMethodShouldGenerateDiagnostic()
{
- DiagnosticResult diagWith2Locations = GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(17, 13, "method");
-
- diagWith2Locations.Locations = new[]
- {
- diagWith2Locations.Locations[0],
- new DiagnosticResultLocation(diagWith2Locations.Locations[0].Path, 18, 13)
- };
+ DiagnosticResult diagWith2Locations = GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(17, 13, "method")
+ .WithLocation(18, 13);
VerifyCSharp(@"
using System;
@@ -492,13 +488,8 @@ public void method()
diagWith2Locations
);
- diagWith2Locations = GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodBasicResultAt(13, 13, "method");
-
- diagWith2Locations.Locations = new[]
- {
- diagWith2Locations.Locations[0],
- new DiagnosticResultLocation(diagWith2Locations.Locations[0].Path, 14, 13)
- };
+ diagWith2Locations = GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodBasicResultAt(13, 13, "method")
+ .WithLocation(14, 13);
VerifyBasic(@"
Imports System.Xml
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs
index a2b6101358..3cd355667d 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs
index 8c802b7ee0..7c1eb93b44 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs
index b70f9e2463..83ffa75e9a 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs
index 3a7e265009..3473d338df 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs
index d51a6723f4..3db7a63f7b 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs
index 8190d2bb9d..d7b0ffbd41 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs
index ccd7ac2273..d9334efc69 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs
index d6314bd441..b74a917f19 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs
index f6de3e11a8..fa5dcd7b33 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs
index 2dbb26f90e..b83b8c361b 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs
index 0c9b368fd1..9d7ec60d05 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs
index 1cb0d0cdba..37d750b1f9 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs
index 54deb6ecfb..09b501924f 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureConstructedSettingsTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureConstructedSettingsTests.cs
index 5d6dcc1349..eefaa36515 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureConstructedSettingsTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureConstructedSettingsTests.cs
@@ -1,9 +1,10 @@
// 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 Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.NetFramework.CSharp.Analyzers;
using Microsoft.NetFramework.VisualBasic.Analyzers;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.CSharp;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureInputSettingsTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureInputSettingsTests.cs
index c86bc1f3cf..0cfee3c2dd 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureInputSettingsTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/DoNotUseInsecureXSLTScriptExecutionXslCompiledTransformLoadInsecureInputSettingsTests.cs
@@ -1,5 +1,6 @@
// 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 Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/ImplementSerializationConstructorsTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/ImplementSerializationConstructorsTests.cs
index aade74245d..6ac24b8d20 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/ImplementSerializationConstructorsTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/ImplementSerializationConstructorsTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
-using Xunit;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
+using Xunit;
namespace Microsoft.NetFramework.Analyzers.UnitTests
{
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkAllNonSerializableFieldsTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkAllNonSerializableFieldsTests.cs
index 3c7f70ca19..7a35b4b956 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkAllNonSerializableFieldsTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkAllNonSerializableFieldsTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
-using Xunit;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
+using Xunit;
namespace Microsoft.NetFramework.Analyzers.UnitTests
{
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkISerializableTypesWithSerializableTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkISerializableTypesWithSerializableTests.cs
index 08dd7ed4c1..55fc143732 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkISerializableTypesWithSerializableTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/MarkISerializableTypesWithSerializableTests.cs
@@ -1,8 +1,9 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
-using Xunit;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
+using Xunit;
namespace Microsoft.NetFramework.Analyzers.UnitTests
{
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/Security/MarkVerbHandlersWithValidateAntiforgeryTokenTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/Security/MarkVerbHandlersWithValidateAntiforgeryTokenTests.cs
index 6f39ebc304..82d3fd3da9 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/Security/MarkVerbHandlersWithValidateAntiforgeryTokenTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/Security/MarkVerbHandlersWithValidateAntiforgeryTokenTests.cs
@@ -2,6 +2,7 @@
using System.Linq;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Microsoft.NetFramework.Analyzers/UnitTests/TypesShouldNotExtendCertainBaseTypesTests.cs b/src/Microsoft.NetFramework.Analyzers/UnitTests/TypesShouldNotExtendCertainBaseTypesTests.cs
index d42d1c012c..206a6b7d28 100644
--- a/src/Microsoft.NetFramework.Analyzers/UnitTests/TypesShouldNotExtendCertainBaseTypesTests.cs
+++ b/src/Microsoft.NetFramework.Analyzers/UnitTests/TypesShouldNotExtendCertainBaseTypesTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Roslyn.Diagnostics.Analyzers/UnitTests/DeclarePublicAPIAnalyzerTests.cs b/src/Roslyn.Diagnostics.Analyzers/UnitTests/DeclarePublicAPIAnalyzerTests.cs
index bb510eaf35..54ed29b17b 100644
--- a/src/Roslyn.Diagnostics.Analyzers/UnitTests/DeclarePublicAPIAnalyzerTests.cs
+++ b/src/Roslyn.Diagnostics.Analyzers/UnitTests/DeclarePublicAPIAnalyzerTests.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Roslyn.Diagnostics.Analyzers/UnitTests/DoNotMixAttributesFromDifferentVersionsOfMEFTests.cs b/src/Roslyn.Diagnostics.Analyzers/UnitTests/DoNotMixAttributesFromDifferentVersionsOfMEFTests.cs
index b920de8fc0..16b57ccca3 100644
--- a/src/Roslyn.Diagnostics.Analyzers/UnitTests/DoNotMixAttributesFromDifferentVersionsOfMEFTests.cs
+++ b/src/Roslyn.Diagnostics.Analyzers/UnitTests/DoNotMixAttributesFromDifferentVersionsOfMEFTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Roslyn.Diagnostics.Analyzers/UnitTests/PartsExportedWithMEFv2MustBeMarkedAsSharedTests.cs b/src/Roslyn.Diagnostics.Analyzers/UnitTests/PartsExportedWithMEFv2MustBeMarkedAsSharedTests.cs
index afa98391bd..10e4d290d6 100644
--- a/src/Roslyn.Diagnostics.Analyzers/UnitTests/PartsExportedWithMEFv2MustBeMarkedAsSharedTests.cs
+++ b/src/Roslyn.Diagnostics.Analyzers/UnitTests/PartsExportedWithMEFv2MustBeMarkedAsSharedTests.cs
@@ -1,6 +1,7 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Test.Utilities;
using Xunit;
diff --git a/src/Test.Utilities/DiagnosticAnalyzerTestBase.cs b/src/Test.Utilities/DiagnosticAnalyzerTestBase.cs
index 687c053b13..52361f2f41 100644
--- a/src/Test.Utilities/DiagnosticAnalyzerTestBase.cs
+++ b/src/Test.Utilities/DiagnosticAnalyzerTestBase.cs
@@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.VisualBasic;
using Roslyn.Utilities;
@@ -117,22 +118,12 @@ public static MetadataReference SystemThreadingTaskFacadeRef
protected static DiagnosticResult GetGlobalResult(string id, string message)
{
- return new DiagnosticResult
- {
- Id = id,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Message = message
- };
+ return new DiagnosticResult(id, DiagnosticHelpers.DefaultDiagnosticSeverity).WithMessage(message);
}
protected static DiagnosticResult GetGlobalResult(DiagnosticDescriptor rule, params string[] messageArguments)
{
- return new DiagnosticResult
- {
- Id = rule.Id,
- Severity = rule.DefaultSeverity,
- Message = string.Format(rule.MessageFormat.ToString(), messageArguments)
- };
+ return new DiagnosticResult(rule).WithMessage(string.Format(rule.MessageFormat.ToString(), messageArguments));
}
protected static DiagnosticResult GetBasicResultAt(int line, int column, string id, string message)
@@ -167,44 +158,28 @@ protected static DiagnosticResult GetAdditionalFileResultAt(int line, int column
private static DiagnosticResult GetResultAt(string path, int line, int column, string id, string message)
{
- var location = new DiagnosticResultLocation(path, line, column);
-
- return new DiagnosticResult
- {
- Locations = new[] { location },
- Id = id,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Message = message
- };
+ return new DiagnosticResult(id, DiagnosticHelpers.DefaultDiagnosticSeverity).WithLocation(path, line, column).WithMessage(message);
}
protected static DiagnosticResult GetResultAt(string path, string id, string message, params string[] locationStrings)
{
- return new DiagnosticResult
+ var result = new DiagnosticResult(id, DiagnosticHelpers.DefaultDiagnosticSeverity).WithMessage(message);
+ foreach (var location in ParseResultLocations(path, locationStrings))
{
- Locations = ParseResultLocations(path, locationStrings),
- Id = id,
- Severity = DiagnosticHelpers.DefaultDiagnosticSeverity,
- Message = message
- };
+ result = result.WithLocation(location.path, location.location);
+ }
+
+ return result;
}
private static DiagnosticResult GetResultAt(string path, int line, int column, DiagnosticDescriptor rule, params object[] messageArguments)
{
- var location = new DiagnosticResultLocation(path, line, column);
-
- return new DiagnosticResult
- {
- Locations = new[] { location },
- Id = rule.Id,
- Severity = rule.DefaultSeverity,
- Message = string.Format(rule.MessageFormat.ToString(), messageArguments)
- };
+ return new DiagnosticResult(rule).WithLocation(path, line, column).WithArguments(messageArguments);
}
- private static DiagnosticResultLocation[] ParseResultLocations(string defaultPath, string[] locationStrings)
+ private static (string path, LinePosition location)[] ParseResultLocations(string defaultPath, string[] locationStrings)
{
- var builder = new List();
+ var builder = new List<(string path, LinePosition location)>();
foreach (string str in locationStrings)
{
@@ -217,7 +192,7 @@ private static DiagnosticResultLocation[] ParseResultLocations(string defaultPat
Assert.True(int.TryParse(tokens[2], out int column) && line >= -1, "Column must be >= -1 in location string: " + str);
- builder.Add(new DiagnosticResultLocation(path, line, column));
+ builder.Add((path, new LinePosition(line, column)));
}
return builder.ToArray();
@@ -333,21 +308,24 @@ protected void VerifyBasic(string source, FileAndSource additionalText, params D
protected void Verify(string source, string language, DiagnosticAnalyzer analyzer, IEnumerable additionalFiles, CompilationOptions compilationOptions, ParseOptions parseOptions, params DiagnosticResult[] expected)
{
var diagnostics = GetSortedDiagnostics(new[] { source }.ToFileAndSource(), language, analyzer, compilationOptions, parseOptions, additionalFiles: additionalFiles);
- diagnostics.Verify(analyzer, PrintActualDiagnosticsOnFailure, ExpectedDiagnosticsAssertionTemplate, expected);
+ diagnostics.Verify(analyzer, PrintActualDiagnosticsOnFailure, ExpectedDiagnosticsAssertionTemplate, GetDefaultPath(language), expected);
}
private void Verify(string source, string language, DiagnosticAnalyzer analyzer, ReferenceFlags referenceFlags, TestValidationMode validationMode, CompilationOptions compilationOptions, ParseOptions parseOptions, params DiagnosticResult[] expected)
{
var diagnostics = GetSortedDiagnostics(new[] { source }.ToFileAndSource(), language, analyzer, compilationOptions, parseOptions, referenceFlags: referenceFlags, validationMode: validationMode);
- diagnostics.Verify(analyzer, PrintActualDiagnosticsOnFailure, ExpectedDiagnosticsAssertionTemplate, expected);
+ diagnostics.Verify(analyzer, PrintActualDiagnosticsOnFailure, ExpectedDiagnosticsAssertionTemplate, GetDefaultPath(language), expected);
}
private void Verify(FileAndSource[] sources, string language, DiagnosticAnalyzer analyzer, TestValidationMode validationMode, bool allowUnsafeCode, ReferenceFlags referenceFlags, CompilationOptions compilationOptions, ParseOptions parseOptions, params DiagnosticResult[] expected)
{
var diagnostics = GetSortedDiagnostics(sources, language, analyzer, compilationOptions, parseOptions, validationMode, referenceFlags: referenceFlags, allowUnsafeCode: allowUnsafeCode);
- diagnostics.Verify(analyzer, PrintActualDiagnosticsOnFailure, ExpectedDiagnosticsAssertionTemplate, expected);
+ diagnostics.Verify(analyzer, PrintActualDiagnosticsOnFailure, ExpectedDiagnosticsAssertionTemplate, GetDefaultPath(language), expected);
}
+ protected static string GetDefaultPath(string language) =>
+ language == LanguageNames.CSharp ? CSharpDefaultFilePath : VisualBasicDefaultFilePath;
+
protected IEnumerable GetAdditionalTextFiles(string fileName, string text) =>
ImmutableArray.Create(GetAdditionalTextFile(fileName, text));
diff --git a/src/Test.Utilities/DiagnosticAnalyzerTests.Extensions.cs b/src/Test.Utilities/DiagnosticAnalyzerTests.Extensions.cs
index 630e46e8b6..b66c4eb984 100644
--- a/src/Test.Utilities/DiagnosticAnalyzerTests.Extensions.cs
+++ b/src/Test.Utilities/DiagnosticAnalyzerTests.Extensions.cs
@@ -7,6 +7,7 @@
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Testing;
using Xunit;
namespace Test.Utilities
@@ -18,6 +19,7 @@ public static void Verify(
DiagnosticAnalyzer analyzer,
bool printActualDiagnosticsOnFailure,
string expectedDiagnosticsAssertionTemplate,
+ string defaultPath,
params DiagnosticResult[] expectedResults)
{
if (analyzer != null && analyzer.SupportedDiagnostics.Length == 0)
@@ -43,9 +45,9 @@ public static void Verify(
for (int i = 0; i < expectedResults.Length; i++)
{
Diagnostic actual = actualResults.ElementAt(i);
- DiagnosticResult expected = expectedResults[i];
+ DiagnosticResult expected = expectedResults[i].WithDefaultPath(defaultPath);
- if (expected.Line == -1 && expected.Column == -1)
+ if (!expected.HasLocation)
{
if (actual.Location != Location.None)
{
@@ -59,14 +61,14 @@ public static void Verify(
}
else
{
- VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First());
+ VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Spans[0]);
Location[] additionalLocations = actual.AdditionalLocations.ToArray();
- if (additionalLocations.Length != expected.Locations.Length - 1)
+ if (additionalLocations.Length != expected.Spans.Length - 1)
{
AssertFalse(
string.Format("Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n",
- expected.Locations.Length - 1, additionalLocations.Length,
+ expected.Spans.Length - 1, additionalLocations.Length,
FormatDiagnostics(analyzer, actual)),
printActualDiagnosticsOnFailure,
expectedDiagnosticsAssertionTemplate,
@@ -75,7 +77,7 @@ public static void Verify(
for (int j = 0; j < additionalLocations.Length; ++j)
{
- VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]);
+ VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Spans[j + 1]);
}
}
@@ -111,9 +113,14 @@ public static void Verify(
}
}
- public static void Verify(this IEnumerable actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults)
+ public static void Verify(this IEnumerable actualResults, DiagnosticAnalyzer analyzer)
{
- Verify(actualResults, analyzer, false, null, expectedResults);
+ Verify(actualResults, analyzer, false, null, "ignoredPath", Array.Empty());
+ }
+
+ public static void Verify(this IEnumerable actualResults, DiagnosticAnalyzer analyzer, string defaultPath, params DiagnosticResult[] expectedResults)
+ {
+ Verify(actualResults, analyzer, false, null, defaultPath, expectedResults);
}
private static void AssertFalse(
@@ -151,7 +158,7 @@ public static void Print(this IEnumerable actualResults, string expe
}
}
- private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, DiagnosticResultLocation expected)
+ private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, FileLinePositionSpan expected)
{
FileLinePositionSpan actualSpan = actual.GetLineSpan();
@@ -162,24 +169,24 @@ private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagno
Microsoft.CodeAnalysis.Text.LinePosition actualLinePosition = actualSpan.StartLinePosition;
// Only check line position if there is an actual line in the real diagnostic
- if (actualLinePosition.Line > 0)
+ if (expected.StartLinePosition.Line > 0)
{
- if (actualLinePosition.Line + 1 != expected.Line)
+ if (actualLinePosition.Line + 1 != expected.StartLinePosition.Line)
{
Assert.True(false,
string.Format("Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
- expected.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzer, diagnostic)));
+ expected.StartLinePosition.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzer, diagnostic)));
}
}
// Only check column position if there is an actual column position in the real diagnostic
- if (actualLinePosition.Character > 0)
+ if (expected.StartLinePosition.Character > 0)
{
- if (actualLinePosition.Character + 1 != expected.Column)
+ if (actualLinePosition.Character + 1 != expected.StartLinePosition.Character)
{
Assert.True(false,
string.Format("Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
- expected.Column, actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic)));
+ expected.StartLinePosition.Character, actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic)));
}
}
}
diff --git a/src/Test.Utilities/DiagnosticResult.cs b/src/Test.Utilities/DiagnosticResult.cs
deleted file mode 100644
index 789a2b802a..0000000000
--- a/src/Test.Utilities/DiagnosticResult.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-// 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.Linq;
-using Microsoft.CodeAnalysis;
-using Roslyn.Utilities;
-using Xunit;
-
-namespace Test.Utilities
-{
- public struct DiagnosticResultLocation : IEquatable
- {
- public DiagnosticResultLocation(string path, int line, int column)
- {
- Assert.True(line >= 0 || column >= 0, "At least one of line and column must be > 0");
- Assert.True(line >= -1 && column >= -1, "Both line and column must be >= -1");
-
- this.Path = path;
- this.Line = line;
- this.Column = column;
- }
-
- public string Path { get; private set; }
- public int Line { get; private set; }
- public int Column { get; private set; }
-
- public override bool Equals(object obj)
- {
- return this.Equals((DiagnosticResultLocation)obj);
- }
-
- public override int GetHashCode()
- {
- return Hash.CombineValues(new[] { this.Path.GetHashCode(), this.Line, this.Column });
- }
-
- public bool Equals(DiagnosticResultLocation other)
- {
- return this.Path.Equals(other.Path, System.StringComparison.OrdinalIgnoreCase) &&
- this.Line == other.Line &&
- this.Column == other.Column;
- }
-
- public static bool operator ==(DiagnosticResultLocation left, DiagnosticResultLocation right)
- {
- return left.Equals(right);
- }
-
- public static bool operator !=(DiagnosticResultLocation left, DiagnosticResultLocation right)
- {
- return !left.Equals(right);
- }
- }
-
- public struct DiagnosticResult : IEquatable
- {
- private DiagnosticResultLocation[] _locations;
-
-#pragma warning disable CA1819 // Properties should not return arrays
- public DiagnosticResultLocation[] Locations
-#pragma warning restore CA1819 // Properties should not return arrays
- {
- get
- {
- if (_locations == null)
- {
- _locations = Array.Empty();
- }
-
- return _locations;
- }
-
- set
- {
- _locations = value;
- }
- }
-
- public DiagnosticSeverity Severity { get; set; }
-
- public string Id { get; set; }
-
- public string Message { get; set; }
-
- public string Path => this.Locations.Length > 0 ? this.Locations[0].Path : "";
-
- public int Line => this.Locations.Length > 0 ? this.Locations[0].Line : -1;
-
- public int Column => this.Locations.Length > 0 ? this.Locations[0].Column : -1;
-
- private string GetSeverityString(DiagnosticSeverity severity)
- {
- switch (severity)
- {
- case DiagnosticSeverity.Hidden:
- return "Hidden";
- case DiagnosticSeverity.Info:
- return "Info";
- case DiagnosticSeverity.Warning:
- return "Warning";
- case DiagnosticSeverity.Error:
- return "Error";
- default:
- return "";
- }
- }
-
- public override string ToString()
- {
- return $"{System.IO.Path.GetFileName(Path)}({Line},{Column}): {GetSeverityString(Severity)} {Id}: {Message}";
- }
-
- public override bool Equals(object obj)
- {
- return this.Equals((DiagnosticResult)obj);
- }
-
- public override int GetHashCode()
- {
- return Hash.Combine(this.Locations.Length,
- Hash.CombineValues(this.Locations.Select(l => l.GetHashCode())));
- }
-
- public bool Equals(DiagnosticResult other)
- {
- return this.Locations.Length == other.Locations.Length &&
- this.Locations.SetEquals(other.Locations);
- }
-
- public static bool operator ==(DiagnosticResult left, DiagnosticResult right)
- {
- return left.Equals(right);
- }
-
- public static bool operator !=(DiagnosticResult left, DiagnosticResult right)
- {
- return right.Equals(left);
- }
- }
-}
diff --git a/src/Test.Utilities/Test.Utilities.csproj b/src/Test.Utilities/Test.Utilities.csproj
index 4e03b95d5e..36f0bc4d8c 100644
--- a/src/Test.Utilities/Test.Utilities.csproj
+++ b/src/Test.Utilities/Test.Utilities.csproj
@@ -14,6 +14,8 @@
+
+
diff --git a/src/Test.Utilities/Traits.cs b/src/Test.Utilities/Traits.cs
index 4d6835daa2..ec87ed892d 100644
--- a/src/Test.Utilities/Traits.cs
+++ b/src/Test.Utilities/Traits.cs
@@ -6,7 +6,9 @@ public static class Traits
{
public const string DataflowAnalysis = nameof(DataflowAnalysis);
#pragma warning disable CA1034 // Nested types should not be visible - test class matching the pattern used in Roslyn.
+#pragma warning disable CA1724 // Type names should not match namespaces
public static class Dataflow
+#pragma warning restore CA1724 // Type names should not match namespaces
#pragma warning restore CA1034 // Nested types should not be visible
{
public const string CopyAnalysis = nameof(CopyAnalysis);