CsWinRT
CsWinRT copied to clipboard
Files created for Embedded are not marked as auto-generated
Describe the bug
I am trying to use the Embedding option in my C# application.
This app uses <Nullable>enable</Nullable> and <WarningsAsErrors>Nullable</WarningsAsErrors>.
I am getting a lot of errors/warnings, like these:
error CS8625: Cannot convert null literal to non-nullable reference type.
error CS8769: Nullability of reference types in type of parameter 'value' doesn't match implemented member
I understand that CsWinRT and WinRT do not support Nullable.
You could help mitigate this problem if the generated files were explicitly marked as generated files. This would automatically suppress some warnings as appropriate.
This can be done in a multitude of ways.
One way is to use the file extension ".g.cs" or to use a <auto-generated> header.
To Reproduce I think this is a general and understood issue, I can provide a repro project if needed.
Expected behavior CsWin32 uses this header:
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
That seems like a good idea.
Version Info
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.7" />
<CsWinRTEmbedded>true</CsWinRTEmbedded>
<CsWinRTWindowsMetadata>sdk</CsWinRTWindowsMetadata>
<CsWinRTGenerateProjection>true</CsWinRTGenerateProjection>
Additional context None