Skip to content

Commit 5df4f06

Browse files
Sergio0694Copilot
andcommitted
Suppress IL2050 and CA1420 from CsWin32-generated P/Invoke in UnitTest
The Microsoft.Windows.CsWin32 source generator emits a CoRegisterClassObject P/Invoke (Windows.Win32.PInvoke.Ole32) that uses COM marshalling. This trips IL2050 (COM interop correctness cannot be guaranteed after trimming) and CA1420 (managed parameter/return types require runtime marshalling, which is disabled repo-wide via the centralized DisableRuntimeMarshalling). This is generated code we don't control, so suppress both in UnitTest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 14ba87c commit 5df4f06

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/Tests/UnitTest/UnitTest.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
than raising the minimum target platform (which would defeat the purpose of those tests).
2828
-->
2929
<NoWarn>$(NoWarn);CA1416</NoWarn>
30+
31+
<!--
32+
The CsWin32 source generator emits a 'CoRegisterClassObject' P/Invoke (in 'Ole32') that uses COM
33+
marshalling, which trips 'IL2050' (COM interop correctness under trimming) and 'CA1420' (requires
34+
runtime marshalling, which is disabled repo-wide). This is generated code we don't control, so
35+
suppress both here.
36+
-->
37+
<NoWarn>$(NoWarn);IL2050;CA1420</NoWarn>
3038
<SelfContained>true</SelfContained>
3139
<CsWinRTEnabled>false</CsWinRTEnabled>
3240
<OutputType>exe</OutputType>

0 commit comments

Comments
 (0)