diff options
author | Jackson Schuster <jschuster@microsoft.com> | 2021-12-03 22:18:10 +0300 |
---|---|---|
committer | Jackson Schuster <jschuster@microsoft.com> | 2021-12-10 01:39:54 +0300 |
commit | 149b0e3c6932dac45dc7253e179b7ee2f42cccea (patch) | |
tree | 800326ac0fc51d14aeff3bc87af4813889ac54b3 | |
parent | 921b07f5c71fd28358952423f119ddd3edd4aa05 (diff) |
COM Analyzer also checks containing type for RUC
-rw-r--r-- | src/ILLink.RoslynAnalyzer/COMAnalyzer.cs | 5 | ||||
-rw-r--r-- | test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs b/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs index 05e0aa097..498d9d598 100644 --- a/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs +++ b/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs @@ -40,8 +40,11 @@ namespace ILLink.RoslynAnalyzer if (!targetMethod.HasAttribute (DllImportAttribute)) return; - if (operationContext.ContainingSymbol is ISymbol containingSymbol && containingSymbol.HasAttribute(RequiresUnreferencedCodeAttribute)) { + if (operationContext.ContainingSymbol is ISymbol containingSymbol) { + if (containingSymbol.HasAttribute (RequiresUnreferencedCodeAttribute) + || containingSymbol.ContainingType.HasAttribute (RequiresUnreferencedCodeAttribute)) { return; + } } bool comDangerousMethod = IsComInterop (targetMethod.ReturnType); 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 a92e86945..6909d5967 100644 --- a/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs +++ b/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Warnings/ComPInvokeWarning.cs @@ -178,8 +178,8 @@ namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Warnings [RequiresUnreferencedCode ("test")] static void Call_CanSuppressWithRequiresUnreferencedCodeInLambda () { - var lambda = () => CanSuppressWithRequiresUnreferencedCode (null); - lambda (); + Action<int> lambda = (x) => CanSuppressWithRequiresUnreferencedCode (null); + lambda (0); } |