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

Inconsistent nullable feature status for WinUI3 projects #46420

Closed
huoyaoyuan opened this issue Jul 29, 2020 · 3 comments
Closed

Inconsistent nullable feature status for WinUI3 projects #46420

huoyaoyuan opened this issue Jul 29, 2020 · 3 comments

Comments

@huoyaoyuan
Copy link
Member

Version Used:
Visual Studio 16.7 Preview 6
.NET SDK 5.0.100 Preview 7
WinUI 3 Preview 2

Steps to Reproduce:

  1. Create a new WinUI(.NET 5) project from template. https://docs.microsoft.com/en-us/windows/apps/winui/winui3/get-started-winui3-for-desktop
    Building the package project requires workaround for this VS version, but building the main .NET project will success.
  2. Add <Nullable>enable</Nullable> in csproj.
    The compiler will complain about that field m_Window of class App is not initialized, as expected.
  3. Add nullable annotation onto the field declaration, making it become private Window? m_Window;. Then compile the project again.

Expected Behavior:
No warning about nullability present.

Actual Behavior:
The IDE IntelliSense warning goes away. But there will be warning CS8632: you can only use nullable annotations in #nullable enable context in IDE output window. The warning does not go into IDE error list window.

Other Information:
I haven't confirmed whether it's caused by WinUI or CsWinRT. But I can confirm that it doesn't apply to WPF (.NET5).

@cartermp
Copy link
Contributor

In theory this should work because WinUI3 project stargeting net5 are SDK-style projects.

@huoyaoyuan
Copy link
Member Author

It only repros when there's .xaml (probably requires generating .xaml.g.cs) added to the project.

@huoyaoyuan
Copy link
Member Author

Opened dotnet/msbuild#6088 . This is an external issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants