|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
| 3 | +using System.Diagnostics.CodeAnalysis; |
3 | 4 | using System.Runtime.InteropServices;
|
4 | 5 | using System.Text;
|
5 | 6 | using Mono.Linker.Tests.Cases.Expectations.Assertions;
|
6 | 7 |
|
7 | 8 | namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Warnings
|
8 | 9 | {
|
9 |
| - [LogContains ("SomeMethodTakingInterface")] |
10 |
| - [LogContains ("SomeMethodTakingObject")] |
| 10 | + [SkipKeptItemsValidation] |
| 11 | + [ExpectedNoWarnings] |
11 | 12 | [KeptModuleReference ("Foo")]
|
12 | 13 | class ComPInvokeWarning
|
13 | 14 | {
|
| 15 | + [UnconditionalSuppressMessage ("trim", "IL2026")] |
14 | 16 | static void Main ()
|
15 | 17 | {
|
16 | 18 | SomeMethodTakingInterface (null);
|
17 | 19 | SomeMethodTakingObject (null);
|
| 20 | + GetInterface (); |
| 21 | + CanSuppressWarningOnParameter (null); |
| 22 | + CanSuppressWarningOnReturnType (); |
| 23 | + CanSuppressWithRequiresUnreferencedCode (null); |
18 | 24 | }
|
19 | 25 |
|
20 |
| - [Kept] |
| 26 | + [ExpectedWarning ("IL2050")] |
21 | 27 | [DllImport ("Foo")]
|
22 | 28 | static extern void SomeMethodTakingInterface (IFoo foo);
|
23 | 29 |
|
24 |
| - [Kept] |
| 30 | + [ExpectedWarning ("IL2050")] |
25 | 31 | [DllImport ("Foo")]
|
26 | 32 | static extern void SomeMethodTakingObject ([MarshalAs (UnmanagedType.IUnknown)] object obj);
|
27 | 33 |
|
28 |
| - [Kept] |
| 34 | + [ExpectedWarning ("IL2050")] |
| 35 | + [DllImport ("Foo")] |
| 36 | + static extern IFoo GetInterface (); |
| 37 | + |
| 38 | + [UnconditionalSuppressMessage ("trim", "IL2050")] |
| 39 | + [DllImport ("Foo")] |
| 40 | + static extern void CanSuppressWarningOnParameter ([MarshalAs (UnmanagedType.IUnknown)] object obj); |
| 41 | + |
| 42 | + [UnconditionalSuppressMessage ("trim", "IL2050")] |
| 43 | + [DllImport ("Foo")] |
| 44 | + static extern IFoo CanSuppressWarningOnReturnType (); |
| 45 | + |
| 46 | + [ExpectedWarning ("IL2050")] // Issue https://github.com/mono/linker/issues/1989 |
| 47 | + [RequiresUnreferencedCode ("test")] |
| 48 | + [DllImport ("Foo")] |
| 49 | + static extern void CanSuppressWithRequiresUnreferencedCode (IFoo foo); |
| 50 | + |
29 | 51 | interface IFoo { }
|
30 | 52 | }
|
31 | 53 | }
|
0 commit comments