diff --git a/Directory.Build.targets b/Directory.Build.targets
index 8a25326bc4..34e0b79669 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -50,7 +50,21 @@
-
+
+
+
+
+
+
+
+
+
-
+
1.0.1-beta1.20214.2
1.3.1
+ 4.7.0
+ 4.7.0
1.4.2
10.1.0
1.1.2
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/Microsoft.CodeAnalysis.Analyzers.UnitTests.csproj b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/Microsoft.CodeAnalysis.Analyzers.UnitTests.csproj
index 1e5bce18bb..77910b02d3 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/Microsoft.CodeAnalysis.Analyzers.UnitTests.csproj
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/Microsoft.CodeAnalysis.Analyzers.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
diff --git a/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.BannedApiAnalyzers.UnitTests.csproj b/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.BannedApiAnalyzers.UnitTests.csproj
index 15ddb242c4..00d254c02a 100644
--- a/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.BannedApiAnalyzers.UnitTests.csproj
+++ b/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.BannedApiAnalyzers.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.csproj b/src/NetAnalyzers/UnitTests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.csproj
index fb11cf2b0f..40d7d50029 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.csproj
+++ b/src/NetAnalyzers/UnitTests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.csproj
@@ -1,8 +1,9 @@
- net472
+ netcoreapp3.1;net472
$(DefineConstants),NET_ANALYZERS_TEST
+ true
@@ -16,7 +17,7 @@
-
+
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethodsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethodsTests.cs
index e0a836af82..b3bf56e490 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethodsTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethodsTests.cs
@@ -3669,7 +3669,6 @@ await VerifyCS.VerifyAnalyzerAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -3916,6 +3915,7 @@ public async Task Issue1891()
{
await new VerifyCS.Test
{
+ ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithSystemWeb,
TestState =
{
Sources =
@@ -4083,7 +4083,6 @@ protected virtual bool HasUrl(IContext filterContext)
}
}"
},
- AdditionalReferences = { AdditionalMetadataReferences.SystemWeb }
},
ExpectedDiagnostics =
{
@@ -5422,6 +5421,7 @@ public async Task Issue1943()
{
await new VerifyCS.Test
{
+ ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithSystemWeb,
TestState =
{
Sources =
@@ -5487,7 +5487,6 @@ public void M(HttpContext httpContext, TextWriter Output, int id, int count, int
}
"
},
- AdditionalReferences = { AdditionalMetadataReferences.SystemWeb }
}
}.RunAsync();
}
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkAllNonSerializableFieldsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkAllNonSerializableFieldsTests.cs
index ca3852b36f..a32039f0d3 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkAllNonSerializableFieldsTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkAllNonSerializableFieldsTests.cs
@@ -379,7 +379,10 @@ Friend Property s2 As NonSerializableType
[Fact]
public async Task CA2235WithArrayType()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System;
public class NonSerializableType { }
@@ -392,10 +395,17 @@ internal class CA2235WithNonSerializableArray
public SerializableType[] s1;
internal NonSerializableType[] s2;
}",
- // Test0.cs(12,52): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType[] which is not serializable
- GetCA2235CSharpResultAt(12, 52, "s2", "CA2235WithNonSerializableArray", "NonSerializableType[]"));
-
- await VerifyVB.VerifyAnalyzerAsync(@"
+ ExpectedDiagnostics =
+ {
+ // Test0.cs(12,52): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType[] which is not serializable
+ GetCA2235CSharpResultAt(12, 52, "s2", "CA2235WithNonSerializableArray", "NonSerializableType[]"),
+ },
+ }.RunAsync();
+
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System
Public Class NonSerializableType
End Class
@@ -408,8 +418,12 @@ Friend Class CA2235WithNonSerializableArray
Public s1 As SerializableType()
Friend Property s2 As NonSerializableType()
End Class",
- // Test0.vb(12,37): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType() which is not serializable
- GetCA2235BasicResultAt(12, 37, "s2", "CA2235WithNonSerializableArray", "NonSerializableType()"));
+ ExpectedDiagnostics =
+ {
+ // Test0.vb(12,37): warning CA2235: Field s2 is a member of type CA2235WithNonSerializableArray which is serializable but is of type NonSerializableType() which is not serializable
+ GetCA2235BasicResultAt(12, 37, "s2", "CA2235WithNonSerializableArray", "NonSerializableType()"),
+ },
+ }.RunAsync();
}
[Fact]
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs
index 9225b617c6..9ea183884f 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethodsTests.cs
@@ -162,7 +162,10 @@ void Method()
public async Task CA2241CSharpVarArgsNotSupported()
{
// currently not supported due to "https://github.com/dotnet/roslyn/issues/7346"
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System;
public class C
@@ -173,7 +176,8 @@ void Method()
Console.WriteLine(""{0} {1} {2} {3} {4}"", 1, 2, 3, 4, __arglist(5));
}
}
-");
+",
+ }.RunAsync();
}
[Fact]
@@ -232,6 +236,9 @@ End Class
GetBasicResultAt(6, 9),
GetBasicResultAt(7, 9),
GetBasicResultAt(8, 9),
+#if NETCOREAPP
+ GetBasicResultAt(9, 9),
+#endif
GetBasicResultAt(10, 9));
}
@@ -259,6 +266,9 @@ End Class
GetBasicResultAt(6, 9),
GetBasicResultAt(7, 9),
GetBasicResultAt(8, 9),
+#if NETCOREAPP
+ GetBasicResultAt(9, 9),
+#endif
GetBasicResultAt(10, 9));
}
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SpecifyIFormatProviderTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SpecifyIFormatProviderTests.cs
index 3f935b53f3..92f516d95a 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SpecifyIFormatProviderTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SpecifyIFormatProviderTests.cs
@@ -800,7 +800,10 @@ End Sub
[Fact]
public async Task CA1305_NonStringReturningComputerInfoInstalledUICultureIFormatProvider_VisualBasic()
{
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System
Imports System.Globalization
Imports System.Threading
@@ -821,9 +824,13 @@ End Sub
Public Shared Sub IFormatProviderReturningNonString(format As String, provider As IFormatProvider)
End Sub
End Class",
-GetIFormatProviderUICultureRuleBasicResultAt(12, 9, "UICultureAsIFormatProviderReturningNonStringTest.TestMethod()",
+ ExpectedDiagnostics =
+ {
+ GetIFormatProviderUICultureRuleBasicResultAt(12, 9, "UICultureAsIFormatProviderReturningNonStringTest.TestMethod()",
"ComputerInfo.InstalledUICulture",
- "IFormatProviderOverloads.IFormatProviderReturningNonString(String, IFormatProvider)"));
+ "IFormatProviderOverloads.IFormatProviderReturningNonString(String, IFormatProvider)"),
+ },
+ }.RunAsync();
}
[Fact]
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithmsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithmsTests.cs
index b31776c579..6ac063d7a4 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithmsTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithmsTests.cs
@@ -1965,7 +1965,10 @@ End Namespace
[Fact]
public async Task CA5350RIPEMD160ManagedInMethodDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
@@ -1978,9 +1981,16 @@ private static void TestMethod()
}
}
}",
- GetCSharpResultAt(10, 25, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(10, 25, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Module TestClass
@@ -1988,13 +1998,20 @@ Sub TestMethod()
Dim md1601alg As New RIPEMD160Managed
End Sub
End Module",
- GetBasicResultAt(6, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(6, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350RIPEMD160ManagedInGetDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2006,9 +2023,16 @@ public RIPEMD160Managed GetRIPEMD160
}
}
}",
- GetCSharpResultAt(9, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(9, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass1
@@ -2019,13 +2043,20 @@ End Get
End Property
End Class
End Namespace",
- GetBasicResultAt(7, 12, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(7, 12, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350RIPEMD160ManagedInFieldDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2034,9 +2065,16 @@ class TestClass
RIPEMD160Managed privateRIPEMD160 = new RIPEMD160Managed();
}
}",
- GetCSharpResultAt(7, 45, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(7, 45, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass
@@ -2044,13 +2082,20 @@ Private privateRIPEMD160 As New RIPEMD160Managed()
End Class
End Namespace
",
- GetBasicResultAt(5, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(5, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
}
//No VB
[Fact]
public async Task CA5350RIPEMD160ManagedInLambdaExpression()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace TestNamespace
@@ -2063,13 +2108,20 @@ private async Task TestMethod()
}
}
}",
- GetCSharpResultAt(10, 36, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(10, 36, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"),
+ },
+ }.RunAsync();
}
//No VB
[Fact]
public async Task CA5350RIPEMD160ManagedInAnonymousMethodExpression()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2079,13 +2131,20 @@ class TestClass
Del d = delegate () { new RIPEMD160Managed(); };
}
}",
- GetCSharpResultAt(8, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(8, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "RIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350RIPEMD160CreateInMethodDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
@@ -2098,9 +2157,16 @@ private static void TestMethod()
}
}
}",
- GetCSharpResultAt(10, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(10, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass
@@ -2109,13 +2175,20 @@ Private Shared Sub TestMethod()
End Sub
End Class
End Namespace",
- GetBasicResultAt(6, 29, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(6, 29, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350RIPEMD160CreateInGetDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2127,9 +2200,16 @@ public RIPEMD160 GetRIPEMD160
}
}
}",
- GetCSharpResultAt(9, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(9, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass1
@@ -2140,13 +2220,20 @@ End Get
End Property
End Class
End Namespace",
- GetBasicResultAt(7, 12, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(7, 12, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350RIPEMD160CreateInFieldDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2155,22 +2242,36 @@ class TestClass
RIPEMD160 privateRIPEMD160 = RIPEMD160.Create();
}
}",
- GetCSharpResultAt(7, 38, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(7, 38, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass
Private privateRIPEMD160 As RIPEMD160 = RIPEMD160.Create()
End Class
End Namespace",
- GetBasicResultAt(5, 43, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(5, 43, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateRIPEMD160", "RIPEMD160"),
+ },
+ }.RunAsync();
}
//No VB
[Fact]
public async Task CA5350RIPEMD160CreateInLambdaExpression()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace TestNamespace
@@ -2183,13 +2284,20 @@ private async Task TestMethod()
}
}
}",
- GetCSharpResultAt(10, 36, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(10, 36, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "RIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350RIPEMD160CreateInAnonymousMethodExpression()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2199,9 +2307,16 @@ class TestClass
Del d = delegate () { RIPEMD160.Create(); };
}
}",
- GetCSharpResultAt(8, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(8, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "RIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass
@@ -2209,13 +2324,20 @@ Private Delegate Sub Del()
Private d As Del = Sub() RIPEMD160.Create()
End Class
End Namespace",
- GetBasicResultAt(6, 34, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "RIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(6, 34, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "RIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350HMACRIPEMD160InMethodDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
@@ -2228,9 +2350,16 @@ private static void TestMethod()
}
}
}",
- GetCSharpResultAt(10, 25, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(10, 25, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass
@@ -2239,13 +2368,20 @@ Private Shared Sub TestMethod()
End Sub
End Class
End Namespace",
- GetBasicResultAt(6, 16, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(6, 16, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350HMACRIPEMD160InGetDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2257,9 +2393,16 @@ public HMACRIPEMD160 GetHMARIPEMD160
}
}
}",
- GetCSharpResultAt(9, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetHMARIPEMD160", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(9, 26, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetHMARIPEMD160", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass1
@@ -2270,13 +2413,20 @@ End Get
End Property
End Class
End Namespace",
- GetBasicResultAt(7, 12, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetHMARIPEMD160", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(7, 12, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "get_GetHMARIPEMD160", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task CA5350HMACRIPEMD160InFieldDeclaration()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2285,22 +2435,36 @@ class TestClass
HMACRIPEMD160 privateHMARIPEMD160 = new HMACRIPEMD160();
}
}",
- GetCSharpResultAt(7, 45, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateHMARIPEMD160", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(7, 45, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateHMARIPEMD160", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class TestClass
Private privateHMARIPEMD160 As New HMACRIPEMD160()
End Class
End Namespace",
- GetBasicResultAt(5, 34, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateHMARIPEMD160", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(5, 34, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "privateHMARIPEMD160", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
}
//No VB
[Fact]
public async Task CA5350HMACRIPEMD160InLambdaExpression()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace TestNamespace
@@ -2313,13 +2477,20 @@ private async Task TestMethod()
}
}
}",
- GetCSharpResultAt(10, 36, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(10, 36, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
}
//No VB
[Fact]
public async Task CA5350HMACRIPEMD160InAnonymousMethodExpression()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
{
@@ -2329,7 +2500,11 @@ class TestClass
Del d = delegate () { new HMACRIPEMD160(); };
}
}",
- GetCSharpResultAt(8, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(8, 31, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "d", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
@@ -2337,6 +2512,7 @@ public async Task CA5350CreateObjectFromRIPEMD160DerivedClass()
{
await new VerifyCS.Test
{
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestState =
{
Sources =
@@ -2390,6 +2566,7 @@ protected override byte[] HashFinal()
await new VerifyVB.Test
{
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestState =
{
Sources =
@@ -2439,6 +2616,7 @@ public async Task CA5350CreateObjectFromRIPEMD160ManagedDerivedClass()
{
await new VerifyCS.Test
{
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestState =
{
Sources =
@@ -2492,6 +2670,7 @@ protected override byte[] HashFinal()
await new VerifyVB.Test
{
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestState =
{
Sources =
@@ -2539,7 +2718,10 @@ End Namespace
[Fact]
public async Task CA5350CreateObjectFromHMACRIPEMD160DerivedClass()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.Security.Cryptography;
namespace TestNamespace
@@ -2554,9 +2736,16 @@ private static void TestMethod()
}
}
}",
- GetCSharpResultAt(12, 25, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(12, 25, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
Imports System.Security.Cryptography
Namespace TestNamespace
Class MyHMACRIPEMD160
@@ -2569,7 +2758,11 @@ Private Shared Sub TestMethod()
End Sub
End Class
End Namespace",
- GetBasicResultAt(10, 16, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"));
+ ExpectedDiagnostics =
+ {
+ GetBasicResultAt(10, 16, DoNotUseInsecureCryptographicAlgorithmsAnalyzer.DoNotUseWeakCryptographyRule, "TestMethod", "HMACRIPEMD160"),
+ },
+ }.RunAsync();
}
[Fact]
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterMethodsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterMethodsTests.cs
index 4453a4336d..8794004f3c 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterMethodsTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterMethodsTests.cs
@@ -14,7 +14,10 @@ public class DoNotUseInsecureDeserializerBinaryFormatterMethodsTests
[Fact]
public async Task UnsafeDeserialize_Diagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
@@ -29,13 +32,20 @@ public object BfUnsafeDeserialize(byte[] bytes)
}
}
}",
- GetCSharpResultAt(12, 20, "object BinaryFormatter.UnsafeDeserialize(Stream serializationStream, HeaderHandler handler)"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(12, 20, "object BinaryFormatter.UnsafeDeserialize(Stream serializationStream, HeaderHandler handler)"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task UnsafeDeserializeMethodResponse_Diagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
@@ -50,7 +60,11 @@ public object BfUnsafeDeserialize(byte[] bytes)
}
}
}",
- GetCSharpResultAt(12, 20, "object BinaryFormatter.UnsafeDeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(12, 20, "object BinaryFormatter.UnsafeDeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)"),
+ },
+ }.RunAsync();
}
[Fact]
@@ -77,7 +91,10 @@ public object D(byte[] bytes)
[Fact]
public async Task Deserialize_HeaderHandler_Diagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
@@ -92,13 +109,20 @@ public object D(byte[] bytes)
}
}
}",
- GetCSharpResultAt(12, 20, "object BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(12, 20, "object BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)"),
+ },
+ }.RunAsync();
}
[Fact]
public async Task DeserializeMethodResponse_Diagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
@@ -113,7 +137,11 @@ public object D(byte[] bytes)
}
}
}",
- GetCSharpResultAt(12, 20, "object BinaryFormatter.DeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(12, 20, "object BinaryFormatter.DeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)"),
+ },
+ }.RunAsync();
}
[Fact]
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterWithoutBinderTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterWithoutBinderTests.cs
index 94dfc24dfc..6bf317607b 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterWithoutBinderTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterWithoutBinderTests.cs
@@ -49,6 +49,7 @@ public object Deserialize(byte[] bytes)
var csharpTest = new VerifyCS.Test
{
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
TestState =
{
Sources = { source, myBinderCSharpSourceCode }
@@ -918,7 +919,10 @@ public object DeserializeWithDelegate(byte[] bytes)
[Fact]
public async Task Deserialize_BranchInvokedAsDelegate_Diagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = @"
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
@@ -942,8 +946,12 @@ public object DeserializeWithDelegate(byte[] bytes)
}
}
}",
- GetCSharpResultAt(21, 20, BinderNotSetRule, "object BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)"),
- GetCSharpResultAt(21, 20, BinderNotSetRule, "object BinaryFormatter.UnsafeDeserialize(Stream serializationStream, HeaderHandler handler)"));
+ ExpectedDiagnostics =
+ {
+ GetCSharpResultAt(21, 20, BinderNotSetRule, "object BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)"),
+ GetCSharpResultAt(21, 20, BinderNotSetRule, "object BinaryFormatter.UnsafeDeserialize(Stream serializationStream, HeaderHandler handler)"),
+ },
+ }.RunAsync();
}
[Fact]
@@ -1104,7 +1112,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -1132,7 +1139,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -1157,7 +1163,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -1186,7 +1191,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -1270,7 +1274,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -1327,7 +1330,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -1447,7 +1449,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
@@ -1473,7 +1474,6 @@ await VerifyCSharpWithMyBinderDefinedAsync(@"
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting.Messaging;
namespace Blah
{
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinderTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinderTests.cs
index 3b4de89aec..76a85c52dc 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinderTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinderTests.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 System;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
@@ -22,10 +23,11 @@ public class DoNotUseInsecureDeserializerJsonNetWithoutBinderTests
private static readonly DiagnosticDescriptor MaybeRule =
DoNotUseInsecureDeserializerJsonNetWithoutBinder.MaybeInsecureSerializer;
- [Fact]
- public async Task DocSample1_CSharp_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_CSharp_Violation(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
public class BookRecord
@@ -64,10 +66,11 @@ public BookRecord DeserializeBookRecord(JsonReader reader)
GetCSharpResultAt(33, 16, DefinitelyRule));
}
- [Fact]
- public async Task DocSample1_VB_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_VB_Violation(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports Newtonsoft.Json
Public Class BookRecord
@@ -104,10 +107,11 @@ End Class
GetBasicResultAt(31, 16, DefinitelyRule));
}
- [Fact]
- public async Task DocSample1_CSharp_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_CSharp_Solution(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -170,10 +174,11 @@ public BookRecord DeserializeBookRecord(JsonReader reader)
");
}
- [Fact]
- public async Task DocSample1_VB_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_VB_Solution(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports System
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Serialization
@@ -232,10 +237,11 @@ End Class
");
}
- [Fact]
- public async Task DocSample2_CSharp_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_CSharp_Violation(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -304,10 +310,11 @@ public BookRecord DeserializeBookRecord(JsonReader reader)
GetCSharpResultAt(63, 16, MaybeRule));
}
- [Fact]
- public async Task DocSample2_VB_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_VB_Violation(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports System
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Serialization
@@ -371,10 +378,11 @@ End Class
GetBasicResultAt(58, 16, MaybeRule));
}
- [Fact]
- public async Task DocSample2_CSharp_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_CSharp_Solution(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -445,10 +453,11 @@ public BookRecord DeserializeBookRecord(JsonReader reader)
");
}
- [Fact]
- public async Task DocSample2_VB_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_VB_Solution(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports System
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Serialization
@@ -514,10 +523,11 @@ End Class
");
}
- [Fact]
- public async Task Insecure_JsonSerializer_Deserialize_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonSerializer_Deserialize_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -532,10 +542,11 @@ object Method(JsonReader jr)
GetCSharpResultAt(10, 16, DefinitelyRule));
}
- [Fact]
- public async Task ExplicitlyNone_JsonSerializer_Deserialize_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task ExplicitlyNone_JsonSerializer_Deserialize_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -549,10 +560,11 @@ object Method(JsonReader jr)
}");
}
- [Fact]
- public async Task AllAndBinder_JsonSerializer_Deserialize_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task AllAndBinder_JsonSerializer_Deserialize_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -579,10 +591,11 @@ object Method(JsonReader jr)
}");
}
- [Fact]
- public async Task InitializeField_JsonSerializer_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task InitializeField_JsonSerializer_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -598,10 +611,11 @@ void Init()
GetCSharpResultAt(10, 9, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_JsonSerializer_Populate_MaybeDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonSerializer_Populate_MaybeDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -623,10 +637,11 @@ object Method(JsonReader jr)
GetCSharpResultAt(16, 9, MaybeRule));
}
- [Fact]
- public async Task Insecure_JsonSerializer_DeserializeGeneric_MaybeDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonSerializer_DeserializeGeneric_MaybeDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -647,10 +662,11 @@ T Method(JsonReader jr)
}
// Ideally, we'd transfer the JsonSerializerSettings' TypeNameHandling's state to the JsonSerializer's TypeNameHandling's state.
- [Fact]
- public async Task Insecure_JsonSerializer_FromInsecureSettings_DeserializeGeneric_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonSerializer_FromInsecureSettings_DeserializeGeneric_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -671,35 +687,44 @@ T Method(JsonReader jr)
}");
}
- [Fact]
- public async Task TypeNameHandlingNoneBinderNonNull_JsonSerializer_Populate_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task TypeNameHandlingNoneBinderNonNull_JsonSerializer_Populate_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ string serializationNamespace = "using System.Runtime.Serialization;";
+#if NETCOREAPP
+ if (version < NewtonsoftJsonVersion.Version12)
+ {
+ serializationNamespace = "";
+ }
+#endif
+
+ await VerifyCSharpWithJsonNetAsync(version, $@"
using System;
-using System.Runtime.Serialization;
+{serializationNamespace}
using Newtonsoft.Json;
class Blah
-{
+{{
private Func SbGetter;
object Method(JsonReader jr)
- {
+ {{
SerializationBinder sb = SbGetter();
if (sb != null)
- {
+ {{
JsonSerializer serializer = new JsonSerializer();
serializer.Binder = sb;
object o = new object();
serializer.Populate(jr, o);
return o;
- }
+ }}
else
- {
+ {{
return null;
- }
- }
-}");
+ }}
+ }}
+}}");
}
[Theory]
@@ -712,7 +737,7 @@ public async Task EditorConfigConfiguration_ExcludedSymbolNamesWithValueOption(s
{
var csharpTest = new VerifyCS.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
TestState =
{
Sources =
@@ -744,11 +769,16 @@ object Method(JsonReader jr)
await csharpTest.RunAsync();
}
- private async Task VerifyCSharpWithJsonNetAsync(string source, params DiagnosticResult[] expected)
+ private async Task VerifyCSharpWithJsonNetAsync(NewtonsoftJsonVersion version, string source, params DiagnosticResult[] expected)
{
var csharpTest = new VerifyCS.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = version switch
+ {
+ NewtonsoftJsonVersion.Version10 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson10,
+ NewtonsoftJsonVersion.Version12 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
+ _ => throw new NotSupportedException(),
+ },
TestState =
{
Sources = { source },
@@ -760,11 +790,16 @@ private async Task VerifyCSharpWithJsonNetAsync(string source, params Diagnostic
await csharpTest.RunAsync();
}
- private async Task VerifyBasicWithJsonNetAsync(string source, params DiagnosticResult[] expected)
+ private async Task VerifyBasicWithJsonNetAsync(NewtonsoftJsonVersion version, string source, params DiagnosticResult[] expected)
{
var vbTest = new VerifyVB.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = version switch
+ {
+ NewtonsoftJsonVersion.Version10 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson10,
+ NewtonsoftJsonVersion.Version12 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
+ _ => throw new NotSupportedException(),
+ },
TestState =
{
Sources = { source },
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNetTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNetTests.cs
index 5c0029e061..ecff1810f9 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNetTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNetTests.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 System;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
@@ -20,10 +21,11 @@ public class DoNotUseInsecureSettingsForJsonNetTests
private static readonly DiagnosticDescriptor DefinitelyRule = DoNotUseInsecureSettingsForJsonNet.DefinitelyInsecureSettings;
private static readonly DiagnosticDescriptor MaybeRule = DoNotUseInsecureSettingsForJsonNet.MaybeInsecureSettings;
- [Fact]
- public async Task DocSample1_CSharp_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_CSharp_Violation(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
public class BookRecord
@@ -63,10 +65,11 @@ public BookRecord DeserializeBookRecord(string s)
GetCSharpResultAt(34, 16, DefinitelyRule));
}
- [Fact]
- public async Task DocSample1_VB_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_VB_Violation(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports Newtonsoft.Json
Public Class BookRecord
@@ -103,10 +106,11 @@ End Class
GetBasicResultAt(31, 16, DefinitelyRule));
}
- [Fact]
- public async Task DocSample1_CSharp_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_CSharp_Solution(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -169,10 +173,11 @@ public BookRecord DeserializeBookRecord(string s)
");
}
- [Fact]
- public async Task DocSample1_VB_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_VB_Solution(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports System
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Serialization
@@ -231,10 +236,11 @@ End Class
");
}
- [Fact]
- public async Task DocSample2_CSharp_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_CSharp_Violation(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -303,10 +309,11 @@ public BookRecord DeserializeBookRecord(string s)
GetCSharpResultAt(63, 16, MaybeRule));
}
- [Fact]
- public async Task DocSample2_VB_Violation()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_VB_Violation(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports System
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Serialization
@@ -370,10 +377,11 @@ End Class
GetBasicResultAt(58, 16, MaybeRule));
}
- [Fact]
- public async Task DocSample2_CSharp_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_CSharp_Solution(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -444,10 +452,11 @@ public BookRecord DeserializeBookRecord(string s)
");
}
- [Fact]
- public async Task DocSample2_VB_Solution()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample2_VB_Solution(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports System
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Serialization
@@ -513,10 +522,11 @@ End Class
");
}
- [Fact]
- public async Task Field_Interprocedural_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Field_Interprocedural_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -562,10 +572,11 @@ private static ISerializationBinder GetSerializationBinder()
");
}
- [Fact]
- public async Task Secure_SometimesInitialization_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Secure_SometimesInitialization_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -583,10 +594,11 @@ public void EnsureInitialized()
");
}
- [Fact]
- public async Task Insecure_JsonConvert_DeserializeObject_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DeserializeObject_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -601,10 +613,11 @@ object Method(string s)
GetCSharpResultAt(10, 16, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_JsonConvert_DeserializeAnonymousType_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DeserializeAnonymousType_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -619,10 +632,11 @@ T Method(string s, T t)
GetCSharpResultAt(10, 16, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_JsonSerializer_Create_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonSerializer_Create_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System.IO;
using Newtonsoft.Json;
@@ -639,10 +653,11 @@ T Deserialize(string s)
GetCSharpResultAt(11, 37, DefinitelyRule));
}
- [Fact]
- public async Task Secure_JsonSerializer_CreateDefault_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Secure_JsonSerializer_CreateDefault_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System.IO;
using Newtonsoft.Json;
@@ -657,10 +672,11 @@ T Deserialize(string s)
}");
}
- [Fact]
- public async Task Insecure_JsonConvert_DefaultSettings_Lambda_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DefaultSettings_Lambda_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -678,10 +694,11 @@ void Method()
GetCSharpResultAt(12, 20, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_JsonConvert_DefaultSettings_Lambda_ImplicitReturn_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DefaultSettings_Lambda_ImplicitReturn_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -698,10 +715,11 @@ void Method()
GetCSharpResultAt(9, 13, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_JsonConvert_DefaultSettings_LocalFunction_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DefaultSettings_LocalFunction_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -721,10 +739,11 @@ JsonSerializerSettings GetSettings()
GetCSharpResultAt(14, 20, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_JsonConvert_DefaultSettings_LocalFunctionWithTryCatch_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DefaultSettings_LocalFunctionWithTryCatch_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -760,10 +779,11 @@ void HandleException(Exception exParam)
GetCSharpResultAt(24, 20, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_JsonConvert_DefaultSettings_LocalFunction_CapturedVariables_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DefaultSettings_LocalFunction_CapturedVariables_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -787,10 +807,11 @@ JsonSerializerSettings GetSettings()
}
// Ideally, we'd only generate one diagnostic in this case.
- [Fact]
- public async Task Insecure_JsonConvert_DefaultSettings_NestedLocalFunction_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_JsonConvert_DefaultSettings_NestedLocalFunction_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -816,10 +837,11 @@ JsonSerializerSettings InnerGetSettings()
GetCSharpResultAt(18, 24, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_FieldInitialization_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_FieldInitialization_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -829,10 +851,11 @@ class Blah
GetCSharpResultAt(6, 60, DefinitelyRule));
}
- [Fact]
- public async Task Secure_FieldInitialization_SerializationBinderSet_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Secure_FieldInitialization_SerializationBinderSet_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -853,34 +876,44 @@ public class MyISerializationBinder : Newtonsoft.Json.Serialization.ISerializati
}");
}
- [Fact]
- public async Task Secure_FieldInitialization_BinderSet_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Secure_FieldInitialization_BinderSet_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ string serializationBinderType = "System.Runtime.Serialization.SerializationBinder";
+#if NETCOREAPP
+ if (version < NewtonsoftJsonVersion.Version12)
+ {
+ serializationBinderType = "Newtonsoft.Json.SerializationBinder";
+ }
+#endif
+
+ await VerifyCSharpWithJsonNetAsync(version, $@"
using System;
using Newtonsoft.Json;
class Blah
-{
+{{
public static readonly JsonSerializerSettings Settings =
new JsonSerializerSettings()
- {
+ {{
TypeNameHandling = TypeNameHandling.Objects,
Binder = new MyBinder(),
- };
-}
+ }};
+}}
-public class MyBinder : System.Runtime.Serialization.SerializationBinder
-{
+public class MyBinder : {serializationBinderType}
+{{
public override Type BindToType(string assemblyName, string typeName) => throw new NotImplementedException();
public override void BindToName(Type serializedType, out string assemblyName, out string typeName) => throw new NotImplementedException();
-}");
+}}");
}
- [Fact]
- public async Task Insecure_PropertyInitialization_DefinitelyDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_PropertyInitialization_DefinitelyDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
class Blah
@@ -890,10 +923,11 @@ class Blah
GetCSharpResultAt(6, 60, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_PropertyInitialization_MaybeDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_PropertyInitialization_MaybeDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -915,10 +949,11 @@ class Blah
GetCSharpResultAt(14, 60, MaybeRule));
}
- [Fact]
- public async Task Insecure_Lazy_Field_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_Lazy_Field_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -933,10 +968,11 @@ class Blah
GetCSharpResultAt(9, 13, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_Instance_Constructor_Initializer_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_Instance_Constructor_Initializer_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -955,10 +991,11 @@ public Blah()
GetCSharpResultAt(11, 9, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_Instance_Constructor_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_Instance_Constructor_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -975,10 +1012,11 @@ public Blah()
GetCSharpResultAt(11, 9, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_Instance_Constructor_Interprocedural_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_Instance_Constructor_Interprocedural_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1007,10 +1045,11 @@ public void Initialize(bool flag)
GetCSharpResultAt(18, 13, DefinitelyRule));
}
- [Fact]
- public async Task InsecureButNotInitialized_Instance_Constructor_Interprocedural_LValuesWithMoreThanOneCapturedOperation_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task InsecureButNotInitialized_Instance_Constructor_Interprocedural_LValuesWithMoreThanOneCapturedOperation_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1044,10 +1083,11 @@ public static void Initialize(JsonSerializerSettings[] a1, JsonSerializerSetting
");
}
- [Fact]
- public async Task Unknown_PropertyInitialized_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Unknown_PropertyInitialized_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1065,10 +1105,11 @@ public Blah()
");
}
- [Fact]
- public async Task UnknownThenNull_PropertyInitialized_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task UnknownThenNull_PropertyInitialized_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1087,10 +1128,11 @@ public Blah()
");
}
- [Fact]
- public async Task UnknownOrNull_PropertyInitialized_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task UnknownOrNull_PropertyInitialized_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1111,10 +1153,11 @@ public Blah()
");
}
- [Fact]
- public async Task InsecureThenNull_PropertyInitialized_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task InsecureThenNull_PropertyInitialized_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1131,10 +1174,11 @@ public Blah()
");
}
- [Fact]
- public async Task InsecureThenSecure_PropertyInitialized_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task InsecureThenSecure_PropertyInitialized_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1151,10 +1195,11 @@ public Blah()
");
}
- [Fact]
- public async Task SecureThenInsecure_FieldInitialized_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task SecureThenInsecure_FieldInitialized_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1172,10 +1217,11 @@ public Blah()
GetCSharpResultAt(11, 9, DefinitelyRule));
}
- [Fact]
- public async Task InsecureOrNull_PropertyInitialized_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task InsecureOrNull_PropertyInitialized_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1195,10 +1241,11 @@ public Blah()
GetCSharpResultAt(12, 13, DefinitelyRule));
}
- [Fact]
- public async Task InsecureOrSecure_PropertyInitialized_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task InsecureOrSecure_PropertyInitialized_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1218,10 +1265,11 @@ public Blah()
GetCSharpResultAt(12, 13, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_Field_Initialized_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_Field_Initialized_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1238,10 +1286,11 @@ static Blah()
GetCSharpResultAt(11, 9, DefinitelyRule));
}
- [Fact]
- public async Task Insecure_UnusedLocalVariable_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_UnusedLocalVariable_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1263,10 +1312,11 @@ public void Initialize(bool flag)
");
}
- [Fact]
- public async Task Insecure_Return_InstanceMethod_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Insecure_Return_InstanceMethod_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -1300,7 +1350,7 @@ public async Task EditorConfigConfiguration_ExcludedSymbolNamesWithValueOption(s
{
var csharpTest = new VerifyCS.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
TestState =
{
Sources =
@@ -1330,11 +1380,16 @@ object Method(string s)
await csharpTest.RunAsync();
}
- private async Task VerifyCSharpWithJsonNetAsync(string source, params DiagnosticResult[] expected)
+ private async Task VerifyCSharpWithJsonNetAsync(NewtonsoftJsonVersion version, string source, params DiagnosticResult[] expected)
{
var csharpTest = new VerifyCS.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = version switch
+ {
+ NewtonsoftJsonVersion.Version10 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson10,
+ NewtonsoftJsonVersion.Version12 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
+ _ => throw new NotSupportedException(),
+ },
TestState =
{
Sources = { source },
@@ -1346,11 +1401,16 @@ private async Task VerifyCSharpWithJsonNetAsync(string source, params Diagnostic
await csharpTest.RunAsync();
}
- private async Task VerifyBasicWithJsonNetAsync(string source, params DiagnosticResult[] expected)
+ private async Task VerifyBasicWithJsonNetAsync(NewtonsoftJsonVersion version, string source, params DiagnosticResult[] expected)
{
var vbTest = new VerifyVB.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = version switch
+ {
+ NewtonsoftJsonVersion.Version10 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson10,
+ NewtonsoftJsonVersion.Version12 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
+ _ => throw new NotSupportedException(),
+ },
TestState =
{
Sources = { source },
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandlingTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandlingTests.cs
index a0932aa513..9fa76baa18 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandlingTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandlingTests.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 System;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
@@ -18,10 +19,11 @@ public class JsonNetTypeNameHandlingTests
{
private static readonly DiagnosticDescriptor Rule = JsonNetTypeNameHandling.Rule;
- [Fact]
- public async Task DocSample1_CSharp_Violation_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_CSharp_Violation_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
public class ExampleClass
@@ -37,10 +39,11 @@ public ExampleClass()
GetCSharpResultAt(11, 37, Rule));
}
- [Fact]
- public async Task DocSample1_VB_Violation_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_VB_Violation_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports Newtonsoft.Json
Public Class ExampleClass
@@ -54,10 +57,11 @@ End Sub
GetBasicResultAt(9, 37, Rule));
}
- [Fact]
- public async Task DocSample1_CSharp_Solution_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_CSharp_Solution_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using Newtonsoft.Json;
public class ExampleClass
@@ -73,10 +77,11 @@ public ExampleClass()
}");
}
- [Fact]
- public async Task DocSample1_VB_Solution_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task DocSample1_VB_Solution_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyBasicWithJsonNetAsync(@"
+ await VerifyBasicWithJsonNetAsync(version, @"
Imports Newtonsoft.Json
Public Class ExampleClass
@@ -90,10 +95,11 @@ End Sub
End Class");
}
- [Fact]
- public async Task Reference_TypeNameHandling_None_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Reference_TypeNameHandling_None_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -106,10 +112,11 @@ public static void Main(string[] args)
}");
}
- [Fact]
- public async Task Reference_TypeNameHandling_All_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Reference_TypeNameHandling_All_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -123,10 +130,11 @@ public static void Main(string[] args)
GetCSharpResultAt(9, 27, Rule));
}
- [Fact]
- public async Task Reference_AttributeTargets_All_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Reference_AttributeTargets_All_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -139,10 +147,11 @@ public static void Main(string[] args)
}");
}
- [Fact]
- public async Task Assign_TypeNameHandling_Objects_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Assign_TypeNameHandling_Objects_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -156,10 +165,11 @@ public static void Main(string[] args)
GetCSharpResultAt(9, 32, Rule));
}
- [Fact]
- public async Task Assign_TypeNameHandling_1_Or_Arrays_Diagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Assign_TypeNameHandling_1_Or_Arrays_Diagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -173,10 +183,11 @@ public static void Main(string[] args)
GetCSharpResultAt(9, 55, Rule));
}
- [Fact]
- public async Task Assign_TypeNameHandling_0_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Assign_TypeNameHandling_0_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -189,10 +200,11 @@ public static void Main(string[] args)
}");
}
- [Fact]
- public async Task Assign_TypeNameHandling_None_NoDiagnostic()
+ [Theory]
+ [CombinatorialData]
+ public async Task Assign_TypeNameHandling_None_NoDiagnostic(NewtonsoftJsonVersion version)
{
- await VerifyCSharpWithJsonNetAsync(@"
+ await VerifyCSharpWithJsonNetAsync(version, @"
using System;
using Newtonsoft.Json;
@@ -205,11 +217,16 @@ public static void Main(string[] args)
}");
}
- private async Task VerifyCSharpWithJsonNetAsync(string source, params DiagnosticResult[] expected)
+ private async Task VerifyCSharpWithJsonNetAsync(NewtonsoftJsonVersion version, string source, params DiagnosticResult[] expected)
{
var csharpTest = new VerifyCS.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = version switch
+ {
+ NewtonsoftJsonVersion.Version10 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson10,
+ NewtonsoftJsonVersion.Version12 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
+ _ => throw new NotSupportedException(),
+ },
TestState =
{
Sources = { source },
@@ -221,11 +238,16 @@ private async Task VerifyCSharpWithJsonNetAsync(string source, params Diagnostic
await csharpTest.RunAsync();
}
- private async Task VerifyBasicWithJsonNetAsync(string source, params DiagnosticResult[] expected)
+ private async Task VerifyBasicWithJsonNetAsync(NewtonsoftJsonVersion version, string source, params DiagnosticResult[] expected)
{
var vbTest = new VerifyVB.Test
{
- ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithNewtonsoftJson,
+ ReferenceAssemblies = version switch
+ {
+ NewtonsoftJsonVersion.Version10 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson10,
+ NewtonsoftJsonVersion.Version12 => AdditionalMetadataReferences.DefaultWithNewtonsoftJson12,
+ _ => throw new NotSupportedException(),
+ },
TestState =
{
Sources = { source },
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/NewtonsoftJsonVersion.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/NewtonsoftJsonVersion.cs
new file mode 100644
index 0000000000..c96e90aea5
--- /dev/null
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Security/NewtonsoftJsonVersion.cs
@@ -0,0 +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.
+
+namespace Microsoft.NetCore.Analyzers.Security.UnitTests
+{
+ public enum NewtonsoftJsonVersion
+ {
+ Version10,
+ Version12,
+ }
+}
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs
index 0e0ed8d2e7..a61f9a4499 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingCreateUsingInsecureInputXmlReaderSettingsTests.cs
@@ -17,7 +17,9 @@ public partial class DoNotUseInsecureDtdProcessingAnalyzerTests
[Fact]
public async Task XmlReaderSettingsDefaultAsFieldShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -34,7 +36,9 @@ public void TestMethod(string path)
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -52,7 +56,9 @@ End Class
[Fact]
public async Task XmlReaderSettingsAsFieldSetDtdProcessingToParseWithNoCreateShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -67,7 +73,9 @@ public void TestMethod(){}
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -85,7 +93,9 @@ End Class
[Fact]
public async Task XmlReaderSettingsAsFieldDefaultAndDtdProcessingToIgnoreShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -104,7 +114,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -122,7 +134,9 @@ End Class
[Fact]
public async Task XmlReaderSettingsAsInputSetDtdProcessingToParseShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -137,7 +151,9 @@ public void TestMethod(string path, XmlReaderSettings settings)
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -152,7 +168,9 @@ End Class
[Fact]
public async Task XmlReaderSettingsAsInputInGetShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
public class TestClass
@@ -170,7 +188,9 @@ public XmlReader Test
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Public Class TestClass
@@ -188,7 +208,9 @@ End Property
[Fact]
public async Task XmlReaderSettingsAsInputInTryShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -208,7 +230,9 @@ private void TestMethod()
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -229,7 +253,9 @@ End Sub
[Fact]
public async Task XmlReaderSettingsAsInputInCatchShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -248,7 +274,9 @@ private void TestMethod()
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -268,7 +296,9 @@ End Sub
[Fact]
public async Task XmlReaderSettingsAsInputInFinallyShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -287,7 +317,9 @@ private void TestMethod()
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -308,7 +340,9 @@ End Sub
[Fact]
public async Task XmlReaderSettingsAsInputInAsyncAwaitShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -330,7 +364,9 @@ private async void TestMethod2()
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -353,7 +389,9 @@ End Sub
[Fact]
public async Task XmlReaderSettingsAsInputInDelegateShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -369,7 +407,9 @@ class TestClass
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -388,7 +428,9 @@ End Sub
[Fact]
public async Task XmlReaderSettingsAsInputSetDtdProcessingToProhibitShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -405,7 +447,9 @@ public void TestMethod(string path, XmlReaderSettings settings)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -421,7 +465,9 @@ End Class
[Fact]
public async Task XmlReaderSettingsAsInputSetPropertiesToSecureValuesShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -440,7 +486,9 @@ public void TestMethod(string path, XmlReaderSettings settings)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs
index d361269c69..8725ad328a 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseLoadXmlTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075LoadXmlBasicResultAt(int line, int colu
[Fact]
public async Task UseXmlDocumentLoadXmlShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -40,7 +42,9 @@ public void TestMethod(string xml)
GetCA3075LoadXmlCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -59,7 +63,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadXmlInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -77,7 +83,9 @@ public XmlDocument Test
GetCA3075LoadXmlCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -99,7 +107,9 @@ End Property
[Fact]
public async Task UseXmlDocumentLoadXmlInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -124,7 +134,9 @@ public XmlDocument GetDoc
GetCA3075LoadXmlCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -151,7 +163,9 @@ End Property
[Fact]
public async Task UseXmlDocumentLoadXmlInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -172,7 +186,9 @@ private void TestMethod()
GetCA3075LoadXmlCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -197,7 +213,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadXmlInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -218,7 +236,9 @@ private void TestMethod()
GetCA3075LoadXmlCSharpResultAt(14, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -242,7 +262,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadXmlInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -263,7 +285,9 @@ private void TestMethod()
GetCA3075LoadXmlCSharpResultAt(15, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -288,7 +312,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadXmlInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -311,7 +337,9 @@ private async void TestMethod2()
GetCA3075LoadXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -338,7 +366,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadXmlShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -355,7 +385,9 @@ public void TestMethod1(string xml)
GetCA3075LoadXmlCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -375,7 +407,9 @@ End Class
[Fact]
public async Task UseXmlDataDocumentLoadXmlInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -400,7 +434,9 @@ public XmlDataDocument SetDoc
GetCA3075LoadXmlCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -427,7 +463,9 @@ End Property
[Fact]
public async Task UseXmlDataDocumentLoadXmlInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -448,7 +486,9 @@ private void TestMethod()
GetCA3075LoadXmlCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -473,7 +513,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadXmlInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -494,7 +536,9 @@ private void TestMethod()
GetCA3075LoadXmlCSharpResultAt(14, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -518,7 +562,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadXmlInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -539,7 +585,9 @@ private void TestMethod()
GetCA3075LoadXmlCSharpResultAt(15, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -564,7 +612,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadXmlInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -587,7 +637,9 @@ private async void TestMethod2()
GetCA3075LoadXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -614,7 +666,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadXmlInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -637,7 +691,9 @@ private async void TestMethod2()
GetCA3075LoadXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs
index c942585ac7..5a22e26942 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingDoNotUseSetInnerXmlTests.cs
@@ -17,7 +17,9 @@ public partial class DoNotUseInsecureDtdProcessingAnalyzerTests
[Fact]
public async Task UseXmlDocumentSetInnerXmlShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -35,7 +37,9 @@ public void TestMethod(string xml)
GetCA3075InnerXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
@@ -56,7 +60,9 @@ End Class
[Fact]
public async Task UseXmlDocumentSetInnerXmlInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -74,7 +80,9 @@ public XmlDocument Test
GetCA3075InnerXmlCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -96,7 +104,9 @@ End Property
[Fact]
public async Task UseXmlDocumentSetInnerXmlInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -121,7 +131,9 @@ public XmlDocument GetDoc
GetCA3075InnerXmlCSharpResultAt(15, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -148,7 +160,9 @@ End Property
[Fact]
public async Task UseXmlDocumentSetInnerXmlInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -169,7 +183,9 @@ private void TestMethod()
GetCA3075InnerXmlCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -194,7 +210,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentSetInnerXmlInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -215,7 +233,9 @@ private void TestMethod()
GetCA3075InnerXmlCSharpResultAt(14, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -239,7 +259,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentSetInnerXmlInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -260,7 +282,9 @@ private void TestMethod()
GetCA3075InnerXmlCSharpResultAt(15, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -285,7 +309,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentSetInnerXmlInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -308,7 +334,9 @@ private async void TestMethod2()
GetCA3075InnerXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -335,7 +363,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentSetInnerXmlInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -351,7 +381,9 @@ class TestClass
GetCA3075InnerXmlCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -373,7 +405,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentSetInnerXmlInlineShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -394,7 +428,9 @@ public void TestMethod(string xml)
GetCA3075InnerXmlCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
@@ -415,7 +451,9 @@ End Class
[Fact]
public async Task UseXmlDataDocumentInnerXmlShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -433,7 +471,9 @@ public void TestMethod(string xml)
GetCA3075InnerXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
@@ -454,7 +494,9 @@ End Class
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -472,7 +514,9 @@ public XmlDataDocument Test
GetCA3075InnerXmlCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -494,7 +538,9 @@ End Property
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -519,7 +565,9 @@ public XmlDataDocument GetDoc
GetCA3075InnerXmlCSharpResultAt(15, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -547,7 +595,9 @@ End Class
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -568,7 +618,9 @@ private void TestMethod()
GetCA3075InnerXmlCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -593,7 +645,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -614,7 +668,9 @@ private void TestMethod()
GetCA3075InnerXmlCSharpResultAt(14, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -638,7 +694,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -659,7 +717,9 @@ private void TestMethod()
GetCA3075InnerXmlCSharpResultAt(15, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -684,7 +744,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -707,7 +769,9 @@ private async void TestMethod2()
GetCA3075InnerXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -734,7 +798,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -750,7 +816,9 @@ class TestClass
GetCA3075InnerXmlCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -772,7 +840,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentSetInnerXmlInlineShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -793,7 +863,9 @@ public void TestMethod(string xml)
GetCA3075InnerXmlCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs
index 335ff4105f..6e3c441ac6 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs
@@ -24,7 +24,7 @@ private static DiagnosticResult GetCA3077ConstructorBasicResultAt(int line, int
[Fact]
public async Task XmlDocumentDerivedTypeWithEmptyConstructorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -38,7 +38,7 @@ public TestClass () {}
GetCA3077ConstructorCSharpResultAt(9, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -55,7 +55,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetResolverToNullInOnlyCtorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -71,7 +71,7 @@ public TestClass()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -87,7 +87,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetInsecureResolverInOnlyCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -104,7 +104,7 @@ public TestClass(XmlResolver resolver)
GetCA3077ConstructorCSharpResultAt(9, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -122,7 +122,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetInsecureResolverInCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -144,7 +144,7 @@ public TestClass(XmlResolver resolver)
GetCA3077ConstructorCSharpResultAt(14, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -166,7 +166,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetSecureResolverForVariableInCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -183,7 +183,7 @@ public TestClass(XmlDocument doc)
GetCA3077ConstructorCSharpResultAt(9, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -201,7 +201,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetSecureResolverWithOutThisInCtorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -218,7 +218,7 @@ public TestClass(XmlDocument doc)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -235,7 +235,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetSecureResolverToAXmlDocumentFieldInCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -253,7 +253,7 @@ public TestClass(XmlDocument doc)
GetCA3077ConstructorCSharpResultAt(10, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -272,7 +272,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetSecureResolverAtLeastOnceInCtorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -295,7 +295,7 @@ public TestClass(bool flag)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -315,7 +315,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetNullToHidingFieldInCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -333,7 +333,7 @@ public TestClass()
GetCA3077ConstructorCSharpResultAt(10, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -352,7 +352,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetNullToBaseXmlResolverInCtorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -369,7 +369,7 @@ public TestClass()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -386,7 +386,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetUrlResolverToBaseXmlResolverInCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -404,7 +404,7 @@ public TestClass()
GetCA3077ConstructorCSharpResultAt(10, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -423,7 +423,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetNullToHidingPropertyInCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -442,7 +442,7 @@ public TestClass()
GetCA3077ConstructorCSharpResultAt(11, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -470,7 +470,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetNullToBaseWithHidingPropertyInCtorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -488,7 +488,7 @@ public TestClass()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -514,7 +514,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetUrlResolverToBaseWithHidingPropertyInCtorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -533,7 +533,7 @@ public TestClass()
GetCA3077ConstructorCSharpResultAt(11, 16, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -557,5 +557,29 @@ End Class
GetCA3077ConstructorBasicResultAt(17, 20, "TestClass")
);
}
+
+ private async Task VerifyCSharpAnalyzerAsync(string source, params DiagnosticResult[] expected)
+ {
+ var test = new VerifyCS.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = source,
+ };
+
+ test.ExpectedDiagnostics.AddRange(expected);
+ await test.RunAsync();
+ }
+
+ private async Task VerifyVisualBasicAnalyzerAsync(string source, params DiagnosticResult[] expected)
+ {
+ var test = new VerifyVB.Test
+ {
+ ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default,
+ TestCode = source,
+ };
+
+ test.ExpectedDiagnostics.AddRange(expected);
+ await test.RunAsync();
+ }
}
}
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs
index 65a255ea5f..52809a954a 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignNoConstructorTests.cs
@@ -24,7 +24,7 @@ private static DiagnosticResult GetCA3077NoConstructorBasicResultAt(int line, in
[Fact]
public async Task NonXmlDocumentDerivedTypeWithNoConstructorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -40,7 +40,7 @@ public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToRe
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System
Imports System.Xml
@@ -57,7 +57,7 @@ End Class
[Fact]
public async Task NonXmlDocumentDerivedTypeWithConstructorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -75,7 +75,7 @@ public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToRe
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System
Imports System.Xml
@@ -95,7 +95,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeWithNoConstructorShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -106,7 +106,7 @@ class TestClass : XmlDocument {}
GetCA3077NoConstructorCSharpResultAt(7, 11, "TestClass")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs
index 9cab0a1608..525050ab45 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignSetInsecureXmlResolverInMethodTests.cs
@@ -24,7 +24,7 @@ private static DiagnosticResult GetCA3077InsecureMethodBasicResultAt(int line, i
[Fact]
public async Task XmlDocumentDerivedTypeNoCtorSetUrlResolverToXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -46,7 +46,7 @@ public void method()
GetCA3077InsecureMethodCSharpResultAt(16, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -67,7 +67,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetUrlResolverToXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -89,7 +89,7 @@ public void method()
GetCA3077InsecureMethodCSharpResultAt(16, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -111,7 +111,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetNullToXmlResolverMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -132,7 +132,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -152,7 +152,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetUrlResolverToThisXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -174,7 +174,7 @@ public void method()
GetCA3077InsecureMethodCSharpResultAt(16, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -196,7 +196,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetNullToThisXmlResolverMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -217,7 +217,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -237,7 +237,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetUrlResolverToBaseXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -259,7 +259,7 @@ public void method()
GetCA3077InsecureMethodCSharpResultAt(16, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -281,7 +281,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetNullToBaseXmlResolverMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -302,7 +302,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -322,7 +322,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetUrlResolverToVariableMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -343,7 +343,7 @@ public void method(XmlDocument doc)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -363,7 +363,7 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetUrlResolverToHidingXmlResolverFieldInMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -386,7 +386,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs
index 7a23684a52..dfd8afd308 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs
@@ -24,7 +24,7 @@ private static DiagnosticResult GetCA3077XmlTextReaderDerivedClassSetInsecureSet
[Fact]
public async Task XmlTextReaderDerivedTypeNoCtorSetUrlResolverToXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -41,7 +41,7 @@ public void method()
GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(11, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -59,7 +59,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetUrlResolverToXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -82,7 +82,7 @@ public void method()
GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(17, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -105,7 +105,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetDtdProcessingToParseMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -128,7 +128,7 @@ public void method()
GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(17, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -151,7 +151,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetUrlResolverToThisXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -174,7 +174,7 @@ public void method()
GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(17, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -197,7 +197,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetUrlResolverToBaseXmlResolverMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -220,7 +220,7 @@ public void method()
GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(17, 13, "method")
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -243,7 +243,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetXmlResolverToNullMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -265,7 +265,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -286,7 +286,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetDtdProcessingToProhibitMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -308,7 +308,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -329,7 +329,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetDtdProcessingToTypoMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -351,7 +351,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -372,7 +372,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeParseAndNullResolverMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -395,7 +395,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -417,7 +417,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeIgnoreAndUrlResolverMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -440,7 +440,7 @@ public void method()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -465,7 +465,7 @@ public async Task XmlTextReaderDerivedTypeParseAndUrlResolverMethodShouldGenerat
DiagnosticResult diagWith2Locations = GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodCSharpResultAt(17, 13, "method")
.WithLocation(18, 13);
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -492,7 +492,7 @@ public void method()
diagWith2Locations = GetCA3077XmlTextReaderDerivedClassSetInsecureSettingsInMethodBasicResultAt(13, 13, "method")
.WithLocation(14, 13);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -517,7 +517,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSecureResolverInOnePathMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -547,7 +547,7 @@ public void method(bool flag)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
@@ -574,7 +574,7 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetInsecureSettingsInSeperatePathsMethodShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(@"
using System;
using System.Xml;
@@ -607,7 +607,7 @@ public void method(bool flag)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(@"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs
index b8521a8a75..e52749c28e 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingReviewDataViewCollectionStringTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075DataViewBasicResultAt(int line, int col
[Fact]
public async Task UseDataSetDefaultDataViewManagerSetCollectionStringShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
namespace TestNamespace
@@ -41,7 +43,9 @@ public void TestMethod(string src)
GetCA3075DataViewCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Namespace TestNamespace
@@ -59,7 +63,9 @@ End Class
[Fact]
public async Task UseDataSetDefaultDataViewManagernInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -77,7 +83,9 @@ public DataSet Test
GetCA3075DataViewCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -97,7 +105,9 @@ End Property
[Fact]
public async Task UseDataSetDefaultDataViewManagerInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -122,7 +132,9 @@ public DataSet GetDoc
GetCA3075DataViewCSharpResultAt(15, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -147,7 +159,9 @@ End Property
[Fact]
public async Task UseDataSetDefaultDataViewManagerInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -168,7 +182,9 @@ private void TestMethod()
GetCA3075DataViewCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -191,7 +207,9 @@ End Sub
[Fact]
public async Task UseDataSetDefaultDataViewManagerInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -212,7 +230,9 @@ private void TestMethod()
GetCA3075DataViewCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -234,7 +254,9 @@ End Sub
[Fact]
public async Task UseDataSetDefaultDataViewManagerInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -255,7 +277,9 @@ private void TestMethod()
GetCA3075DataViewCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -278,7 +302,9 @@ End Sub
[Fact]
public async Task UseDataSetDefaultDataViewManagerInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Data;
@@ -301,7 +327,9 @@ private async void TestMethod2()
GetCA3075DataViewCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Data
@@ -326,7 +354,9 @@ End Sub
[Fact]
public async Task UseDataSetDefaultDataViewManagerInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -342,7 +372,9 @@ class TestClass
GetCA3075DataViewCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -362,7 +394,9 @@ End Sub
[Fact]
public async Task UseDataViewManagerSetCollectionStringShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
namespace TestNamespace
@@ -380,7 +414,9 @@ public void TestMethod(string src)
GetCA3075DataViewCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Namespace TestNamespace
@@ -398,7 +434,9 @@ End Class
[Fact]
public async Task UseDataViewManagerInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -416,7 +454,9 @@ public DataViewManager Test
GetCA3075DataViewCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -436,7 +476,9 @@ End Property
[Fact]
public async Task UseDataViewManagerInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -461,7 +503,9 @@ public DataViewManager GetDoc
GetCA3075DataViewCSharpResultAt(15, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -486,7 +530,9 @@ End Property
[Fact]
public async Task UseDataViewManagerInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -507,7 +553,9 @@ private void TestMethod()
GetCA3075DataViewCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -530,7 +578,9 @@ End Sub
[Fact]
public async Task UseDataViewManagerInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -551,7 +601,9 @@ private void TestMethod()
GetCA3075DataViewCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -573,7 +625,9 @@ End Sub
[Fact]
public async Task UseDataViewManagerInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -594,7 +648,9 @@ private void TestMethod()
GetCA3075DataViewCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -617,7 +673,9 @@ End Sub
[Fact]
public async Task UseDataViewManagerInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Data;
@@ -640,7 +698,9 @@ private async void TestMethod2()
GetCA3075DataViewCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Data
@@ -665,7 +725,9 @@ End Sub
[Fact]
public async Task UseDataViewManagerInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -681,7 +743,9 @@ class TestClass
GetCA3075DataViewCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs
index 84dc3b8891..d72d75e3df 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlSchemaTests.cs
@@ -23,7 +23,9 @@ private DiagnosticResult CA3075ReadXmlSchemaGetBasicResultAt(int line, int colum
[Fact]
public async Task UseDataSetReadXmlSchemaShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
namespace TestNamespace
@@ -41,7 +43,9 @@ public void TestMethod(string path)
CA3075ReadXmlSchemaGetCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Namespace TestNamespace
@@ -59,7 +63,9 @@ End Class
[Fact]
public async Task UseDataSetReadXmlSchemaInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -77,7 +83,9 @@ public DataSet Test
CA3075ReadXmlSchemaGetCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -97,7 +105,9 @@ End Property
[Fact]
public async Task UseDataSetReadXmlSchemaInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -122,7 +132,9 @@ public DataSet GetDoc
CA3075ReadXmlSchemaGetCSharpResultAt(15, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -147,7 +159,9 @@ End Property
[Fact]
public async Task UseDataSetReadXmlSchemaInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -168,7 +182,9 @@ private void TestMethod()
CA3075ReadXmlSchemaGetCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -191,7 +207,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlSchemaInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -212,7 +230,9 @@ private void TestMethod()
CA3075ReadXmlSchemaGetCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -234,7 +254,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlSchemaInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -255,7 +277,9 @@ private void TestMethod()
CA3075ReadXmlSchemaGetCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -278,7 +302,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlSchemaInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Data;
@@ -301,7 +327,9 @@ private async void TestMethod2()
CA3075ReadXmlSchemaGetCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Data
@@ -326,7 +354,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlSchemaInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -342,7 +372,9 @@ class TestClass
CA3075ReadXmlSchemaGetCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -362,7 +394,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlSchemaWithXmlReaderShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -380,7 +414,9 @@ public void TestMethod(XmlReader reader)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs
index d0ecd8f030..ef548ae830 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataSetReadXmlTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075DataSetReadXmlBasicResultAt(int line, i
[Fact]
public async Task UseDataSetReadXmlShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -42,7 +44,9 @@ public void TestMethod1214(string path)
GetCA3075DataSetReadXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
@@ -61,7 +65,9 @@ End Class
[Fact]
public async Task UseDataSetReadXmlInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -79,7 +85,9 @@ public DataSet Test
GetCA3075DataSetReadXmlCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -99,7 +107,9 @@ End Property
[Fact]
public async Task UseDataSetReadXmlInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -124,7 +134,9 @@ public DataSet GetDoc
GetCA3075DataSetReadXmlCSharpResultAt(15, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -149,7 +161,9 @@ End Property
[Fact]
public async Task UseDataSetReadXmlInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -170,7 +184,9 @@ private void TestMethod()
GetCA3075DataSetReadXmlCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -193,7 +209,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -214,7 +232,9 @@ private void TestMethod()
GetCA3075DataSetReadXmlCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -236,7 +256,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -257,7 +279,9 @@ private void TestMethod()
GetCA3075DataSetReadXmlCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -280,7 +304,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Data;
@@ -303,7 +329,9 @@ private async void TestMethod2()
GetCA3075DataSetReadXmlCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Data
@@ -328,7 +356,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -344,7 +374,9 @@ class TestClass
GetCA3075DataSetReadXmlCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -364,7 +396,9 @@ End Sub
[Fact]
public async Task UseDataSetReadXmlWithXmlReaderShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -382,7 +416,9 @@ public void TestMethod1214Ok(XmlReader reader)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs
index 7df2eaddbd..c74e49be68 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlSchemaTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075DataTableReadXmlSchemaBasicResultAt(int
[Fact]
public async Task UseDataTableReadXmlSchemaShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml;
using System.Data;
@@ -43,7 +45,9 @@ public void TestMethod(Stream stream)
GetCA3075DataTableReadXmlSchemaCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml
Imports System.Data
@@ -63,7 +67,9 @@ End Class
[Fact]
public async Task UseDataTableReadXmlSchemaInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -81,7 +87,9 @@ public DataTable Test
GetCA3075DataTableReadXmlSchemaCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -101,7 +109,9 @@ End Property
[Fact]
public async Task UseDataTableReadXmlSchemaInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -126,7 +136,9 @@ public DataTable GetDoc
GetCA3075DataTableReadXmlSchemaCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -151,7 +163,9 @@ End Property
[Fact]
public async Task UseDataTableReadXmlSchemaInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -172,7 +186,9 @@ private void TestMethod()
GetCA3075DataTableReadXmlSchemaCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -195,7 +211,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlSchemaInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -216,7 +234,9 @@ private void TestMethod()
GetCA3075DataTableReadXmlSchemaCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -238,7 +258,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlSchemaInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -259,7 +281,9 @@ private void TestMethod()
GetCA3075DataTableReadXmlSchemaCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -282,7 +306,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlSchemaInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Data;
@@ -305,7 +331,9 @@ private async void TestMethod2()
GetCA3075DataTableReadXmlSchemaCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Data
@@ -330,7 +358,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlSchemaInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -346,7 +376,9 @@ class TestClass
GetCA3075DataTableReadXmlSchemaCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -366,7 +398,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlSchemaWithXmlReaderShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -384,7 +418,9 @@ public void TestMethod(XmlReader reader)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs
index 6dab322b88..3515eefb0e 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDataTableReadXmlTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075DataTableReadXmlBasicResultAt(int line,
[Fact]
public async Task UseDataTableReadXmlShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml;
using System.Data;
@@ -43,7 +45,9 @@ public void TestMethod(Stream stream)
GetCA3075DataTableReadXmlCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml
Imports System.Data
@@ -63,7 +67,9 @@ End Class
[Fact]
public async Task UseDataTableReadXmlInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -81,7 +87,9 @@ public DataTable Test
GetCA3075DataTableReadXmlCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -101,7 +109,9 @@ End Property
[Fact]
public async Task UseDataTableReadXmlInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -126,7 +136,9 @@ public DataTable GetDoc
GetCA3075DataTableReadXmlCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -151,7 +163,9 @@ End Property
[Fact]
public async Task UseDataTableReadXmlInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -172,7 +186,9 @@ private void TestMethod()
GetCA3075DataTableReadXmlCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -195,7 +211,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -216,7 +234,9 @@ private void TestMethod()
GetCA3075DataTableReadXmlCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -238,7 +258,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
@@ -259,7 +281,9 @@ private void TestMethod()
GetCA3075DataTableReadXmlCSharpResultAt(15, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
@@ -282,7 +306,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Data;
@@ -305,7 +331,9 @@ private async void TestMethod2()
GetCA3075DataTableReadXmlCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Data
@@ -329,7 +357,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
class TestClass
@@ -345,7 +375,9 @@ class TestClass
GetCA3075DataTableReadXmlCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Class TestClass
@@ -365,7 +397,9 @@ End Sub
[Fact]
public async Task UseDataTableReadXmlWithXmlReaderShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Data;
@@ -383,7 +417,9 @@ public void TestMethod(XmlReader reader)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Data
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs
index 552a246228..3aa1e99830 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForDeserializeTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075DeserializeBasicResultAt(int line, int
[Fact]
public async Task UseXmlSerializerDeserializeShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml;
using System.Xml.Serialization;
@@ -42,7 +44,9 @@ public void TestMethod(Stream stream)
GetCA3075DeserializeCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization
@@ -62,7 +66,9 @@ End Class
[Fact]
public async Task UseXmlSerializerDeserializeInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Serialization;
@@ -82,7 +88,9 @@ public XmlSerializer Test
GetCA3075DeserializeCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml.Serialization
@@ -103,7 +111,9 @@ End Property
[Fact]
public async Task UseXmlSerializerDeserializeInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Serialization;
@@ -129,7 +139,9 @@ public XmlSerializer SetDoc
GetCA3075DeserializeCSharpResultAt(16, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml.Serialization
@@ -155,7 +167,9 @@ End Property
[Fact]
public async Task UseXmlSerializerDeserializeInTryShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Serialization;
using System;
@@ -177,7 +191,9 @@ private void TestMethod()
GetCA3075DeserializeCSharpResultAt(14, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.IO
Imports System.Xml.Serialization
@@ -201,7 +217,9 @@ End Sub
[Fact]
public async Task UseXmlSerializerDeserializeInCatchShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Serialization;
using System;
@@ -222,7 +240,9 @@ private void TestMethod()
GetCA3075DeserializeCSharpResultAt(14, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.IO
Imports System.Xml.Serialization
@@ -245,7 +265,9 @@ End Sub
[Fact]
public async Task UseXmlSerializerDeserializeInFinallyShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Serialization;
using System;
@@ -266,7 +288,9 @@ private void TestMethod()
GetCA3075DeserializeCSharpResultAt(15, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.IO
Imports System.Xml.Serialization
@@ -290,7 +314,9 @@ End Sub
[Fact]
public async Task UseXmlSerializerDeserializeInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Serialization;
@@ -309,7 +335,9 @@ public class UseXmlReaderForDeserialize
GetCA3075DeserializeCSharpResultAt(13, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml.Serialization
@@ -331,7 +359,9 @@ End Sub
[Fact]
public async Task UseXmlSerializerDeserializeInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Threading.Tasks;
using System.Xml.Serialization;
@@ -354,7 +384,9 @@ private async void TestMethod2()
GetCA3075DeserializeCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Threading.Tasks
Imports System.Xml.Serialization
@@ -379,7 +411,9 @@ End Sub
[Fact]
public async Task UseXmlSerializerDeserializeWithXmlReaderShouldNoGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml;
using System.Xml.Serialization;
@@ -397,7 +431,9 @@ public void TestMethod(XmlTextReader reader)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs
index 1f822971d4..a1b7d64471 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForLoadTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075LoadBasicResultAt(int line, int column)
[Fact]
public async Task UseXmlDocumentLoadShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -42,7 +44,9 @@ public void TestMethod(string path)
GetCA3075LoadCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -61,7 +65,9 @@ End Class
[Fact]
public async Task UseXmlDocumentLoadInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -80,7 +86,9 @@ public XmlDocument Test
GetCA3075LoadCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -101,7 +109,9 @@ End Property
[Fact]
public async Task UseXmlDocumentLoadInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -127,7 +137,9 @@ public XmlDocument GetDoc
GetCA3075LoadCSharpResultAt(16, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -153,7 +165,9 @@ End Property
[Fact]
public async Task UseXmlDocumentLoadInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -175,7 +189,9 @@ private void TestMethod()
GetCA3075LoadCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -199,7 +215,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -221,7 +239,9 @@ private void TestMethod()
GetCA3075LoadCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -244,7 +264,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -266,7 +288,9 @@ private void TestMethod()
GetCA3075LoadCSharpResultAt(16, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -290,7 +314,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -314,7 +340,9 @@ private async void TestMethod2()
GetCA3075LoadCSharpResultAt(13, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -339,7 +367,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -356,7 +386,9 @@ class TestClass
GetCA3075LoadCSharpResultAt(12, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -377,7 +409,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -394,7 +428,9 @@ public void TestMethod(string path)
GetCA3075LoadCSharpResultAt(10, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -411,7 +447,9 @@ End Class
[Fact]
public async Task UseXmlDataDocumentLoadInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -430,7 +468,9 @@ public XmlDataDocument Test
GetCA3075LoadCSharpResultAt(12, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -452,7 +492,9 @@ End Property
[Fact]
public async Task UseXmlDataDocumentLoadInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -473,7 +515,9 @@ private void TestMethod()
GetCA3075LoadCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -498,7 +542,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -519,7 +565,9 @@ private void TestMethod()
GetCA3075LoadCSharpResultAt(14, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -543,7 +591,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -564,7 +614,9 @@ private void TestMethod()
GetCA3075LoadCSharpResultAt(15, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -589,7 +641,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -612,7 +666,9 @@ private async void TestMethod2()
GetCA3075LoadCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -639,7 +695,9 @@ End Sub
[Fact]
public async Task UseXmlDataDocumentLoadInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -655,7 +713,9 @@ class TestClass
GetCA3075LoadCSharpResultAt(11, 9)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -677,7 +737,9 @@ End Sub
[Fact]
public async Task UseXmlDocumentLoadWithXmlReaderParameterShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -693,7 +755,9 @@ private static void TestMethod(XmlTextReader reader)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -710,7 +774,9 @@ End Class
[Fact]
public async Task UseXmlDataDocumentLoadWithXmlReaderParameterShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -728,7 +794,9 @@ private static void TestMethod(XmlTextReader reader)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs
index 4c41cb3f05..82c545e222 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForSchemaReadTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075SchemaReadBasicResultAt(int line, int c
[Fact]
public async Task UseXmlSchemaReadWithoutXmlTextReaderShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Schema;
@@ -41,7 +43,9 @@ public void TestMethod(string path)
GetCA3075SchemaReadCSharpResultAt(12, 32)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml.Schema
@@ -60,7 +64,9 @@ End Class
[Fact]
public async Task UseXmlSchemaReadWithoutXmlTextReaderInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml.Schema;
@@ -80,7 +86,9 @@ public XmlSchema Test
GetCA3075SchemaReadCSharpResultAt(13, 32)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.IO
Imports System.Xml.Schema
@@ -101,7 +109,9 @@ End Property
[Fact]
public async Task UseUseXmlSchemaReadWithoutXmlTextReaderInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
using System.IO;
using System.Xml.Schema;
@@ -128,7 +138,9 @@ public XmlSchema GetDoc
GetCA3075SchemaReadCSharpResultAt(17, 36)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Imports System.IO
Imports System.Xml.Schema
@@ -155,7 +167,9 @@ End Property
[Fact]
public async Task UseXmlSchemaReadWithoutXmlTextReaderInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
using System.IO;
@@ -177,7 +191,9 @@ private void TestMethod()
GetCA3075SchemaReadCSharpResultAt(14, 32)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
Imports System.IO
@@ -201,7 +217,9 @@ End Sub
[Fact]
public async Task UseXmlSchemaReadWithoutXmlTextReaderInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
using System.IO;
@@ -223,7 +241,9 @@ private void TestMethod()
GetCA3075SchemaReadCSharpResultAt(15, 36)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
Imports System.IO
@@ -246,7 +266,9 @@ End Sub
[Fact]
public async Task UseXmlSchemaReadWithoutXmlTextReaderInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Data;
using System.IO;
@@ -268,7 +290,9 @@ private void TestMethod()
GetCA3075SchemaReadCSharpResultAt(16, 36)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Data
Imports System.IO
@@ -292,7 +316,9 @@ End Sub
[Fact]
public async Task UseXmlSchemaReadWithoutXmlTextReaderInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Data;
using System.IO;
@@ -316,7 +342,9 @@ private async void TestMethod2()
GetCA3075SchemaReadCSharpResultAt(13, 36)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Data
Imports System.IO
@@ -342,7 +370,9 @@ End Sub
[Fact]
public async Task UseXmlSchemaReadWithoutXmlTextReaderInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Data;
using System.IO;
using System.Xml.Schema;
@@ -359,7 +389,9 @@ class TestClass
GetCA3075SchemaReadCSharpResultAt(12, 32)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Data
Imports System.IO
Imports System.Xml.Schema
@@ -380,7 +412,9 @@ End Sub
[Fact]
public async Task UseXmlSchemaReadWithXmlTextReaderShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Xml.Schema;
@@ -396,7 +430,9 @@ public void TestMethod19(XmlTextReader reader)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Xml.Schema
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs
index 2d525b1896..1c7c1ef36a 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingUseXmlReaderForXPathDocumentTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075XPathDocumentBasicResultAt(int line, in
[Fact]
public async Task UseXPathDocumentWithoutReaderShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Xml.XPath;
@@ -41,7 +43,9 @@ public void TestMethod(string path)
GetCA3075XPathDocumentCSharpResultAt(11, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Imports System.Xml.XPath
@@ -59,7 +63,9 @@ End Class
[Fact]
public async Task UseXPathDocumentWithoutReaderInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml.XPath;
class TestClass
@@ -77,7 +83,9 @@ public XPathDocument Test
GetCA3075XPathDocumentCSharpResultAt(11, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml.XPath
Class TestClass
@@ -96,7 +104,9 @@ End Property
[Fact]
public async Task UseXPathDocumentWithoutReaderInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml.XPath;
class TestClass
@@ -120,7 +130,9 @@ public XPathDocument GetDoc
GetCA3075XPathDocumentCSharpResultAt(14, 41)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml.XPath
Class TestClass
@@ -144,7 +156,9 @@ End Property
[Fact]
public async Task UseXPathDocumentWithoutReaderInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml.XPath;
@@ -164,7 +178,9 @@ private void TestMethod()
GetCA3075XPathDocumentCSharpResultAt(12, 37)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml.XPath
@@ -186,7 +202,9 @@ End Sub
[Fact]
public async Task UseXPathDocumentWithoutReaderInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml.XPath;
@@ -206,7 +224,9 @@ private void TestMethod()
GetCA3075XPathDocumentCSharpResultAt(13, 37)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml.XPath
@@ -227,7 +247,9 @@ End Sub
[Fact]
public async Task UseXPathDocumentWithoutReaderInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml.XPath;
@@ -247,7 +269,9 @@ private void TestMethod()
GetCA3075XPathDocumentCSharpResultAt(14, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml.XPath
@@ -269,7 +293,9 @@ End Sub
[Fact]
public async Task UseXPathDocumentWithoutReaderInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml.XPath;
@@ -291,7 +317,9 @@ private async void TestMethod2()
GetCA3075XPathDocumentCSharpResultAt(11, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml.XPath
@@ -315,7 +343,9 @@ End Sub
[Fact]
public async Task UseXPathDocumentWithoutReaderInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml.XPath;
class TestClass
@@ -330,7 +360,9 @@ class TestClass
GetCA3075XPathDocumentCSharpResultAt(10, 29)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml.XPath
Class TestClass
@@ -349,7 +381,9 @@ End Sub
[Fact]
public async Task UseXPathDocumentWithXmlReaderShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
using System.Xml.XPath;
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs
index c095c5d078..39352c7fc7 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentConstructedWithNoSecureResolverTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075XmlDocumentWithNoSecureResolverBasicRes
[Fact]
public async Task XmlDocumentSetResolverToNullShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -39,7 +41,9 @@ private static void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -57,7 +61,9 @@ End Namespace
[Fact]
public async Task XmlDocumentSetResolverToNullInInitializerShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -75,7 +81,9 @@ private static void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -93,7 +101,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentAsFieldSetResolverToNullInInitializerShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -108,7 +118,9 @@ class TestClass
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -124,7 +136,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentAsFieldSetInsecureResolverInInitializerShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -137,7 +151,9 @@ class TestClass
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(8, 54)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -216,7 +232,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentUseSecureResolverShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -232,7 +250,9 @@ private static void TestMethod(XmlSecureResolver resolver)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -249,7 +269,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentSetSecureResolverInInitializerShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -267,7 +289,9 @@ private static void TestMethod(XmlSecureResolver resolver)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -285,7 +309,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentUseSecureResolverWithPermissionsShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Net;
using System.Security;
using System.Security.Permissions;
@@ -311,7 +337,9 @@ private static void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Net
Imports System.Security
Imports System.Security.Permissions
@@ -338,7 +366,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentSetResolverToNullInTryClauseShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -358,7 +388,9 @@ private static void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -451,7 +483,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentUseNonSecureResolverShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -468,7 +502,9 @@ private static void TestMethod()
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -487,7 +523,9 @@ End Class
[Fact]
public async Task XmlDocumentUseNonSecureResolverInTryClauseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -508,7 +546,9 @@ private static void TestMethod()
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -531,7 +571,9 @@ End Class
[Fact]
public async Task XmlDocumentReassignmentSetResolverToNullInInitializerShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -550,7 +592,9 @@ private static void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1125,7 +1169,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentDerivedTypeNotSetResolverShouldNotGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -1148,7 +1194,9 @@ void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1172,7 +1220,9 @@ End Namespace
[Fact]
public async Task XmlDocumentDerivedTypeWithNoSecureResolverShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -1191,7 +1241,9 @@ void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentSetInsecureResolverTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentSetInsecureResolverTests.cs
index 4a7a5fcded..dde8796d53 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentSetInsecureResolverTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlDocumentSetInsecureResolverTests.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 System.Threading.Tasks;
+using Microsoft.CodeAnalysis.Testing;
using Xunit;
using VerifyCS = Test.Utilities.CSharpSecurityCodeFixVerifier<
Microsoft.NetFramework.Analyzers.DoNotUseInsecureDtdProcessingAnalyzer,
@@ -16,7 +17,9 @@ public partial class DoNotUseInsecureDtdProcessingAnalyzerTests
[Fact]
public async Task Issue2753_CS_Diagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -36,7 +39,9 @@ private static void TestMethod(XmlResolver resolver)
[Fact]
public async Task Issue2753_VB_Diagnostic()
{
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Module SomeClass
@@ -51,7 +56,9 @@ End Sub
[Fact]
public async Task XmlDocumentNoCtorSetResolverToNullShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -66,7 +73,9 @@ private static void TestMethod(XmlDocument doc)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -81,7 +90,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorUseSecureResolverShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -96,7 +107,9 @@ private static void TestMethod(XmlDocument doc, XmlSecureResolver resolver)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -111,7 +124,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorUseSecureResolverWithPermissionsShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Net;
using System.Security;
using System.Security.Permissions;
@@ -136,7 +151,9 @@ private static void TestMethod(XmlDocument doc)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Net
Imports System.Security
Imports System.Security.Permissions
@@ -161,7 +178,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorSetResolverToNullInTryClauseShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -180,7 +199,9 @@ private static void TestMethod(XmlDocument doc)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -199,7 +220,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorUseNonSecureResolverInCatchClauseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -219,7 +242,9 @@ private static void TestMethod(XmlDocument doc)
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -240,7 +265,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorUseNonSecureResolverInFinallyClauseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -260,7 +287,9 @@ private static void TestMethod(XmlDocument doc)
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(13, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -282,7 +311,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorDoNotSetResolverShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -297,7 +328,9 @@ private static void TestMethod(XmlDocument doc, XmlReader reader)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -312,7 +345,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorUseNonSecureResolverShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -328,7 +363,9 @@ private static void TestMethod(XmlDocument doc)
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(10, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -345,7 +382,9 @@ End Class
[Fact]
public async Task XmlDocumentNoCtorUseNonSecureResolverInTryClauseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -365,7 +404,9 @@ private static void TestMethod(XmlDocument doc)
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -386,7 +427,9 @@ End Class
[Fact]
public async Task XmlDocumentDerivedTypeSetInsecureResolverShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -406,7 +449,9 @@ void TestMethod()
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(13, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -430,7 +475,9 @@ End Class
[Fact]
public async Task XmlDocumentCreatedAsTempSetResolverToNullShouldNotGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -447,7 +494,9 @@ public void Method2(XmlDocument doc){}
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -469,7 +518,9 @@ End Namespace"
[Fact]
public async Task XmlDocumentCreatedAsTempSetInsecureResolverShouldGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -488,7 +539,9 @@ public void Method2(XmlDocument doc){}
GetCA3075XmlDocumentWithNoSecureResolverCSharpResultAt(11, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs
index 19b16a190a..257fe9e85e 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlReaderCreateWrongOverloadTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075XmlReaderCreateWrongOverloadBasicResult
[Fact]
public async Task UseXmlReaderCreateWrongOverloadShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -39,7 +41,9 @@ private static void TestMethod()
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(10, 26)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -56,7 +60,9 @@ End Class
[Fact]
public async Task UseXmlReaderCreateInsecureOverloadInGetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -73,7 +79,9 @@ public XmlReader Test
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(10, 32)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -92,7 +100,9 @@ End Property
[Fact]
public async Task UseXmlReaderCreateInsecureOverloadInSetShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass1
@@ -112,7 +122,9 @@ public XmlReader Test
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(12, 26)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass1
@@ -134,7 +146,9 @@ End Property
[Fact]
public async Task UseXmlReaderCreateInsecureOverloadInTryShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -153,7 +167,9 @@ private void TestMethod()
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(11, 26)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -174,7 +190,9 @@ End Sub
[Fact]
public async Task UseXmlReaderCreateInsecureOverloadInCatchShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -192,7 +210,9 @@ private void TestMethod()
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(11, 26)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -212,7 +232,9 @@ End Sub
[Fact]
public async Task UseXmlReaderCreateInsecureOverloadInFinallyShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -230,7 +252,9 @@ private void TestMethod()
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(12, 26)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Imports System.Xml
@@ -251,7 +275,9 @@ End Sub
[Fact]
public async Task UseXmlReaderCreateInsecureOverloadInAsyncAwaitShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Threading.Tasks;
using System.Xml;
@@ -270,7 +296,9 @@ private async void TestMethod2()
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(9, 45)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Threading.Tasks
Imports System.Xml
@@ -293,7 +321,9 @@ End Sub
[Fact]
public async Task UseXmlReaderCreateInsecureOverloadInDelegateShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
class TestClass
@@ -305,7 +335,9 @@ class TestClass
GetCA3075XmlReaderCreateWrongOverloadCSharpResultAt(8, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Class TestClass
@@ -322,7 +354,9 @@ End Sub
[Fact]
public async Task UseXmlReaderCreateTextReaderOnlyOverloadShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Xml;
@@ -342,7 +376,9 @@ private static void TestMethod()
[Fact]
public async Task UseXmlReaderCreateStreamOnlyOverloadShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.IO;
using System.Text;
using System.Xml;
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs
index f0fa119fdf..e1f7846704 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderConstructedWithNoSecureResolutionTests.cs
@@ -25,7 +25,9 @@ private static DiagnosticResult GetCA3075XmlTextReaderConstructedWithNoSecureRes
[Fact]
public async Task StaticPropertyAssignmentShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
namespace TestNamespace
@@ -43,7 +45,9 @@ static SystemContext()
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System
Namespace TestNamespace
@@ -62,7 +66,9 @@ End Namespace
[Fact]
public async Task ConstructXmlTextReaderShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -79,7 +85,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(10, 36)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -96,7 +104,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -117,7 +127,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(11, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -139,7 +151,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -160,7 +174,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(12, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -181,7 +197,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -202,7 +220,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(13, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -224,7 +244,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderOnlySetResolverToSecureValueShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -242,7 +264,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(10, 36)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -260,7 +284,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetResolverToSecureValueInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -282,7 +308,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(11, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -305,7 +333,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetResolverToSecureValueInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -327,7 +357,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(12, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -349,7 +381,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetResolverToSecureValueInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -371,7 +405,9 @@ public void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(13, 40)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -394,7 +430,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderOnlySetDtdProcessingToSecureValueShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -411,7 +449,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -428,7 +468,9 @@ End Namespace"
[Fact]
public async Task ConstructXmlTextReaderSetDtdProcessingToSecureValueInTryBlockShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -449,7 +491,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -471,7 +515,9 @@ End Namespace"
[Fact]
public async Task ConstructXmlTextReaderSetDtdProcessingToSecureValueInCatchBlockShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -492,7 +538,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -513,7 +561,9 @@ End Namespace"
[Fact]
public async Task ConstructXmlTextReaderSetDtdProcessingToSecureValueInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -534,7 +584,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -556,7 +608,9 @@ End Namespace"
[Fact]
public async Task ConstructXmlTextReaderSetResolverAndDtdProcessingToSecureValuesShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -574,7 +628,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -591,7 +647,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetSetResolverAndDtdProcessingToSecureValueInTryBlockShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -613,7 +671,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -635,7 +695,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetSetResolverAndDtdProcessingToSecureValueInCatchBlockShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -657,7 +719,9 @@ public void TestMethod(string path)
"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -678,7 +742,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetSetResolverAndDtdProcessingToSecureValueInFinallyBlockShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -698,7 +764,9 @@ public void TestMethod(string path)
}
}
");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -722,7 +790,9 @@ End Namespace
[Fact]
public async Task ConstructXmlTextReaderSetResolverAndDtdProcessingToSecureValuesInInitializerShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -739,7 +809,9 @@ private static void TestMethod(string path)
}
}
}");
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -758,7 +830,9 @@ End Namespace
[Fact]
public async Task ConstructXmlTextReaderOnlySetResolverToSecureValueInInitializerShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -777,7 +851,9 @@ private static void TestMethod(string path)
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(10, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -796,7 +872,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderOnlySetDtdProcessingToSecureValueInInitializerShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -814,7 +892,9 @@ private static void TestMethod(string path)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -832,7 +912,9 @@ End Namespace"
[Fact]
public async Task ConstructXmlTextReaderAsFieldShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -845,7 +927,9 @@ class TestClass
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -860,7 +944,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderAsFieldSetBothToSecureValuesInInitializerShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -876,7 +962,9 @@ class TestClass
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -892,7 +980,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderAsFieldOnlySetResolverToSecureValuesInInitializerShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -908,7 +998,9 @@ class TestClass
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
@@ -926,7 +1018,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderAsFieldOnlySetDtdProcessingToSecureValuesInInitializerShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -941,7 +1035,9 @@ class TestClass
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -957,7 +1053,9 @@ End Namespace"
[Fact]
public async Task ConstructDefaultXmlTextReaderAsFieldSetBothToSecureValuesInMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -976,7 +1074,9 @@ public TestClass()
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -997,7 +1097,9 @@ End Namespace
[Fact]
public async Task ConstructXmlTextReaderAsFieldOnlySetResolverToSecureValueInMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -1015,7 +1117,9 @@ public TestClass()
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1034,7 +1138,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderAsFieldOnlySetResolverToSecureValueInMethodInTryBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -1057,7 +1163,9 @@ public void TestMethod()
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1081,7 +1189,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderAsFieldOnlySetResolverToSecureValueInMethodInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -1101,7 +1211,9 @@ public void TestMethod()
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1124,7 +1236,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderAsFieldOnlySetResolverToSecureValueInMethodInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -1144,7 +1258,9 @@ public void TestMethod()
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1168,7 +1284,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderAsFieldOnlySetDtdProcessingToSecureValueInMethodShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -1186,7 +1304,9 @@ public TestClass()
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(8, 39)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1205,7 +1325,9 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeWithNoSecureSettingsShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -1223,7 +1345,9 @@ void TestMethod()
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -1243,7 +1367,9 @@ End Class
[Fact]
public async Task XmlTextReaderCreatedAsTempNoSettingsShouldGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -1262,7 +1388,9 @@ public void Method2(XmlTextReader reader){}
GetCA3075XmlTextReaderConstructedWithNoSecureResolutionCSharpResultAt(11, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs
index 9f76ec8117..93b18d80f5 100644
--- a/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs
+++ b/src/NetAnalyzers/UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingXmlTextReaderSetInsecureResolutionTests.cs
@@ -23,7 +23,9 @@ private static DiagnosticResult GetCA3075XmlTextReaderSetInsecureResolutionBasic
[Fact]
public async Task UseXmlTextReaderNoCtorShouldNotGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -38,7 +40,9 @@ private static void TestMethod(XmlTextReader reader)
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -53,7 +57,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetResolverToNullShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -69,7 +75,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(10, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -86,7 +94,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetDtdProcessingToParseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -102,7 +112,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(10, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -119,7 +131,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetBothToInsecureValuesShouldGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -137,7 +151,9 @@ private static void TestMethod(XmlTextReader reader, XmlUrlResolver resolver)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(11, 13)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -156,7 +172,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetInSecureResolverInTryClauseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -176,7 +194,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -197,7 +217,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetInSecureResolverInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -215,7 +237,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(11, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -236,7 +260,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetInSecureResolverInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -254,7 +280,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(12, 23)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -276,7 +304,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetDtdprocessingToParseInTryClauseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -296,7 +326,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(12, 17)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -317,7 +349,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetDtdprocessingToParseInCatchBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -335,7 +369,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(11, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -356,7 +392,9 @@ End Class
[Fact]
public async Task XmlTextReaderNoCtorSetDtdprocessingToParseInFinallyBlockShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -374,7 +412,9 @@ private static void TestMethod(XmlTextReader reader)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(12, 23)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -396,7 +436,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetInsecureResolverInInitializerShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -415,7 +457,9 @@ private static void TestMethod(string path)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(10, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -434,7 +478,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetDtdProcessingParseInInitializerShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -453,7 +499,9 @@ private static void TestMethod(string path)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(10, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -472,7 +520,9 @@ End Class
[Fact]
public async Task ConstructXmlTextReaderSetBothToInsecureValuesInInitializerShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -492,7 +542,9 @@ private static void TestMethod(string path)
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(10, 33)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -512,7 +564,9 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetInsecureResolverShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -532,7 +586,9 @@ void TestMethod()
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(13, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -556,7 +612,9 @@ End Class
[Fact]
public async Task XmlTextReaderDerivedTypeSetDtdProcessingParseShouldGenerateDiagnostic()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System;
using System.Xml;
@@ -576,7 +634,9 @@ void TestMethod()
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(13, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -600,7 +660,9 @@ End Class
[Fact]
public async Task XmlTextReaderCreatedAsTempSetSecureSettingsShouldNotGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -618,7 +680,9 @@ public void Method2(XmlTextReader reader){}
}"
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -640,7 +704,9 @@ End Class
[Fact]
public async Task XmlTextReaderCreatedAsTempSetInsecureResolverShouldGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -659,7 +725,9 @@ public void Method2(XmlTextReader reader){}
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(11, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
@@ -684,7 +752,9 @@ End Namespace
[Fact]
public async Task XmlTextReaderCreatedAsTempSetDtdProcessingParseShouldGenerateDiagnostics()
{
- await VerifyCS.VerifyAnalyzerAsync(@"
+ await VerifyCSharpAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
using System.Xml;
namespace TestNamespace
@@ -703,7 +773,9 @@ public void Method2(XmlTextReader reader){}
GetCA3075XmlTextReaderSetInsecureResolutionCSharpResultAt(11, 21)
);
- await VerifyVB.VerifyAnalyzerAsync(@"
+ await VerifyVisualBasicAnalyzerAsync(
+ ReferenceAssemblies.NetFramework.Net472.Default,
+ @"
Imports System.Xml
Namespace TestNamespace
diff --git a/src/PerformanceSensitiveAnalyzers/UnitTests/Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.UnitTests.csproj b/src/PerformanceSensitiveAnalyzers/UnitTests/Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.UnitTests.csproj
index 398c0d9bd8..e1d0800b6c 100644
--- a/src/PerformanceSensitiveAnalyzers/UnitTests/Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.UnitTests.csproj
+++ b/src/PerformanceSensitiveAnalyzers/UnitTests/Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
$(NoWarn);xUnit1000;CA1812
diff --git a/src/PublicApiAnalyzers/UnitTests/DeclarePublicApiAnalyzerTests.cs b/src/PublicApiAnalyzers/UnitTests/DeclarePublicApiAnalyzerTests.cs
index 777a0d7c32..8b0155bf4b 100644
--- a/src/PublicApiAnalyzers/UnitTests/DeclarePublicApiAnalyzerTests.cs
+++ b/src/PublicApiAnalyzers/UnitTests/DeclarePublicApiAnalyzerTests.cs
@@ -715,14 +715,19 @@ public async Task TypeForwardsAreProcessed1()
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.StringComparison))]
";
+#if NETCOREAPP
+ var containingAssembly = "netstandard";
+#else
+ var containingAssembly = "mscorlib";
+#endif
string shippedText = $@"
-System.StringComparison (forwarded, contained in mscorlib)
-System.StringComparison.CurrentCulture = 0 -> System.StringComparison (forwarded, contained in mscorlib)
-System.StringComparison.CurrentCultureIgnoreCase = 1 -> System.StringComparison (forwarded, contained in mscorlib)
-System.StringComparison.InvariantCulture = 2 -> System.StringComparison (forwarded, contained in mscorlib)
-System.StringComparison.InvariantCultureIgnoreCase = 3 -> System.StringComparison (forwarded, contained in mscorlib)
-System.StringComparison.Ordinal = 4 -> System.StringComparison (forwarded, contained in mscorlib)
-System.StringComparison.OrdinalIgnoreCase = 5 -> System.StringComparison (forwarded, contained in mscorlib)
+System.StringComparison (forwarded, contained in {containingAssembly})
+System.StringComparison.CurrentCulture = 0 -> System.StringComparison (forwarded, contained in {containingAssembly})
+System.StringComparison.CurrentCultureIgnoreCase = 1 -> System.StringComparison (forwarded, contained in {containingAssembly})
+System.StringComparison.InvariantCulture = 2 -> System.StringComparison (forwarded, contained in {containingAssembly})
+System.StringComparison.InvariantCultureIgnoreCase = 3 -> System.StringComparison (forwarded, contained in {containingAssembly})
+System.StringComparison.Ordinal = 4 -> System.StringComparison (forwarded, contained in {containingAssembly})
+System.StringComparison.OrdinalIgnoreCase = 5 -> System.StringComparison (forwarded, contained in {containingAssembly})
";
string unshippedText = $@"";
@@ -735,22 +740,28 @@ public async Task TypeForwardsAreProcessed2()
var source = @"
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.StringComparer))]
";
+
+#if NETCOREAPP
+ var containingAssembly = "netstandard";
+#else
+ var containingAssembly = "mscorlib";
+#endif
string shippedText = $@"
-System.StringComparer (forwarded, contained in mscorlib)
-static System.StringComparer.InvariantCulture.get -> System.StringComparer (forwarded, contained in mscorlib)
-static System.StringComparer.InvariantCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
-static System.StringComparer.CurrentCulture.get -> System.StringComparer (forwarded, contained in mscorlib)
-static System.StringComparer.CurrentCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
-static System.StringComparer.Ordinal.get -> System.StringComparer (forwarded, contained in mscorlib)
-static System.StringComparer.OrdinalIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
-static System.StringComparer.Create(System.Globalization.CultureInfo culture, bool ignoreCase) -> System.StringComparer (forwarded, contained in mscorlib)
-System.StringComparer.Compare(object x, object y) -> int (forwarded, contained in mscorlib)
-System.StringComparer.Equals(object x, object y) -> bool (forwarded, contained in mscorlib)
-System.StringComparer.GetHashCode(object obj) -> int (forwarded, contained in mscorlib)
-abstract System.StringComparer.Compare(string x, string y) -> int (forwarded, contained in mscorlib)
-abstract System.StringComparer.Equals(string x, string y) -> bool (forwarded, contained in mscorlib)
-abstract System.StringComparer.GetHashCode(string obj) -> int (forwarded, contained in mscorlib)
-System.StringComparer.StringComparer() -> void (forwarded, contained in mscorlib)
+System.StringComparer (forwarded, contained in {containingAssembly})
+static System.StringComparer.InvariantCulture.get -> System.StringComparer (forwarded, contained in {containingAssembly})
+static System.StringComparer.InvariantCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in {containingAssembly})
+static System.StringComparer.CurrentCulture.get -> System.StringComparer (forwarded, contained in {containingAssembly})
+static System.StringComparer.CurrentCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in {containingAssembly})
+static System.StringComparer.Ordinal.get -> System.StringComparer (forwarded, contained in {containingAssembly})
+static System.StringComparer.OrdinalIgnoreCase.get -> System.StringComparer (forwarded, contained in {containingAssembly})
+static System.StringComparer.Create(System.Globalization.CultureInfo culture, bool ignoreCase) -> System.StringComparer (forwarded, contained in {containingAssembly})
+System.StringComparer.Compare(object x, object y) -> int (forwarded, contained in {containingAssembly})
+System.StringComparer.Equals(object x, object y) -> bool (forwarded, contained in {containingAssembly})
+System.StringComparer.GetHashCode(object obj) -> int (forwarded, contained in {containingAssembly})
+abstract System.StringComparer.Compare(string x, string y) -> int (forwarded, contained in {containingAssembly})
+abstract System.StringComparer.Equals(string x, string y) -> bool (forwarded, contained in {containingAssembly})
+abstract System.StringComparer.GetHashCode(string obj) -> int (forwarded, contained in {containingAssembly})
+System.StringComparer.StringComparer() -> void (forwarded, contained in {containingAssembly})
";
string unshippedText = $@"";
diff --git a/src/PublicApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.PublicApiAnalyzers.UnitTests.csproj b/src/PublicApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.PublicApiAnalyzers.UnitTests.csproj
index 340e05b2c7..d5bded7321 100644
--- a/src/PublicApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.PublicApiAnalyzers.UnitTests.csproj
+++ b/src/PublicApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.PublicApiAnalyzers.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
diff --git a/src/Roslyn.Diagnostics.Analyzers/UnitTests/Roslyn.Diagnostics.Analyzers.UnitTests.csproj b/src/Roslyn.Diagnostics.Analyzers/UnitTests/Roslyn.Diagnostics.Analyzers.UnitTests.csproj
index 5e671f342d..ab5295906a 100644
--- a/src/Roslyn.Diagnostics.Analyzers/UnitTests/Roslyn.Diagnostics.Analyzers.UnitTests.csproj
+++ b/src/Roslyn.Diagnostics.Analyzers/UnitTests/Roslyn.Diagnostics.Analyzers.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
diff --git a/src/Test.Utilities/AdditionalMetadataReferences.cs b/src/Test.Utilities/AdditionalMetadataReferences.cs
index 52e80aac40..557a49255e 100644
--- a/src/Test.Utilities/AdditionalMetadataReferences.cs
+++ b/src/Test.Utilities/AdditionalMetadataReferences.cs
@@ -9,33 +9,33 @@ namespace Test.Utilities
{
public static class AdditionalMetadataReferences
{
- public static ReferenceAssemblies Default { get; } = ReferenceAssemblies.Default
- .AddAssemblies(ImmutableArray.Create("System.Xml.Data"))
- .AddPackages(ImmutableArray.Create(new PackageIdentity("Microsoft.CodeAnalysis", "3.0.0")));
+ public static ReferenceAssemblies Default { get; } = CreateDefaultReferenceAssemblies();
public static ReferenceAssemblies DefaultWithoutRoslynSymbols { get; } = ReferenceAssemblies.Default
.AddAssemblies(ImmutableArray.Create("System.Xml.Data"))
.AddPackages(ImmutableArray.Create(new PackageIdentity("Microsoft.CodeAnalysis.Workspaces.Common", "3.0.0")));
- public static ReferenceAssemblies DefaultWithSystemWeb { get; } = Default
+ public static ReferenceAssemblies DefaultWithSystemWeb { get; } = ReferenceAssemblies.NetFramework.Net472.Default
.AddAssemblies(ImmutableArray.Create("System.Web", "System.Web.Extensions"));
- public static ReferenceAssemblies DefaultForTaintedDataAnalysis { get; } = Default
+ public static ReferenceAssemblies DefaultForTaintedDataAnalysis { get; } = ReferenceAssemblies.NetFramework.Net472.Default
.AddAssemblies(ImmutableArray.Create("PresentationFramework", "System.DirectoryServices", "System.Web", "System.Web.Extensions", "System.Xaml"))
.AddPackages(ImmutableArray.Create(new PackageIdentity("AntiXSS", "4.3.0")))
.AddPackages(ImmutableArray.Create(new PackageIdentity("Microsoft.AspNetCore.Mvc", "2.2.0")));
- public static ReferenceAssemblies DefaultWithSerialization { get; } = Default
+ public static ReferenceAssemblies DefaultWithSerialization { get; } = ReferenceAssemblies.NetFramework.Net472.Default
.AddAssemblies(ImmutableArray.Create("System.Runtime.Serialization"));
public static ReferenceAssemblies DefaultWithAzureStorage { get; } = ReferenceAssemblies.Default
.AddPackages(ImmutableArray.Create(new PackageIdentity("WindowsAzure.Storage", "9.0.0")));
- public static ReferenceAssemblies DefaultWithNewtonsoftJson { get; } = Default
+ public static ReferenceAssemblies DefaultWithNewtonsoftJson10 { get; } = Default
.AddPackages(ImmutableArray.Create(new PackageIdentity("Newtonsoft.Json", "10.0.1")));
- public static ReferenceAssemblies DefaultWithWinForms { get; } = Default
- .AddAssemblies(ImmutableArray.Create("System.Windows.Forms"));
+ public static ReferenceAssemblies DefaultWithNewtonsoftJson12 { get; } = Default
+ .AddPackages(ImmutableArray.Create(new PackageIdentity("Newtonsoft.Json", "12.0.1")));
+
+ public static ReferenceAssemblies DefaultWithWinForms { get; } = ReferenceAssemblies.NetFramework.Net472.WindowsForms;
public static ReferenceAssemblies DefaultWithWinHttpHandler { get; } = ReferenceAssemblies.NetStandard.NetStandard20
.AddPackages(ImmutableArray.Create(new PackageIdentity("System.Net.Http.WinHttpHandler", "4.7.0")));
@@ -65,13 +65,39 @@ public static class AdditionalMetadataReferences
public static MetadataReference CodeAnalysisReference { get; } = MetadataReference.CreateFromFile(typeof(Compilation).Assembly.Location);
public static MetadataReference CSharpSymbolsReference { get; } = MetadataReference.CreateFromFile(typeof(CSharpCompilation).Assembly.Location);
public static MetadataReference WorkspacesReference { get; } = MetadataReference.CreateFromFile(typeof(Workspace).Assembly.Location);
+#if !NETCOREAPP
public static MetadataReference SystemWebReference { get; } = MetadataReference.CreateFromFile(typeof(System.Web.HttpRequest).Assembly.Location);
public static MetadataReference SystemRuntimeSerialization { get; } = MetadataReference.CreateFromFile(typeof(System.Runtime.Serialization.NetDataContractSerializer).Assembly.Location);
+#endif
public static MetadataReference TestReferenceAssembly { get; } = MetadataReference.CreateFromFile(typeof(OtherDll.OtherDllStaticMethods).Assembly.Location);
public static MetadataReference SystemDirectoryServices { get; } = MetadataReference.CreateFromFile(typeof(System.DirectoryServices.DirectoryEntry).Assembly.Location);
+#if !NETCOREAPP
public static MetadataReference SystemXaml { get; } = MetadataReference.CreateFromFile(typeof(System.Xaml.XamlReader).Assembly.Location);
public static MetadataReference PresentationFramework { get; } = MetadataReference.CreateFromFile(typeof(System.Windows.Markup.XamlReader).Assembly.Location);
public static MetadataReference SystemWeb { get; } = MetadataReference.CreateFromFile(typeof(System.Web.HttpRequest).Assembly.Location);
public static MetadataReference SystemWebExtensions { get; } = MetadataReference.CreateFromFile(typeof(System.Web.Script.Serialization.JavaScriptSerializer).Assembly.Location);
+#endif
+
+ private static ReferenceAssemblies CreateDefaultReferenceAssemblies()
+ {
+ var referenceAssemblies = ReferenceAssemblies.Default;
+
+#if !NETCOREAPP
+ referenceAssemblies = referenceAssemblies.AddAssemblies(ImmutableArray.Create("System.Xml.Data"));
+#endif
+
+ referenceAssemblies = referenceAssemblies.AddPackages(ImmutableArray.Create(new PackageIdentity("Microsoft.CodeAnalysis", "3.0.0")));
+
+#if NETCOREAPP
+ referenceAssemblies = referenceAssemblies.AddPackages(ImmutableArray.Create(
+ new PackageIdentity("System.Runtime.Serialization.Formatters", "4.3.0"),
+ new PackageIdentity("System.Configuration.ConfigurationManager", "4.7.0"),
+ new PackageIdentity("System.Security.Cryptography.Cng", "4.7.0"),
+ new PackageIdentity("System.Security.Permissions", "4.7.0"),
+ new PackageIdentity("Microsoft.VisualBasic", "10.3.0")));
+#endif
+
+ return referenceAssemblies;
+ }
}
}
diff --git a/src/Test.Utilities/Test.Utilities.csproj b/src/Test.Utilities/Test.Utilities.csproj
index 4ff8d2c48d..b21e1815f4 100644
--- a/src/Test.Utilities/Test.Utilities.csproj
+++ b/src/Test.Utilities/Test.Utilities.csproj
@@ -1,27 +1,30 @@
- net472
+ netcoreapp3.1;net472
true
-
+
+
+
+
+
-
+
-
diff --git a/src/TestReferenceAssembly/TestReferenceAssembly.csproj b/src/TestReferenceAssembly/TestReferenceAssembly.csproj
index 1d8aea0622..192e2b6b06 100644
--- a/src/TestReferenceAssembly/TestReferenceAssembly.csproj
+++ b/src/TestReferenceAssembly/TestReferenceAssembly.csproj
@@ -1,7 +1,7 @@
- net46
+ netstandard2.0;net46
OtherDll
true
diff --git a/src/Text.Analyzers/UnitTests/Text.Analyzers.UnitTests.csproj b/src/Text.Analyzers/UnitTests/Text.Analyzers.UnitTests.csproj
index ad90d8bf18..57e4780574 100644
--- a/src/Text.Analyzers/UnitTests/Text.Analyzers.UnitTests.csproj
+++ b/src/Text.Analyzers/UnitTests/Text.Analyzers.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
diff --git a/src/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverter.UnitTests.csproj b/src/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverter.UnitTests.csproj
index 7498b7f1ed..07195f5a61 100644
--- a/src/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverter.UnitTests.csproj
+++ b/src/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverter.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
false
diff --git a/src/Utilities.UnitTests/Analyzer.Utilities.UnitTests.csproj b/src/Utilities.UnitTests/Analyzer.Utilities.UnitTests.csproj
index d33ee36852..badfbe3641 100644
--- a/src/Utilities.UnitTests/Analyzer.Utilities.UnitTests.csproj
+++ b/src/Utilities.UnitTests/Analyzer.Utilities.UnitTests.csproj
@@ -1,7 +1,8 @@
- net472
+ netcoreapp3.1;net472
+ true
true
diff --git a/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs b/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs
index 76ec4e729f..6488a5415c 100644
--- a/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs
+++ b/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs
@@ -1301,12 +1301,16 @@ protected static Project CreateProject(string[] sources)
.AddMetadataReferences(projectId, references)
.AddMetadataReference(projectId, AdditionalMetadataReferences.CodeAnalysisReference)
.AddMetadataReference(projectId, AdditionalMetadataReferences.WorkspacesReference)
+#if !NETCOREAPP
.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemWebReference)
.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemRuntimeSerialization)
+#endif
.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemDirectoryServices)
+#if !NETCOREAPP
.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemXaml)
.AddMetadataReference(projectId, AdditionalMetadataReferences.PresentationFramework)
.AddMetadataReference(projectId, AdditionalMetadataReferences.SystemWebExtensions)
+#endif
.WithProjectCompilationOptions(projectId, options)
.WithProjectParseOptions(projectId, null)
.GetProject(projectId);
diff --git a/src/Utilities/Compiler/Extensions/DiagnosticExtensions.cs b/src/Utilities/Compiler/Extensions/DiagnosticExtensions.cs
index 446e6be575..4e3218554c 100644
--- a/src/Utilities/Compiler/Extensions/DiagnosticExtensions.cs
+++ b/src/Utilities/Compiler/Extensions/DiagnosticExtensions.cs
@@ -119,7 +119,7 @@ public static Diagnostic CreateDiagnostic(
///
/// TODO: Revert this reflection based workaround once we move to Microsoft.CodeAnalysis version 3.0
///
- private static readonly PropertyInfo s_syntaxTreeDiagnosticOptionsProperty =
+ private static readonly PropertyInfo? s_syntaxTreeDiagnosticOptionsProperty =
typeof(SyntaxTree).GetTypeInfo().GetDeclaredProperty("DiagnosticOptions");
public static void ReportNoLocationDiagnostic(
@@ -164,7 +164,7 @@ public static void ReportNoLocationDiagnostic(
ReportDiagnostic? overriddenSeverity = null;
foreach (var tree in compilation.SyntaxTrees)
{
- var options = (ImmutableDictionary)s_syntaxTreeDiagnosticOptionsProperty.GetValue(tree);
+ var options = (ImmutableDictionary)s_syntaxTreeDiagnosticOptionsProperty.GetValue(tree)!;
if (options.TryGetValue(rule.Id, out var configuredValue))
{
if (configuredValue == ReportDiagnostic.Suppress)
diff --git a/src/Utilities/Compiler/NullableAttributes.cs b/src/Utilities/Compiler/NullableAttributes.cs
index 9695b92d56..b966380c6b 100644
--- a/src/Utilities/Compiler/NullableAttributes.cs
+++ b/src/Utilities/Compiler/NullableAttributes.cs
@@ -3,6 +3,8 @@
// This was copied from https://github.com/dotnet/coreclr/blob/60f1e6265bd1039f023a82e0643b524d6aaf7845/src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/NullableAttributes.cs
// and updated to have the scope of the attributes be internal.
+#if !NETCOREAPP
+
namespace System.Diagnostics.CodeAnalysis
{
/// Specifies that null is allowed as an input even if the corresponding type disallows it.
@@ -82,3 +84,5 @@ internal sealed class DoesNotReturnIfAttribute : Attribute
public bool ParameterValue { get; }
}
}
+
+#endif