-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[XSG] enable/disable feature in msbuild #31349
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
Conversation
There was a problem hiding this 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 |
afd7132
to
dcf0104
Compare
...ontrols/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets
Outdated
Show resolved
Hide resolved
9fff4ba
to
f5cb6b5
Compare
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
24ccb76
to
b0be23e
Compare
@@ -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(';', ','))"/> |
There was a problem hiding this comment.
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...
<EnableMauiXamlDiagnostics Condition=" '$(EnableMauiXamlDiagnostics)' == '' ">$(EnableMauiDiagnostics)</EnableMauiXamlDiagnostics> | ||
<EnableMauiXamlDiagnostics Condition=" '$(EnableMauiXamlDiagnostics)' == '' And '$(Configuration)' == 'Debug' ">$(EnableDiagnostics)</EnableMauiXamlDiagnostics> | ||
<EnableMauiXamlDiagnostics Condition=" '$(EnableMauiXamlDiagnostics)' == '' And '$(Configuration)' == 'Debug' ">true</EnableMauiXamlDiagnostics> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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