Skip to content

Warnings From Generated XAML Refer to a file the IDE cannot find #35908

Closed

Description

@david-maw

Description

Generated XAML creates a warning, for example: warning CS8622: Nullability of reference types... (actually this particular warning is pretty easy to figure out and resolve, but it's an easy example). The build emits an error, like:

1>H:\Develop\Bugs\XamlGeneration\XamlGeneration\obj\Debug\net10.0-windows10.0.19041.0\win-x64\intermediatexaml\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\MainPage.xaml.xsg.cs(143,21,143,37): warning CS8622: Nullability of reference types in type of parameter 'sender' of 'void MainPage.OnCounterClicked(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).

But clicking on the error does noting because the file MainPage.xaml.xsg.cs cannot be found. Adding

    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>

To the project file does not help, so I guess there are two bugs:

  1. Displaying a message about a file then removing the file before the user can take action.
  2. EmitCompilerGeneratedFiles set to true should retain the files whether or not they have warnings.

Steps to Reproduce

  1. Create a new MAUI app
  2. Edit MainPage.xaml.cs OnCounterClicked to specify the first parameter as object sender by removing the "?"
  3. Build it and observe the warning in the build output

I'm sure this (clicking on a warning) used to work in .NET 10 but I'm not sure if it ever worked in .NET11.

Link to public reproduction project repository

No response

Version with bug

11.0.0-preview.4

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

10.0.70

Affected platforms

Windows, Android, I was not able test on other platforms

Affected platform versions

Windows 11, Android SDK 35

Did you find any workaround?

No response

Relevant log output

Activity

  1. added
    t/bug
    on Jun 13, 2026
  2. changed the title [-]Warnings From Generated XAML Refer toa file the IDE cannot find[/-] [+]Warnings From Generated XAML Refer to a file the IDE cannot find[/+] on Jun 13, 2026
  3. NafeelaNazhir commented on Jun 15, 2026

    @NafeelaNazhir
    Contributor

    This issue has been validated in Visual Studio Code 1.124.0 with .NET MAUI versions 10.0.71 & net 11.0.0-preview1. It can be reproducible from net 11.0.0-preview1 and issue not reproduced in net 10.0.71 in Android platform.

    Image

    XamlIssue.zip

  4. added
    s/triaged
    s/verified
    i/regression
    on Jun 15, 2026
  5. added this to the .NET 10 SR9 milestone on Jun 15, 2026
  6. added
    partner/syncfusion
    on Jul 3, 2026
  7. added
    s/try-latest-version
    on Jul 3, 2026
  8. david-maw commented on Jul 3, 2026

    @david-maw
    Author

    Still seems to fail. In Visual Studio Insiders [11925.187] and SDK 11.0.100 preview 5. I see this:

    Image

    Where double-clicking on the error updates the status line to: "The system cannot find the file specified".

  9. removed
    s/try-latest-version
    on Jul 3, 2026
  10. added a commit that references this issue on Oct 16, 2026
    3ca4ae3
  11. github-actions commented on Oct 16, 2026

    @github-actions
    Contributor

    Closed by #39425 (merged to net11.0). GitHub only auto-closes for PRs merged to the default branch; this issue was fixed by a PR merged to a non-default branch.

  12. david-maw commented on Oct 19, 2026

    @david-maw
    Author

    I don't understand this closure, Testing in .NET 11 RC2 by inserting a single `FontSize="Large"`` clause in a default MAUI project gets me 6 warnings:

    1>C:\Program Files\dotnet\sdk\11.0.100-rc.2.26504.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(385,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
    1>H:\Develop\Test\Maui\NET11SDK\NET11SDK\obj\Debug\net11.0-windows10.0.19041.0\win-x64\intermediatexaml\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\MainPage.xaml.xsg.cs(92,74,92,112): warning CS0612: 'Device' is obsolete
    1>H:\Develop\Test\Maui\NET11SDK\NET11SDK\obj\Debug\net11.0-windows10.0.19041.0\win-x64\intermediatexaml\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\MainPage.xaml.xsg.cs(92,127,92,168): warning CS0612: 'NamedSize' is obsolete
    1>H:\Develop\Test\Maui\NET11SDK\NET11SDK\obj\Debug\net11.0-windows10.0.19041.0\win-x64\intermediatexaml\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\MainPage.xaml.xsg.cs(92,74,92,218): warning CS0612: 'Device.GetNamedSize(NamedSize, Type)' is obsolete
    1>  Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
    1>H:\Develop\Test\Maui\NET11SDK\NET11SDK\obj\Debug\net11.0-windows10.0.19041.0\win-x64\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\MainPage.xaml.xsg.cs(92,74,92,112): warning CS0612: 'Device' is obsolete
    1>H:\Develop\Test\Maui\NET11SDK\NET11SDK\obj\Debug\net11.0-windows10.0.19041.0\win-x64\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\MainPage.xaml.xsg.cs(92,127,92,168): warning CS0612: 'NamedSize' is obsolete
    1>H:\Develop\Test\Maui\NET11SDK\NET11SDK\obj\Debug\net11.0-windows10.0.19041.0\win-x64\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\MainPage.xaml.xsg.cs(92,74,92,218): warning CS0612: 'Device.GetNamedSize(NamedSize, Type)' is obsolete
    1>  NET11SDK -> H:\Develop\Test\Maui\NET11SDK\NET11SDK\bin\Debug\net11.0-windows10.0.19041.0\win-x64\NET11SDK.dll
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    ========== Build completed at 5:20 PM and took 10.405 seconds ==========
    

    This looks like the same 3 warnings repeated twice and clicking on any of them does nothing. I am able to set EmitCompilerGeneratedFiles to have intermediate files saved in an 'obj...generated' folder and the warnings in those ones at least are usefully clickable (the intermediatexaml ones still are not). For the casual user I'd think knowing that "warning CS0612: 'Device' is obsolete" means "you used a named FontSize" is a bit obscure and IMHO generated code should never emit warnings - they should be suppressed in favor of a warning against the original source.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamli/regressionpartner/syncfusionplatform/androidplatform/windowsregressed-in-11-preview1s/triageds/verifiedt/bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions