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:
authorJackson Schuster <36744439+jtschuster@users.noreply.github.com>2021-12-14 20:59:41 +0300
committerGitHub <noreply@github.com>2021-12-14 20:59:41 +0300
commit779dacee7c24795017190df9ea017b93813028e2 (patch)
tree319faf992f69e312e61508a7ae646cbd97abc617
parentc0163348df53e676c475dc7593cdedb9194da784 (diff)
parent49fc988809a64e7cef3de39e7e28e512b9d92c31 (diff)
Merge pull request #2408 from jtschuster/bug/2379
Fix Bug 2379
-rw-r--r--src/ILLink.RoslynAnalyzer/COMAnalyzer.cs4
-rw-r--r--src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs28
-rw-r--r--src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs47
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs1
-rw-r--r--test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs4
-rw-r--r--test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs128
6 files changed, 181 insertions, 31 deletions
diff --git a/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs b/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs
index 8e7dfe82c..6f153aa76 100644
--- a/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs
+++ b/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs
@@ -18,6 +18,7 @@ namespace ILLink.RoslynAnalyzer
private const string StructLayoutAttribute = nameof (StructLayoutAttribute);
private const string DllImportAttribute = nameof (DllImportAttribute);
private const string MarshalAsAttribute = nameof (MarshalAsAttribute);
+ private const string RequiresUnreferencedCodeAttribute = nameof (RequiresUnreferencedCodeAttribute);
static readonly DiagnosticDescriptor s_correctnessOfCOMCannotBeGuaranteed = DiagnosticDescriptors.GetDiagnosticDescriptor (DiagnosticId.CorrectnessOfCOMCannotBeGuaranteed,
helpLinkUri: "https://docs.microsoft.com/en-us/dotnet/core/deploying/trim-warnings/il2050");
@@ -39,6 +40,9 @@ namespace ILLink.RoslynAnalyzer
if (!targetMethod.HasAttribute (DllImportAttribute))
return;
+ if (operationContext.ContainingSymbol.IsInRequiresScope (RequiresUnreferencedCodeAttribute))
+ return;
+
bool comDangerousMethod = IsComInterop (targetMethod.ReturnType);
foreach (var parameter in targetMethod.Parameters) {
comDangerousMethod |= IsComInterop (parameter);
diff --git a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
index ff0c5c346..b9032ee22 100644
--- a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
+++ b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
@@ -220,7 +220,7 @@ namespace ILLink.RoslynAnalyzer
ISymbol containingSymbol = FindContainingSymbol (operationContext, AnalyzerDiagnosticTargets);
// Do not emit any diagnostic if caller is annotated with the attribute too.
- if (IsMemberInRequiresScope (containingSymbol))
+ if (containingSymbol.IsInRequiresScope (RequiresAttributeName))
return;
if (ReportSpecialIncompatibleMembersDiagnostic (operationContext, incompatibleMembers, member))
@@ -335,25 +335,11 @@ namespace ILLink.RoslynAnalyzer
message));
}
- private bool HasMismatchingAttributes (ISymbol member1, ISymbol member2) => member1.HasAttribute (RequiresAttributeName) ^ member2.HasAttribute (RequiresAttributeName);
-
- // TODO: Consider sharing with linker IsMethodInRequiresUnreferencedCodeScope method
- /// <summary>
- /// True if the source of a call is considered to be annotated with the Requires... attribute
- /// </summary>
- protected bool IsMemberInRequiresScope (ISymbol member)
+ private bool HasMismatchingAttributes (ISymbol member1, ISymbol member2)
{
- if (member.HasAttribute (RequiresAttributeName) ||
- (member is not ITypeSymbol &&
- member.ContainingType.HasAttribute (RequiresAttributeName))) {
- return true;
- }
-
- // Check also for RequiresAttribute in the associated symbol
- if (member is IMethodSymbol { AssociatedSymbol: { } associated } && associated.HasAttribute (RequiresAttributeName))
- return true;
-
- return false;
+ bool member1HasAttribute = member1.IsOverrideInRequiresScope (RequiresAttributeName);
+ bool member2HasAttribute = member2.IsOverrideInRequiresScope (RequiresAttributeName);
+ return member1HasAttribute ^ member2HasAttribute;
}
// TODO: Consider sharing with linker DoesMethodRequireUnreferencedCode method
@@ -372,7 +358,7 @@ namespace ILLink.RoslynAnalyzer
}
// Also check the containing type
- if ((member.IsStatic || member.IsConstructor ()) && member is not ITypeSymbol) {
+ if (member.IsStatic || member.IsConstructor ()) {
return TryGetRequiresAttribute (member.ContainingType, out requiresAttribute);
}
return false;
@@ -441,4 +427,4 @@ namespace ILLink.RoslynAnalyzer
/// <returns>True if the requirements to run the analyzer are met; otherwise, returns false</returns>
protected abstract bool IsAnalyzerEnabled (AnalyzerOptions options, Compilation compilation);
}
-} \ No newline at end of file
+}
diff --git a/src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs b/src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs
new file mode 100644
index 000000000..24f8a0623
--- /dev/null
+++ b/src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using Microsoft.CodeAnalysis;
+
+namespace ILLink.RoslynAnalyzer
+{
+ public static class RequiresISymbolExtensions
+ {
+ // TODO: Consider sharing with linker IsMethodInRequiresUnreferencedCodeScope method
+ /// <summary>
+ /// True if the source of a call is considered to be annotated with the Requires... attribute
+ /// </summary>
+ public static bool IsInRequiresScope (this ISymbol member, string requiresAttribute)
+ {
+ return member.IsInRequiresScope (requiresAttribute, true);
+ }
+
+ /// <summary>
+ /// True if member of a call is considered to be annotated with the Requires... attribute.
+ /// Doesn't check the associated symbol for overrides and virtual methods because the analyzer should warn on mismatched between the property AND the accessors
+ /// </summary>
+ /// <param name="containingSymbol">
+ /// Symbol that is either an overriding member or an overriden/virtual member
+ /// </param>
+ public static bool IsOverrideInRequiresScope (this ISymbol member, string requiresAttribute)
+ {
+ return member.IsInRequiresScope (requiresAttribute, false);
+ }
+
+ private static bool IsInRequiresScope (this ISymbol member, string requiresAttribute, bool checkAssociatedSymbol)
+ {
+ if (member is ISymbol containingSymbol) {
+ if (containingSymbol.HasAttribute (requiresAttribute)
+ || (containingSymbol is not ITypeSymbol &&
+ containingSymbol.ContainingType.HasAttribute (requiresAttribute))) {
+ return true;
+ }
+ }
+ // Only check associated symbol if not override or virtual method
+ if (checkAssociatedSymbol && member is IMethodSymbol { AssociatedSymbol: { } associated } && associated.HasAttribute (requiresAttribute))
+ return true;
+
+ return false;
+ }
+ }
+}
diff --git a/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs b/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs
index d2f8bf64d..501ba16f9 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using ILLink.RoslynAnalyzer;
using ILLink.Shared;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
diff --git a/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs b/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs
index c652f26fd..d64847908 100644
--- a/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs
+++ b/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs
@@ -156,8 +156,6 @@ namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Warnings
static extern IFoo CanSuppressWarningOnReturnType ();
[RequiresUnreferencedCode ("test")]
- // Bug https://github.com/dotnet/linker/issues/2378
- [ExpectedWarning ("IL2050", ProducedBy = ProducedBy.Analyzer)]
static void Call_CanSuppressWithRequiresUnreferencedCode ()
{
CanSuppressWithRequiresUnreferencedCode (null);
@@ -167,8 +165,6 @@ namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Warnings
static extern void CanSuppressWithRequiresUnreferencedCode (IFoo foo);
[RequiresUnreferencedCode ("test")]
- // Bug https://github.com/dotnet/linker/issues/2378
- [ExpectedWarning ("IL2050", ProducedBy = ProducedBy.Analyzer)]
static void Call_CanSuppressPInvokeWithRequiresUnreferencedCode ()
{
CanSuppressPInvokeWithRequiresUnreferencedCode (null);
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
index 12f0004e0..cafe09aba 100644
--- a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
+++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
@@ -934,6 +934,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[RequiresAssemblyFiles ("Message")]
public virtual string VirtualPropertyAnnotationInProperty { get; set; }
+
+ [RequiresAssemblyFiles ("Message")]
+ public virtual string VirtualPropertyAnnotationInPropertyAndAccessor {
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ get;
+ set;
+ }
}
class BaseClassWithoutRequires
@@ -990,6 +998,64 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL3003", "DerivedClassWithoutRequires.VirtualPropertyAnnotationInProperty", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
public override string VirtualPropertyAnnotationInProperty { get; set; }
+
+ [ExpectedWarning ("IL3003", "DerivedClassWithoutRequires.VirtualPropertyAnnotationInPropertyAndAccessor", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor", ProducedBy = ProducedBy.Analyzer)]
+ public override string VirtualPropertyAnnotationInPropertyAndAccessor {
+ [ExpectedWarning ("IL2046", "VirtualPropertyAnnotationInPropertyAndAccessor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithoutRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get", ProducedBy = ProducedBy.Analyzer)]
+ get;
+ set;
+ }
+ }
+
+ class DerivedClassWithAllWarnings : BaseClassWithRequires
+ {
+ [ExpectedWarning ("IL2046", "DerivedClassWithAllWarnings.VirtualMethod()", "BaseClassWithRequires.VirtualMethod()")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualMethod()", "BaseClassWithRequires.VirtualMethod()", ProducedBy = ProducedBy.Analyzer)]
+ public override void VirtualMethod ()
+ {
+ }
+
+ private string name;
+
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInAccesor", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor", ProducedBy = ProducedBy.Analyzer)]
+ public override string VirtualPropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInAccesor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInAccesor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ get { return name; }
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ [ExpectedWarning ("IL2046", "VirtualPropertyAnnotationInAccesor.set", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.set")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInAccesor.set", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.set", ProducedBy = ProducedBy.Analyzer)]
+ set { name = value; }
+ }
+
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInProperty", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ public override string VirtualPropertyAnnotationInProperty {
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ [ExpectedWarning ("IL2046", "VirtualPropertyAnnotationInProperty.get", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty.get")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInProperty.get", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty.get", ProducedBy = ProducedBy.Analyzer)]
+ get;
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ [ExpectedWarning ("IL2046", "VirtualPropertyAnnotationInProperty.set", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty.set")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInProperty.set", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty.set", ProducedBy = ProducedBy.Analyzer)]
+ set;
+ }
+
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInPropertyAndAccessor", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor", ProducedBy = ProducedBy.Analyzer)]
+ public override string VirtualPropertyAnnotationInPropertyAndAccessor {
+ [ExpectedWarning ("IL2046", "VirtualPropertyAnnotationInPropertyAndAccessor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInPropertyAndAccessor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get", ProducedBy = ProducedBy.Analyzer)]
+ get;
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ [ExpectedWarning ("IL2046", "VirtualPropertyAnnotationInPropertyAndAccessor.set", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.set")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInPropertyAndAccessor.set", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.set", ProducedBy = ProducedBy.Analyzer)]
+ set;
+ }
}
public interface IBaseWithRequires
@@ -1007,6 +1073,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[RequiresAssemblyFiles ("Message")]
string PropertyAnnotationInProperty { get; set; }
+
+ [RequiresAssemblyFiles ("Message")]
+ string PropertyAnnotationInPropertyAndAccessor {
+ get;
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ set;
+ }
}
public interface IBaseWithoutRequires
@@ -1016,6 +1090,8 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
string PropertyAnnotationInAccesor { get; set; }
string PropertyAnnotationInProperty { get; set; }
+
+ string PropertyAnnotationInPropertyAndAccessor { get; set; }
}
class ImplementationClassWithRequires : IBaseWithoutRequires
@@ -1041,6 +1117,17 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[RequiresAssemblyFiles ("Message")]
[ExpectedWarning ("IL3003", "ImplementationClassWithRequires.PropertyAnnotationInProperty", "IBaseWithoutRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
public string PropertyAnnotationInProperty { get; set; }
+
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequires.PropertyAnnotationInPropertyAndAccessor", "IBaseWithoutRequires.PropertyAnnotationInPropertyAndAccessor", ProducedBy = ProducedBy.Analyzer)]
+ public string PropertyAnnotationInPropertyAndAccessor {
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ [ExpectedWarning ("IL2046", "ImplementationClassWithRequires.PropertyAnnotationInPropertyAndAccessor.get", "IBaseWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequires.PropertyAnnotationInPropertyAndAccessor.get", "IBaseWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get", ProducedBy = ProducedBy.Analyzer)]
+ get;
+ set;
+ }
}
class ExplicitImplementationClassWithRequires : IBaseWithoutRequires
@@ -1066,6 +1153,17 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[RequiresAssemblyFiles ("Message")]
[ExpectedWarning ("IL3003", "ExplicitImplementationClassWithRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithoutRequires.PropertyAnnotationInProperty", "IBaseWithoutRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
string IBaseWithoutRequires.PropertyAnnotationInProperty { get; set; }
+
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL3003", "PropertyAnnotationInPropertyAndAccessor", "IBaseWithoutRequires.PropertyAnnotationInPropertyAndAccessor", ProducedBy = ProducedBy.Analyzer)]
+ string IBaseWithoutRequires.PropertyAnnotationInPropertyAndAccessor {
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ [ExpectedWarning ("IL2046", "PropertyAnnotationInPropertyAndAccessor.get", "IBaseWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get")]
+ [ExpectedWarning ("IL3003", "PropertyAnnotationInPropertyAndAccessor.get", "IBaseWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get", ProducedBy = ProducedBy.Analyzer)]
+ get;
+ set;
+ }
}
class ImplementationClassWithoutRequires : IBaseWithRequires
@@ -1086,6 +1184,18 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL3003", "ImplementationClassWithoutRequires.PropertyAnnotationInProperty", "IBaseWithRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
public string PropertyAnnotationInProperty { get; set; }
+
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequires.PropertyAnnotationInPropertyAndAccessor", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor", ProducedBy = ProducedBy.Analyzer)]
+ public string PropertyAnnotationInPropertyAndAccessor {
+ [RequiresAssemblyFiles ("Message")]
+ [RequiresUnreferencedCode ("Message")]
+ [ExpectedWarning ("IL2046", "ImplementationClassWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.get")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.get", ProducedBy = ProducedBy.Analyzer)]
+ get;
+ [ExpectedWarning ("IL2046", "ImplementationClassWithoutRequires.PropertyAnnotationInPropertyAndAccessor.set", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.set")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequires.PropertyAnnotationInPropertyAndAccessor.set", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.set", ProducedBy = ProducedBy.Analyzer)]
+ set;
+ }
}
class ExplicitImplementationClassWithoutRequires : IBaseWithRequires
@@ -1106,6 +1216,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL3003", "ExplicitImplementationClassWithoutRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithRequires.PropertyAnnotationInProperty", "IBaseWithRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
string IBaseWithRequires.PropertyAnnotationInProperty { get; set; }
+
+ [ExpectedWarning ("IL3003", "ExplicitImplementationClassWithoutRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor", ProducedBy = ProducedBy.Analyzer)]
+ string IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor {
+ get;
+ [ExpectedWarning ("IL2046", "PropertyAnnotationInPropertyAndAccessor.set", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.set")]
+ [ExpectedWarning ("IL3003", "PropertyAnnotationInPropertyAndAccessor.set", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.set", ProducedBy = ProducedBy.Analyzer)]
+ set;
+ }
}
class ImplementationClassWithoutRequiresInSource : ReferenceInterfaces.IBaseWithRequiresInReference
@@ -1157,12 +1275,16 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualMethod()", ProducedBy = ProducedBy.Trimmer)]
[ExpectedWarning ("IL2026", "IBaseWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Trimmer)]
[ExpectedWarning ("IL2026", "IBaseWithRequires.Method()", ProducedBy = ProducedBy.Trimmer)]
+ [ExpectedWarning ("IL2026", "VirtualPropertyAnnotationInPropertyAndAccessor.get", ProducedBy = ProducedBy.Trimmer)]
+ [ExpectedWarning ("IL2026", "PropertyAnnotationInPropertyAndAccessor.set", ProducedBy = ProducedBy.Trimmer)]
+
public static void Test ()
{
RequirePublicMethods (typeof (BaseClassWithRequires));
RequirePublicMethods (typeof (BaseClassWithoutRequires));
RequirePublicMethods (typeof (DerivedClassWithRequires));
RequirePublicMethods (typeof (DerivedClassWithoutRequires));
+ RequirePublicMethods (typeof (DerivedClassWithAllWarnings));
RequirePublicMethods (typeof (IBaseWithRequires));
RequirePublicMethods (typeof (IBaseWithoutRequires));
RequirePublicMethods (typeof (ImplementationClassWithRequires));
@@ -1415,8 +1537,6 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[RequiresUnreferencedCode ("RUC")]
class DerivedWithRequiresOnType : BaseWithoutRequiresOnType
{
- // Bug https://github.com/dotnet/linker/issues/2379
- [ExpectedWarning ("IL2046", ProducedBy = ProducedBy.Analyzer)]
public override void Method () { }
}
@@ -1452,8 +1572,6 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
return 1;
}
- // Bug https://github.com/dotnet/linker/issues/2379
- [ExpectedWarning ("IL2046", ProducedBy = ProducedBy.Analyzer)]
public int Method (int a)
{
return a;
@@ -1962,4 +2080,4 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
}
}
-} \ No newline at end of file
+}