CsWinRT
CsWinRT copied to clipboard
CsWinRT 1.5.0 generates incorrect projections on .NET 6
Describe the bug
C:\myproj\obj\x64\Debug\net6.0-windows\Generated Files\Windows.Foundation.Collections.cs(560,23,560,28): error CA2257: The 'ABI.Windows.Foundation.Collections.IMapChangedEventArgs<K>.Vftbl' member on the 'ABI.Windows.Foundation.Collections.IMapChangedEventArgs<K>' type should be marked 'static' as 'ABI.Windows.Foundation.Collections.IMapChangedEventArgs<K>' has the 'DynamicInterfaceImplementationAttribute' applied
To Reproduce
- Create a
net6.0-windows
project - Add the following lines to the csproj:
<PropertyGroup>
<CsWinRTWindowsMetadata>sdk</CsWinRTWindowsMetadata>
<!-- Actual classes we use and their dependencies -->
<CsWinRTIncludes>
Windows.Foundation;
Windows.Security.Credentials.ICredentialFactory;
Windows.Security.Credentials.IPasswordCredential;
Windows.Security.Credentials.IPasswordVault;
Windows.Security.Credentials.PasswordCredential;
Windows.Security.Credentials.PasswordVault;
</CsWinRTIncludes>
<!-- Exclude unused Foundation namespaces that require much more stuff -->
<CsWinRTExcludes>
Windows.Foundation.Diagnostics;
Windows.Foundation.Numerics;
</CsWinRTExcludes>
</PropertyGroup>
- Compile
Expected behavior The code compiles.
Version Info CsWinRT 1.5.0 .NET SDK 6.0.102 Windows SDK 10.0.19041.0
Additional context This used to compile on CsWinRT 1.3.5 and net5.0-windows.
@A-Ovchinnikov-mx, can you try setting the following property in your project as a workaround as documented in Code analysis in .NET?
<PropertyGroup>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
By default, the CA2257 rule should be showing up as a warning and should not cause any runtime issues. But we will need to investigate if there is a way to disable the warning.