Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersCodeFixTests.cs')
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersCodeFixTests.cs1126
1 files changed, 638 insertions, 488 deletions
diff --git a/test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersCodeFixTests.cs b/test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersCodeFixTests.cs
index 4eed3b026..1197135d8 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersCodeFixTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersCodeFixTests.cs
@@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Text;
using Xunit;
using VerifyCS = ILLink.RoslynAnalyzer.Tests.CSharpCodeFixVerifier<
ILLink.RoslynAnalyzer.DynamicallyAccessedMembersAnalyzer,
- ILLink.CodeFix.DAMCodeFixProvider>;
+ ILLink.CodeFix.DynamicallyAccessedMembersCodeFixProvider>;
namespace ILLink.RoslynAnalyzer.Tests
{
@@ -71,18 +71,22 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
- // The parameter 't' of method 'C.M(Type)' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsParameter)
- .WithSpan(7, 3, 7, 8)
- .WithSpan(6, 16, 6, 22)
- .WithArguments("t",
- "C.M2(Type)",
- "t",
- "C.M(Type)",
- "'DynamicallyAccessedMemberTypes.All'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
+ // The parameter 't' of method 'C.M(Type)' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsParameter)
+ .WithSpan(7, 3, 7, 8)
+ .WithSpan(6, 16, 6, 22)
+ .WithArguments("t",
+ "C.M2(Type)",
+ "t",
+ "C.M(Type)",
+ "'DynamicallyAccessedMemberTypes.All'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -121,18 +125,22 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
- // The parameter 't' of method 'C.M(Type)' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsParameter)
- .WithSpan(8, 3, 8, 8)
- .WithSpan(7, 18, 7, 24)
- .WithArguments("t",
- "C.M2(Type)",
- "t",
- "C.M(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
+ // The parameter 't' of method 'C.M(Type)' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsParameter)
+ .WithSpan(8, 3, 8, 8)
+ .WithSpan(7, 18, 7, 24)
+ .WithArguments("t",
+ "C.M2(Type)",
+ "t",
+ "C.M(Type)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -153,7 +161,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
+ // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
// The parameter 't' of method 'C.M(Type)' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsParameter)
@@ -163,7 +171,8 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
"C.M2(Type)",
"t",
"C.M(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.PublicFields'")};
+ "'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.PublicFields'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -185,8 +194,9 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
static void M2([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type t) {}
}
""";
+
var diag = new[] {
- // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
+ // /0/Test0.cs(7,3): warning IL2067: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'C.M2(Type)'.
// The parameter 't' of method 'C.M(Type)' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsParameter)
@@ -195,7 +205,8 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
"C.M2(Type)",
"t",
"C.M(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")};
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -228,15 +239,19 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(8,10): warning IL2068: 'C.M(Type)' method return value does not satisfy 'DynamicallyAccessedMemberTypes.All' requirements. The parameter 't' of method 'C.M(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsMethodReturnType)
- .WithSpan (8, 10, 8, 11)
- .WithSpan (7, 9, 7, 15)
- .WithArguments ("C.M(Type)",
- "t",
- "C.M(Type)",
- "'DynamicallyAccessedMemberTypes.All'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,10): warning IL2068: 'C.M(Type)' method return value does not satisfy 'DynamicallyAccessedMemberTypes.All' requirements. The parameter 't' of method 'C.M(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsMethodReturnType)
+ .WithSpan (8, 10, 8, 11)
+ .WithSpan (7, 9, 7, 15)
+ .WithArguments ("C.M(Type)",
+ "t",
+ "C.M(Type)",
+ "'DynamicallyAccessedMemberTypes.All'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -256,13 +271,14 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(8,10): warning IL2068: 'C.M(Type)' method return value does not satisfy 'DynamicallyAccessedMemberTypes.All' requirements. The parameter 't' of method 'C.M(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ // /0/Test0.cs(8,10): warning IL2068: 'C.M(Type)' method return value does not satisfy 'DynamicallyAccessedMemberTypes.All' requirements. The parameter 't' of method 'C.M(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsMethodReturnType)
.WithSpan (8, 10, 8, 11)
.WithArguments ("C.M(Type)",
"t",
"C.M(Type)",
- "'DynamicallyAccessedMemberTypes.All'")};
+ "'DynamicallyAccessedMemberTypes.All'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -310,17 +326,21 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
private static Type f = typeof(C);
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(13,3): warning IL2069: value stored in field 'C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- //The parameter 'type' of method 'C.M(Type)' does not have matching annotations.
- //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsField)
- .WithSpan(13, 3, 13, 11)
- .WithSpan(11, 24, 11, 33)
- .WithArguments ("C.f",
- "type",
- "C.M(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(13,3): warning IL2069: value stored in field 'C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ //The parameter 'type' of method 'C.M(Type)' does not have matching annotations.
+ //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsField)
+ .WithSpan(13, 3, 13, 11)
+ .WithSpan(11, 24, 11, 33)
+ .WithArguments ("C.f",
+ "type",
+ "C.M(Type)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -359,15 +379,19 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(12,3): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'. The parameter 't' of method 'C.M(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter)
- .WithSpan(12, 3, 12, 17)
- .WithSpan(10, 16, 10, 22)
- .WithArguments("System.Type.GetMethods()",
- "t",
- "C.M(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(12,3): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'. The parameter 't' of method 'C.M(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter)
+ .WithSpan(12, 3, 12, 17)
+ .WithSpan(10, 16, 10, 22)
+ .WithArguments("System.Type.GetMethods()",
+ "t",
+ "C.M(Type)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -409,22 +433,28 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(13,3): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'.
- // The parameter 't' of method 'C.M(Type)' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter)
- .WithSpan(13, 3, 13, 39)
- .WithSpan(11, 16, 11, 22)
- .WithArguments("System.Type.GetMethods(BindingFlags)",
- "t",
- "C.M(Type)",
- "'DynamicallyAccessedMemberTypes.NonPublicMethods'")}, new[] {
- // /0/Test0.cs(9,3): warning IL2111: Method 'C.M(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
- // Trimmer can't guarantee availability of the requirements of the method.
- VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMethodAccessedViaReflection)
- .WithSpan (9, 3, 9, 15)
- .WithArguments ("C.M(Type)") });
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(13,3): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'.
+ // The parameter 't' of method 'C.M(Type)' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter)
+ .WithSpan(13, 3, 13, 39)
+ .WithSpan(11, 16, 11, 22)
+ .WithArguments("System.Type.GetMethods(BindingFlags)",
+ "t",
+ "C.M(Type)",
+ "'DynamicallyAccessedMemberTypes.NonPublicMethods'")
+ },
+ fixedExpected: new[] {
+ // /0/Test0.cs(9,3): warning IL2111: Method 'C.M(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
+ // Trimmer can't guarantee availability of the requirements of the method.
+ VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMethodAccessedViaReflection)
+ .WithSpan (9, 3, 9, 15)
+ .WithArguments ("C.M(Type)")
+ });
}
[Fact]
@@ -470,17 +500,21 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(10,27): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
- // The parameter 't' of method 'System.C.Main(Type)' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter)
- .WithSpan(10, 27, 10, 41)
- .WithSpan(8, 20, 8, 26)
- .WithArguments("System.Type.GetMethods()",
- "t",
- "System.C.Main(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(10,27): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
+ // The parameter 't' of method 'System.C.Main(Type)' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter)
+ .WithSpan(10, 27, 10, 41)
+ .WithSpan(8, 20, 8, 26)
+ .WithArguments("System.Type.GetMethods()",
+ "t",
+ "System.C.Main(Type)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -534,18 +568,21 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(8,3): warning IL2072: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethodsOnParameter(Type)'.
- // The return value of method 'C.GetT()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
-
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2072: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethodsOnParameter(Type)'.
+ // The return value of method 'C.GetT()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsParameter)
.WithSpan(8, 3, 8, 40)
.WithSpan(16, 2, 19, 3)
.WithArguments("type",
"C.NeedsPublicMethodsOnParameter(Type)",
"C.GetC()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -599,17 +636,21 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(8,3): warning IL2072: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethodsOnParameter(Type)'.
- // The return value of method 'C.GetC(Type)' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsParameter)
- .WithSpan(8, 3, 8, 49)
- .WithSpan(16, 2, 19, 3)
- .WithArguments("t",
- "C.NeedsPublicMethodsOnParameter(Type)",
- "C.GetC(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2072: 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethodsOnParameter(Type)'.
+ // The return value of method 'C.GetC(Type)' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsParameter)
+ .WithSpan(8, 3, 8, 49)
+ .WithSpan(16, 2, 19, 3)
+ .WithArguments("t",
+ "C.NeedsPublicMethodsOnParameter(Type)",
+ "C.GetC(Type)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -643,13 +684,13 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
// /0/Test0.cs(8,3): warning IL2072: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethodsOnParameter(Type)'.
// The return value of method 'C.GetT()' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
-
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsParameter)
- .WithSpan(8, 3, 8, 40)
- .WithArguments("type",
- "C.NeedsPublicMethodsOnParameter(Type)",
- "C.GetC()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")};
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsParameter)
+ .WithSpan(8, 3, 8, 40)
+ .WithArguments("type",
+ "C.NeedsPublicMethodsOnParameter(Type)",
+ "C.GetC()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -672,7 +713,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
{
}
- [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)]
+ [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)]
private static Type GetT()
{
return typeof(C);
@@ -683,12 +724,13 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
// /0/Test0.cs(8,3): warning IL2072: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethodsOnParameter(Type)'.
// The return value of method 'C.GetT()' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsParameter)
- .WithSpan(8, 3, 8, 40)
- .WithArguments("type",
- "C.NeedsPublicMethodsOnParameter(Type)",
- "C.GetT()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")};
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsParameter)
+ .WithSpan(8, 3, 8, 40)
+ .WithArguments("type",
+ "C.NeedsPublicMethodsOnParameter(Type)",
+ "C.GetT()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -726,16 +768,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(11,10): warning IL2073: 'C.M()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The return value of method 'C.Main(Type)' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsMethodReturnType)
- .WithSpan(11, 10, 11, 25)
- .WithSpan(5, 2, 7, 3)
- .WithArguments("C.M()",
- "C.Main(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(11,10): warning IL2073: 'C.M()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The return value of method 'C.Main(Type)' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsMethodReturnType)
+ .WithSpan(11, 10, 11, 25)
+ .WithSpan(5, 2, 7, 3)
+ .WithArguments("C.M()",
+ "C.Main(Type)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> (), 2);
}
@@ -773,16 +819,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(11,10): warning IL2073: 'C.M(Type)' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The return value of method 'C.Main(Type)' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsMethodReturnType)
- .WithSpan(11, 10, 11, 17)
- .WithSpan(5, 2, 7, 3)
- .WithArguments("C.M(Type)",
- "C.Main(Type)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(11,10): warning IL2073: 'C.M(Type)' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The return value of method 'C.Main(Type)' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsMethodReturnType)
+ .WithSpan(11, 10, 11, 17)
+ .WithSpan(5, 2, 7, 3)
+ .WithArguments("C.M(Type)",
+ "C.Main(Type)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -830,16 +880,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
private static Type f;
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(8,3): warning IL2074: value stored in field 'C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The return value of method 'C.M()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsField)
- .WithSpan(8, 3, 8, 10)
- .WithSpan(11, 2, 14, 3)
- .WithArguments("C.f",
- "C.M()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2074: value stored in field 'C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The return value of method 'C.M()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsField)
+ .WithSpan(8, 3, 8, 10)
+ .WithSpan(11, 2, 14, 3)
+ .WithArguments("C.f",
+ "C.M()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> (), 1);
}
@@ -882,16 +936,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
- //The return value of method 'C.GetFoo()' does not have matching annotations.
- //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
- .WithSpan(8, 3, 8, 26)
- .WithSpan(11, 2, 14, 3)
- .WithArguments ("System.Type.GetMethod(String)",
- "C.GetC()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
+ //The return value of method 'C.GetFoo()' does not have matching annotations.
+ //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
+ .WithSpan(8, 3, 8, 26)
+ .WithSpan(11, 2, 14, 3)
+ .WithArguments ("System.Type.GetMethod(String)",
+ "C.GetC()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -935,17 +993,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest), new[] {
- // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
- //The return value of method 'C.GetFoo()' does not have matching annotations.
- //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
- .WithSpan(194, 4, 194, 27)
- .WithSpan(197, 3, 200, 4)
- .WithArguments("System.Type.GetMethod(String)",
- "System.C.GetC()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
+ //The return value of method 'C.GetFoo()' does not have matching annotations.
+ //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
+ .WithSpan(194, 4, 194, 27)
+ .WithSpan(197, 3, 200, 4)
+ .WithArguments("System.Type.GetMethod(String)",
+ "System.C.GetC()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -963,7 +1024,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
- private static Type GetC ()
+ private static Type GetC ()
{
return typeof(int);
}
@@ -989,17 +1050,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest), new[] {
- // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
- //The return value of method 'C.GetFoo()' does not have matching annotations.
- //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
- .WithSpan(193, 4, 193, 27)
- .WithSpan(196, 3, 200, 4)
- .WithArguments("System.Type.GetMethod(String)",
- "System.C.GetC()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
+ //The return value of method 'C.GetFoo()' does not have matching annotations.
+ //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
+ .WithSpan(193, 4, 193, 27)
+ .WithSpan(196, 3, 200, 4)
+ .WithArguments("System.Type.GetMethod(String)",
+ "System.C.GetC()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -1045,17 +1109,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest), new[] {
- // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
- //The return value of method 'C.GetFoo()' does not have matching annotations.
- //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
- .WithSpan(194, 4, 194, 27)
- .WithSpan(198, 3, 201, 4)
- .WithArguments("System.Type.GetMethod(String)",
- "System.C.GetC()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
+ //The return value of method 'C.GetFoo()' does not have matching annotations.
+ //The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic (DiagnosticId.DynamicallyAccessedMembersMismatchMethodReturnTypeTargetsThisParameter)
+ .WithSpan(194, 4, 194, 27)
+ .WithSpan(198, 3, 201, 4)
+ .WithArguments("System.Type.GetMethod(String)",
+ "System.C.GetC()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -1101,17 +1168,21 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(10,3): warning IL2077: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethods(Type)'.
- // The field 'C.f' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsParameter)
- .WithSpan(10, 3, 10, 24)
- .WithSpan(6, 22, 6, 35)
- .WithArguments("type",
- "C.NeedsPublicMethods(Type)",
- "C.f",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(10,3): warning IL2077: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethods(Type)'.
+ // The field 'C.f' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsParameter)
+ .WithSpan(10, 3, 10, 24)
+ .WithSpan(6, 22, 6, 35)
+ .WithArguments("type",
+ "C.NeedsPublicMethods(Type)",
+ "C.f",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -1140,9 +1211,9 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(11,3): warning IL2077: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethods(Type)'.
- // The field 'C.f' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ // /0/Test0.cs(11,3): warning IL2077: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.NeedsPublicMethods(Type)'.
+ // The field 'C.f' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsParameter)
.WithSpan(11, 3, 11, 24)
.WithArguments("type",
@@ -1185,16 +1256,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
private static Type f;
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(9,10): warning IL2078: 'C.Main()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The field 'C.f' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsMethodReturnType)
- .WithSpan(9, 10, 9, 11)
- .WithSpan(12, 22, 12, 23)
- .WithArguments("C.Main()",
- "C.f",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(9,10): warning IL2078: 'C.Main()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The field 'C.f' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsMethodReturnType)
+ .WithSpan(9, 10, 9, 11)
+ .WithSpan(12, 22, 12, 23)
+ .WithArguments("C.Main()",
+ "C.f",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -1218,9 +1293,9 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(9,10): warning IL2078: 'C.Main()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The field 'C.f' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ // /0/Test0.cs(9,10): warning IL2078: 'C.Main()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The field 'C.f' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsMethodReturnType)
.WithSpan(9, 10, 9, 11)
.WithArguments("C.Main()",
@@ -1266,16 +1341,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(13,3): warning IL2079: value stored in field 'C.f2' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The field 'C.f1' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsField)
- .WithSpan(13, 3, 13, 10)
- .WithSpan(6, 22, 6, 36)
- .WithArguments("C.f2",
- "C.f1",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(13,3): warning IL2079: value stored in field 'C.f2' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The field 'C.f1' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsField)
+ .WithSpan(13, 3, 13, 10)
+ .WithSpan(6, 22, 6, 36)
+ .WithArguments("C.f2",
+ "C.f1",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -1301,14 +1380,15 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(14,3): warning IL2079: value stored in field 'C.f2' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The field 'C.f1' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ // /0/Test0.cs(14,3): warning IL2079: value stored in field 'C.f2' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The field 'C.f1' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsField)
.WithSpan(14, 3, 14, 10)
.WithArguments("C.f2",
"C.f1",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")};
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -1344,16 +1424,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(10,3): warning IL2080: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
- // The field 'C.f' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsThisParameter)
- .WithSpan(10, 3, 10, 21)
- .WithSpan(6, 22, 6, 35)
- .WithArguments("System.Type.GetMethod(String)",
- "C.f",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(10,3): warning IL2080: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
+ // The field 'C.f' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsThisParameter)
+ .WithSpan(10, 3, 10, 21)
+ .WithSpan(6, 22, 6, 35)
+ .WithArguments("System.Type.GetMethod(String)",
+ "C.f",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -1389,16 +1473,20 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(10,3): warning IL2080: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
- // The field 'C.f' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsThisParameter)
- .WithSpan(10, 3, 10, 21)
- .WithSpan(6, 21, 6, 34)
- .WithArguments("System.Type.GetMethod(String)",
- "C.f",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(10,3): warning IL2080: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'.
+ // The field 'C.f' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsThisParameter)
+ .WithSpan(10, 3, 10, 21)
+ .WithSpan(6, 21, 6, 34)
+ .WithArguments("System.Type.GetMethod(String)",
+ "C.f",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -1428,7 +1516,8 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
.WithSpan(11, 3, 11, 21)
.WithArguments("System.Type.GetMethod(String)",
"C.f",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")};
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -1479,25 +1568,28 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
- new[] {
- // /0/Test0.cs(198,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
- // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsParameter)
- .WithSpan(198, 4, 198, 12)
- .WithSpan(196, 3, 199, 4)
- .WithArguments("t",
- "System.C.M2(Type)",
- "System.C.M1()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'") },
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(198,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
+ // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsParameter)
+ .WithSpan(198, 4, 198, 12)
+ .WithSpan(196, 3, 199, 4)
+ .WithArguments("t",
+ "System.C.M2(Type)",
+ "System.C.M1()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
+ fixedExpected: new[] {
// /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
// and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
.WithSpan(193, 4, 193, 16)
- .WithArguments("System.C.M1()")});
+ .WithArguments("System.C.M1()")
+ });
}
[Fact]
@@ -1551,25 +1643,28 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
- new[] {
- // /0/Test0.cs(198,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
- // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsParameter)
- .WithSpan(199, 4, 199, 12)
- .WithSpan(196, 3, 201, 4)
- .WithArguments("t",
- "System.C.M2(Type)",
- "System.C.M1()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'") },
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(198,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
+ // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsParameter)
+ .WithSpan(199, 4, 199, 12)
+ .WithSpan(196, 3, 201, 4)
+ .WithArguments("t",
+ "System.C.M2(Type)",
+ "System.C.M1()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
+ fixedExpected: new[] {
// /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
// and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
.WithSpan(193, 4, 193, 16)
- .WithArguments("System.C.M1()")});
+ .WithArguments("System.C.M1()")
+ });
}
[Fact]
@@ -1623,25 +1718,28 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
- new[] {
- // /0/Test0.cs(198,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
- // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsParameter)
- .WithSpan(199, 4, 199, 12)
- .WithSpan(196, 3, 201, 4)
- .WithArguments("t",
- "System.C.M2(Type)",
- "System.C.M1(String)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'") },
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(198,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
+ // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsParameter)
+ .WithSpan(199, 4, 199, 12)
+ .WithSpan(196, 3, 201, 4)
+ .WithArguments("t",
+ "System.C.M2(Type)",
+ "System.C.M1(String)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
+ fixedExpected: new[] {
// /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
// and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
.WithSpan(193, 4, 193, 21)
- .WithArguments("System.C.M1(String)")});
+ .WithArguments("System.C.M1(String)")
+ });
}
[Fact]
@@ -1670,20 +1768,21 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(199,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
- // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ // /0/Test0.cs(199,4): warning IL2082: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2(Type)'.
+ // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsParameter)
.WithSpan(199, 4, 199, 12)
.WithArguments("t",
"System.C.M2(Type)",
"System.C.M1()",
"'DynamicallyAccessedMemberTypes.PublicMethods'"),
- // /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
- // and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
- VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
- .WithSpan(193, 4, 193, 16)
- .WithArguments("System.C.M1()")};
+ // /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
+ // and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
+ VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
+ .WithSpan(193, 4, 193, 16)
+ .WithArguments("System.C.M1()")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test), diag, diag);
}
@@ -1729,22 +1828,25 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
- new[] {
- // /0/Test0.cs(199,11): warning IL2083: 'System.C.M1()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements. The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsMethodReturnType)
- .WithSpan(199, 11, 199, 15)
- .WithSpan(196, 3, 200, 4)
- .WithArguments("System.C.M1()",
- "System.C.M1()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'") },
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(199,11): warning IL2083: 'System.C.M1()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements. The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsMethodReturnType)
+ .WithSpan(199, 11, 199, 15)
+ .WithSpan(196, 3, 200, 4)
+ .WithArguments("System.C.M1()",
+ "System.C.M1()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
+ fixedExpected: new[] {
// /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
// and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
.WithSpan(193, 4, 193, 16)
- .WithArguments("System.C.M1()")});
+ .WithArguments("System.C.M1()")
+ });
}
[Fact]
@@ -1790,22 +1892,25 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
- new[] {
- // /0/Test0.cs(199,11): warning IL2083: 'System.C.M1()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements. The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsMethodReturnType)
- .WithSpan(200, 11, 200, 15)
- .WithSpan(196, 3, 201, 4)
- .WithArguments("System.C.M1(String)",
- "System.C.M1(String)",
- "'DynamicallyAccessedMemberTypes.PublicMethods'") },
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(199,11): warning IL2083: 'System.C.M1()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements. The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsMethodReturnType)
+ .WithSpan(200, 11, 200, 15)
+ .WithSpan(196, 3, 201, 4)
+ .WithArguments("System.C.M1(String)",
+ "System.C.M1(String)",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
+ fixedExpected: new[] {
// /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
// and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
.WithSpan(193, 4, 193, 21)
- .WithArguments("System.C.M1(String)")});
+ .WithArguments("System.C.M1(String)")
+ });
}
[Fact]
@@ -1837,11 +1942,12 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
.WithArguments("System.C.M1()",
"System.C.M1()",
"'DynamicallyAccessedMemberTypes.PublicMethods'"),
- // /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
- // and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
- VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
- .WithSpan(193, 4, 193, 16)
- .WithArguments("System.C.M1()")};
+ // /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
+ // and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
+ VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
+ .WithSpan(193, 4, 193, 16)
+ .WithArguments("System.C.M1()")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test), diag, diag);
}
@@ -1892,24 +1998,27 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
- new[] {
- // /0/Test0.cs(198,4): warning IL2084: value stored in field 'System.C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
- // The implicit 'this' argument of method 'System.C.M()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsField)
- .WithSpan(198, 4, 198, 12)
- .WithSpan(196, 3, 199, 4)
- .WithArguments("System.C.f",
- "System.C.M()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'") },
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(198,4): warning IL2084: value stored in field 'System.C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements.
+ // The implicit 'this' argument of method 'System.C.M()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsField)
+ .WithSpan(198, 4, 198, 12)
+ .WithSpan(196, 3, 199, 4)
+ .WithArguments("System.C.f",
+ "System.C.M()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
+ fixedExpected: new[] {
// /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M()' can not be statically determined
// and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
.WithSpan(193, 4, 193, 15)
- .WithArguments("System.C.M()")});
+ .WithArguments("System.C.M()")
+ });
}
[Fact]
@@ -1961,24 +2070,27 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
- string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
- new[] {
- // /0/Test0.cs(198,4): warning IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2()'.
- // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsThisParameter)
- .WithSpan(198, 4, 198, 13)
- .WithSpan(196, 3, 199, 4)
- .WithArguments("System.C.M2()",
- "System.C.M1()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
+ fixedSource: string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), fixtest),
+ baselineExpected: new[] {
+ // /0/Test0.cs(198,4): warning IL2085: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.C.M2()'.
+ // The implicit 'this' argument of method 'System.C.M1()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchThisParameterTargetsThisParameter)
+ .WithSpan(198, 4, 198, 13)
+ .WithSpan(196, 3, 199, 4)
+ .WithArguments("System.C.M2()",
+ "System.C.M1()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
+ fixedExpected: new[] {
// /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
// and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
.WithSpan(193, 4, 193, 16)
- .WithArguments("System.C.M1()")});
+ .WithArguments("System.C.M1()")
+ });
}
[Fact]
@@ -2016,11 +2128,12 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
.WithArguments("System.C.M2()",
"System.C.M1()",
"'DynamicallyAccessedMemberTypes.PublicMethods'"),
- // /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
- // and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
- VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
- .WithSpan(193, 4, 193, 16)
- .WithArguments("System.C.M1()")};
+ // /0/Test0.cs(193,4): warning IL2065: Value passed to implicit 'this' parameter of method 'System.C.M1()' can not be statically determined
+ // and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
+ VerifyCS.Diagnostic(DiagnosticId.ImplicitThisCannotBeStaticallyDetermined)
+ .WithSpan(193, 4, 193, 16)
+ .WithArguments("System.C.M1()")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test),
string.Concat (DynamicallyAccessedMembersAnalyzerTests.GetSystemTypeBase (), test), diag, diag);
}
@@ -2072,7 +2185,10 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
// /0/Test0.cs(18,3): warning IL2087: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'C.M1(Type)'.
// The generic parameter 'T' of 'C.M2<T>()' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
@@ -2083,7 +2199,8 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
"C.M1(Type)",
"T",
"C.M2<T>()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -2126,7 +2243,10 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
// /0/Test0.cs(14,10): warning IL2088: 'C.M<T>()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' requirements.
// The generic parameter 'T' of 'C.M<T>()' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
@@ -2136,7 +2256,8 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
.WithArguments("C.M<T>()",
"T",
"C.M<T>()",
- "'DynamicallyAccessedMemberTypes.PublicConstructors'")},
+ "'DynamicallyAccessedMemberTypes.PublicConstructors'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -2162,15 +2283,16 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(14,10): warning IL2088: 'C.M<T>()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' requirements.
- // The generic parameter 'T' of 'C.M<T>()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsMethodReturnType)
- .WithSpan(14, 10, 14, 19)
- .WithArguments("C.M<T>()",
- "T",
- "C.M<T>()",
- "'DynamicallyAccessedMemberTypes.PublicConstructors'")};
+ // /0/Test0.cs(14,10): warning IL2088: 'C.M<T>()' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' requirements.
+ // The generic parameter 'T' of 'C.M<T>()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsMethodReturnType)
+ .WithSpan(14, 10, 14, 19)
+ .WithArguments("C.M<T>()",
+ "T",
+ "C.M<T>()",
+ "'DynamicallyAccessedMemberTypes.PublicConstructors'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -2207,15 +2329,19 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
private static Type f;
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(8,3): warning IL2089: value stored in field 'C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements. The generic parameter 'T' of 'C.Main<T>()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsField)
- .WithSpan(8, 3, 8, 16)
- .WithSpan(6, 26, 6, 27)
- .WithArguments("C.f",
- "T",
- "C.Main<T>()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(8,3): warning IL2089: value stored in field 'C.f' does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' requirements. The generic parameter 'T' of 'C.Main<T>()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsField)
+ .WithSpan(8, 3, 8, 16)
+ .WithSpan(6, 26, 6, 27)
+ .WithArguments("C.f",
+ "T",
+ "C.Main<T>()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -2244,7 +2370,8 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
.WithArguments("C.f",
"T",
"C.Main<T>()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")};
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -2276,8 +2403,10 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest,
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
// /0/Test0.cs(8,3): warning IL2090: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
// The generic parameter 'T' of 'C<T>' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
@@ -2306,18 +2435,18 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, test,
- new[] {
- // /0/Test0.cs(8,3): warning IL2090: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
- // The generic parameter 'T' of 'C<T>' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsThisParameter)
- .WithSpan(8, 3, 8, 25)
- .WithArguments("System.Type.GetMethods()",
- "T",
- "C<T>",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
- fixedExpected: Array.Empty<DiagnosticResult> ());
+ var diag = new[] {
+ // /0/Test0.cs(8,3): warning IL2090: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
+ // The generic parameter 'T' of 'C<T>' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsThisParameter)
+ .WithSpan(8, 3, 8, 25)
+ .WithArguments("System.Type.GetMethods()",
+ "T",
+ "C<T>",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
+ await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
[Fact]
@@ -2335,18 +2464,18 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, test,
- new[] {
- // /0/Test0.cs(8,3): warning IL2090: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
- // The generic parameter 'T' of 'C<T>' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsThisParameter)
- .WithSpan(8, 3, 8, 25)
- .WithArguments("System.Type.GetMethods()",
- "T",
- "C<T>",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
- fixedExpected: Array.Empty<DiagnosticResult> ());
+ var diag = new[] {
+ // /0/Test0.cs(8,3): warning IL2090: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
+ // The generic parameter 'T' of 'C<T>' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsThisParameter)
+ .WithSpan(8, 3, 8, 25)
+ .WithArguments("System.Type.GetMethods()",
+ "T",
+ "C<T>",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
+ await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
[Fact]
@@ -2392,8 +2521,10 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest,
- new[] {
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
// /0/Test0.cs(16,3): warning IL2091: 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in 'C.M1<T>()'.
// The generic parameter 'S' of 'C.M2<S>()' does not have matching annotations.
// The source value must declare at least the same requirements as those declared on the target location it is assigned to.
@@ -2404,7 +2535,8 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
"C.M1<T>()",
"S",
"C.M2<S>()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")},
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -2432,16 +2564,17 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(16,3): warning IL2091: 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in 'C.M1<T>()'.
- // The generic parameter 'S' of 'C.M2<S>()' does not have matching annotations.
- // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsGenericParameter)
- .WithSpan(16, 3, 16, 8)
- .WithArguments("T",
- "C.M1<T>()",
- "S",
- "C.M2<S>()",
- "'DynamicallyAccessedMemberTypes.PublicMethods'")};
+ // /0/Test0.cs(16,3): warning IL2091: 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in 'C.M1<T>()'.
+ // The generic parameter 'S' of 'C.M2<S>()' does not have matching annotations.
+ // The source value must declare at least the same requirements as those declared on the target location it is assigned to.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchTypeArgumentTargetsGenericParameter)
+ .WithSpan(16, 3, 16, 8)
+ .WithArguments("T",
+ "C.M1<T>()",
+ "S",
+ "C.M2<S>()",
+ "'DynamicallyAccessedMemberTypes.PublicMethods'")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -2483,10 +2616,10 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(11,30): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
- // don't match overridden parameter 't' of method 'Base.M(Type)'.
- // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
+ // /0/Test0.cs(11,30): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
+ // don't match overridden parameter 't' of method 'Base.M(Type)'.
+ // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
.WithSpan(11, 30, 11, 31)
.WithSpan(11, 30, 11, 31)
.WithArguments("t",
@@ -2535,17 +2668,21 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
- // don't match overridden parameter 't' of method 'Base.M(Type)'.
- // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
- .WithSpan(11, 108, 11, 109)
- .WithSpan(6, 29, 6, 30)
- .WithArguments("t",
- "C.M(Type)",
- "t",
- "Base.M(Type)") },
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
+ // don't match overridden parameter 't' of method 'Base.M(Type)'.
+ // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
+ .WithSpan(11, 108, 11, 109)
+ .WithSpan(6, 29, 6, 30)
+ .WithArguments("t",
+ "C.M(Type)",
+ "t",
+ "Base.M(Type)")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -2571,15 +2708,16 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
- // don't match overridden parameter 't' of method 'Base.M(Type)'.
- // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
+ // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
+ // don't match overridden parameter 't' of method 'Base.M(Type)'.
+ // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
.WithSpan(11, 108, 11, 109)
.WithArguments("t",
"C.M(Type)",
"t",
- "Base.M(Type)") };
+ "Base.M(Type)")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -2605,16 +2743,17 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
- // don't match overridden parameter 't' of method 'Base.M(Type)'.
- // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
+ // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
+ // don't match overridden parameter 't' of method 'Base.M(Type)'.
+ // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
.WithSpan(11, 30, 11, 31)
.WithSpan(11, 30, 11, 31)
.WithArguments("t",
"C.M(Type)",
"t",
- "Base.M(Type)") };
+ "Base.M(Type)")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -2640,15 +2779,16 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
- // don't match overridden parameter 't' of method 'Base.M(Type)'.
- // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
+ // /0/Test0.cs(11,108): warning IL2092: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 't' of method 'C.M(Type)'
+ // don't match overridden parameter 't' of method 'Base.M(Type)'.
+ // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodParameterBetweenOverrides)
.WithSpan(11, 108, 11, 109)
.WithArguments("t",
"C.M(Type)",
"t",
- "Base.M(Type)") };
+ "Base.M(Type)")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -2662,7 +2802,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
public class Base
{
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)]
- public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
+ public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
return t;
}
}
@@ -2684,7 +2824,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
public class Base
{
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)]
- public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
+ public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
return t;
}
}
@@ -2700,15 +2840,19 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(14,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
- // don't match overridden return value of method 'Base.M(Type)'.
- // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodReturnValueBetweenOverrides)
- .WithSpan(14, 23, 14, 24)
- .WithSpan(14, 23, 14, 24)
- .WithArguments("C.M(Type)",
- "Base.M(Type)")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(14,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
+ // don't match overridden return value of method 'Base.M(Type)'.
+ // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodReturnValueBetweenOverrides)
+ .WithSpan(14, 23, 14, 24)
+ .WithSpan(14, 23, 14, 24)
+ .WithArguments("C.M(Type)",
+ "Base.M(Type)")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -2721,7 +2865,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
public class Base
{
- public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
+ public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
return t;
}
}
@@ -2760,15 +2904,19 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
}
""";
- await VerifyDynamicallyAccessedMembersCodeFix (test, fixtest, new[] {
- // /0/Test0.cs(14,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
- // don't match overridden return value of method 'Base.M(Type)'.
- // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
- VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodReturnValueBetweenOverrides)
- .WithSpan(14, 23, 14, 24)
- .WithSpan(6, 25, 6, 26)
- .WithArguments("C.M(Type)",
- "Base.M(Type)")},
+ await VerifyDynamicallyAccessedMembersCodeFix (
+ source: test,
+ fixedSource: fixtest,
+ baselineExpected: new[] {
+ // /0/Test0.cs(14,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
+ // don't match overridden return value of method 'Base.M(Type)'.
+ // All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
+ VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodReturnValueBetweenOverrides)
+ .WithSpan(14, 23, 14, 24)
+ .WithSpan(6, 22, 6, 23)
+ .WithArguments("C.M(Type)",
+ "Base.M(Type)")
+ },
fixedExpected: Array.Empty<DiagnosticResult> ());
}
@@ -2782,7 +2930,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
public class Base
{
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]
- public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
+ public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
return t;
}
}
@@ -2799,13 +2947,14 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(15,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
+ // /0/Test0.cs(15,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
// don't match overridden return value of method 'Base.M(Type)'.
// All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodReturnValueBetweenOverrides)
.WithSpan(15, 23, 15, 24)
.WithArguments("C.M(Type)",
- "Base.M(Type)")};
+ "Base.M(Type)")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
@@ -2819,7 +2968,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
public class Base
{
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.None)]
- public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
+ public virtual Type M([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type t) {
return t;
}
}
@@ -2836,13 +2985,14 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
}
""";
var diag = new[] {
- // /0/Test0.cs(15,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
+ // /0/Test0.cs(15,23): warning IL2093: 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'C.M(Type)'
// don't match overridden return value of method 'Base.M(Type)'.
// All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
VerifyCS.Diagnostic(DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodReturnValueBetweenOverrides)
.WithSpan(15, 23, 15, 24)
.WithArguments("C.M(Type)",
- "Base.M(Type)")};
+ "Base.M(Type)")
+ };
await VerifyDynamicallyAccessedMembersCodeFix (test, test, diag, diag);
}
}