Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files created for Embedded are not marked as auto-generated #1576

Open
Marv51 opened this issue Apr 18, 2024 · 0 comments
Open

Files created for Embedded are not marked as auto-generated #1576

Marv51 opened this issue Apr 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Marv51
Copy link

Marv51 commented Apr 18, 2024

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

@Marv51 Marv51 added the bug Something isn't working label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant