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

XAML errors frequently do not reference the file with an issue #21038

Open
BlueRaja opened this issue Mar 6, 2024 · 8 comments
Open

XAML errors frequently do not reference the file with an issue #21038

BlueRaja opened this issue Mar 6, 2024 · 8 comments
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@BlueRaja
Copy link

BlueRaja commented Mar 6, 2024

Description

See title. Sometimes when there's an error with an XAML file, Visual Studio is unable to tell me which file/line the problem occurs in.

I never had this issue with Xamarin Forms, but in one week of Maui it's happened multiple times.

Steps to Reproduce

I'm not sure if this will reproduce the issue, but with the latest instance, I accidentally added the Spacing attribute to a StackLayout twice

<StackLayout HorizontalOptions="FillAndExpand" Spacing="0" Margin="5,0,5,0" Spacing="6">
    ...
</StackLayout>

The error in the error list opened up the .csproj file, rather than the file containing the error.

2024-03-06 01_20_08-NVIDIA GeForce Overlay DT

Link to public reproduction project repository

No response

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@BlueRaja BlueRaja added the t/bug Something isn't working label Mar 6, 2024
@jfversluis
Copy link
Member

Reading the error message it specifies exactly where the error is: line 14, position 81

@mgoertz-msft is there something to be done on our side to also make the double-click work so people will go to the right position immediately or is that in VS?

@jsuarezruiz jsuarezruiz added the area-xaml XAML, CSS, Triggers, Behaviors label Mar 6, 2024
@mgoertz-msft
Copy link
Contributor

@jfversluis All XAML IntelliSense errors are prefixed with XLS (for XAML Language Service). These particular errors start with MAUIG, which come from the MAUI SourceGenerator. So this should probably be fixed there to not report the project as the file with the error in it.

@BlueRaja
Copy link
Author

BlueRaja commented Mar 7, 2024

Reading the error message it specifies exactly where the error is: line 14, position 81

It claims the error is in the .csproj file. It gives no indication of which file actually contains the error.

@jfversluis
Copy link
Member

It claims the error is in the .csproj file. It gives no indication of which file actually contains the error.

There column with that info does seem to have more text as it's ending in ... if you expand the column, is the right file in there?

@BlueRaja
Copy link
Author

BlueRaja commented Mar 7, 2024

That column is expanded, as you can see in the screenshot. If I copy the full error from VS using "right-click + copy", I get this:

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error	MAUIG1001	An error occured while parsing Xaml: 'Spacing' is a duplicate attribute name. Line 14, position 81..	Ringotan.KanjiControl (net8.0-android)	C:\Projects\CSharp\Ringotan\Ringotan.KanjiControl\Ringotan.KanjiControl.csproj	1	Active	

@samhouts samhouts added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Mar 11, 2024
@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Mar 15, 2024
@ninachen03
Copy link
Collaborator

Verified this issue on VS 17.10.0 Preview 2. can repro it.
image

@StephaneDelcroix
Copy link
Contributor

@mgoertz-msft could you help here ? The problem is at this line (I suspect)

var location = projItem.RelativePath is not null ? Location.Create(projItem.RelativePath, new TextSpan(), new LinePositionSpan()) : null;

RelativePath isn't null as a location is returned (position) but is probably string.Empty

@mgoertz-msft
Copy link
Contributor

@StephaneDelcroix Those values come from here:

		fileOptions.TryGetValue("build_metadata.additionalfiles.TargetPath", out var targetPath);
		fileOptions.TryGetValue("build_metadata.additionalfiles.ManifestResourceName", out var manifestResourceName);
		fileOptions.TryGetValue("build_metadata.additionalfiles.RelativePath", out var relativePath);
		fileOptions.TryGetValue("build_property.targetframework", out var targetFramework);
		return new ProjectItem(additionalText, targetPath: targetPath, relativePath: relativePath, manifestResourceName: manifestResourceName, kind: kind, targetFramework: targetFramework);

If the values aren't right, then that's either not the correct way to retrieve them or there's a bug in Roslyn that doesn't populate those values as expected. Another question would be if this happens for all MAUI XAML files or just some? And if it's the latter then what's different about those?

@PureWeen PureWeen modified the milestones: .NET 8 SR6, .NET 8 SR7 Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

9 participants