Skip to content

Conversation

StephaneDelcroix
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix commented Aug 26, 2025

Description of Change

enable/disable visualdiagnostics, enable/disable #line pragmas, no warn per file

global properties:

<EnableMauiXamlDiagnostics>true|false</EnableMauiXamlDiagnostics >. defaults to true for Debug configuration
<MauiXamlLineInfo>enable|disable</MauiXamlLineInfo> defaults to 'enable'
<MauiXamlNoWarn>0618;0612</MauiXamlNoWarn>

per MauiXaml item metadata

EnableDiagnostics="true|false"
LineInfo="disable|enable"
NoWarn="0618"

user shouldn't have to set those properties, but it greatly helps the readability of the generated file

@Copilot Copilot AI review requested due to automatic review settings August 26, 2025 12:10
@StephaneDelcroix StephaneDelcroix requested a review from a team as a code owner August 26, 2025 12:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a configuration option to disable the generation of #line directives in XAML source generation, making the generated C# files more readable for debugging and development purposes without affecting the final compiled IL.

Key Changes

  • Adds EnableLineInfo property to control #line directive generation
  • Removes conditional compilation attributes in favor of runtime configuration
  • Updates test project to disable line info generation by default

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Controls.Xaml.UnitTests.csproj Removes _MAUIXAML_SG_SOURCEINFO define constant to disable line info in tests
SetPropertiesVisitor.cs Updates property setting code to conditionally generate line info based on context
SourceGenContext.cs Adds EnableLineInfo boolean property to control line info generation
ProjectItem.cs Adds EnableLineInfo property with default value of true
PrePost.cs Refactors line info generation from conditional compilation to runtime control
InitializeComponentCodeWriter.cs Sets EnableLineInfo from project item configuration
GeneratorHelpers.cs Adds parsing of LineInfo metadata to determine if line info should be enabled

@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/xsg/lineinfooption branch from afd7132 to dcf0104 Compare August 27, 2025 15:04
@StephaneDelcroix StephaneDelcroix changed the title [XSG] option to disable #line info generation [XSG] enable/disable feature in msbuild Aug 28, 2025
@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/xsg/lineinfooption branch 2 times, most recently from 9fff4ba to f5cb6b5 Compare August 28, 2025 11:23
simonrozsival
simonrozsival previously approved these changes Aug 28, 2025
Doesn't change the generated IL at the end, but make the generated cs
file easir to read, understand, reflect on
<MauiXamlEnableDiagnostics> property or EnableDiagnostics item metadata.
defaults to true for debug
@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/xsg/lineinfooption branch from 24ccb76 to b0be23e Compare August 29, 2025 08:13
@@ -83,6 +89,7 @@
<!-- Assign the default inflator to MauiXaml that don't have any -->
<!-- there's a roslyn bug that stops parsing value at the first semicolon. replace them all https://github.com/dotnet/roslyn/issues/43970 -->
<MauiXaml Inflator="$([MSBuild]::ValueOrDefault('%(MauiXaml.Inflator)','$(_MauiXamlInflator)').Replace(';', ','))"/>
<MauiXaml NoWarn="$([MSBuild]::ValueOrDefault('%(MauiXaml.NoWarn)','').Replace(';', ','))"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know, that roslyn bug...

Comment on lines +14 to +16
<EnableMauiXamlDiagnostics Condition=" '$(EnableMauiXamlDiagnostics)' == '' ">$(EnableMauiDiagnostics)</EnableMauiXamlDiagnostics>
<EnableMauiXamlDiagnostics Condition=" '$(EnableMauiXamlDiagnostics)' == '' And '$(Configuration)' == 'Debug' ">$(EnableDiagnostics)</EnableMauiXamlDiagnostics>
<EnableMauiXamlDiagnostics Condition=" '$(EnableMauiXamlDiagnostics)' == '' And '$(Configuration)' == 'Debug' ">true</EnableMauiXamlDiagnostics>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These defaults make sense, as I don't think we want $(EnableDiagnostics) to default to true in the iOS/Android workloads.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y, I like those defaults as well

@StephaneDelcroix StephaneDelcroix enabled auto-merge (squash) August 29, 2025 19:51
@StephaneDelcroix StephaneDelcroix merged commit 61b4999 into net10.0 Sep 1, 2025
150 checks passed
@StephaneDelcroix StephaneDelcroix deleted the dev/stdelc/xsg/lineinfooption branch September 1, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants