dotnet / dotnet/maui

[XSG] Enable MauiXamlLineInfo by default for better error reporting

Open
#33,795 0 comments 0 reactions 1 assignee Claimed by @StephaneDelcroix View on GitHub
area-xaml s/triaged xsg
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

## Summary

When XAML source generation produces code with errors (type mismatches, invalid syntax, etc.), the C# compiler error currently points to the generated `.xsg.cs` file. This is confusing for developers who need to trace errors back to the original XAML.

The `#line` directive infrastructure already exists and works - it's just disabled by default due to Roslyn issues with large PDBs.

## Current Behavior

`EnableLineInfo` defaults to `false` in `ProjectItem.cs`:
```csharp
return false; //default to False due to roslyn issues with large pdbs https://github.com/dotnet/maui/issues/37782
```

## Desired Behavior

Enable `MauiXamlLineInfo` by default so compiler errors point to the XAML file/line, not the generated code.

## Blocking Issue

- https://github.com/dotnet/maui/issues/37782 - Roslyn issue with large PDBs

## Next Steps

1. Monitor the Roslyn issue for resolution
2. Once resolved, enable `MauiXamlLineInfo` by default (at least in Debug configuration)
3. Consider enabling it unconditionally if PDB size is acceptable

## Workaround

Users can manually enable it today by adding to their project file:
```xml
true
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.