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

Using x:Uid in the ContentDialog main properties produces a compilation error #18322

Open
ArchieCoder opened this issue Sep 27, 2024 · 4 comments
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation area/i18n Categorizes an issue or PR as relevant to i18n difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/resources 🈷️ Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...)

Comments

@ArchieCoder
Copy link
Contributor

Current behavior

I have this error:

ContentDialog1_4b00c2cae815e453e645ca862e00c968.cs(74,6,74,6): error CS1002: ; expected

when I use x:Uid="EngineeringPropertySerialNumbersDialog" in a ContentDialog main properties.

Moving this x:Uid to a Page control works.

Expected behavior

No compilation error.

How to reproduce it (as minimally and precisely as possible)

AppUid.zip

Workaround

No response

Works on UWP/WinUI

No

Environment

No response

NuGet package version(s)

5.4.5

Affected platforms

Skia (WPF), Skia (Linux X11), Skia (macOS), Windows (WinAppSDK)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@ArchieCoder ArchieCoder added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Sep 27, 2024
@ArchieCoder
Copy link
Contributor Author

@jeromelaban (As discussed in Discord) A sample app is provided above. FYI, it is not a blocker since I put my code in code behind.

@jeromelaban jeromelaban added area/i18n Categorizes an issue or PR as relevant to i18n and removed triage/untriaged Indicates an issue requires triaging or verification labels Sep 27, 2024
@cengelha
Copy link

I have the same issue. I don't know what was already said on Discord but I can add that this happens for Uno.Sdk 5.3.99 and up (5.3.96 works fine) and the generated code looks like this:

Without x:Uid

base.Content = 
...
.GenericApply(__that, __nameScope, ((c1, __that, __nameScope) => 
{
	global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_ContentDialog1_a00c984faab7524673d06862ec9846d0, "file:///D:/source/repos/cengelha//Presentation/Dialogs/ContentDialog1.xaml", 13, 4);
	c1.CreationComplete();
}
))
;

this
.GenericApply(__that, __nameScope, ((c2, __that, __nameScope) => 
{
	// Source ..\..\..\..\Presentation\Dialogs\ContentDialog1.xaml (Line 1:2)
	
	// WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}ContentDialog, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator
	c2.DefaultButton = global::Microsoft.UI.Xaml.Controls.ContentDialogButton.Close;
	c2.Title = @"TITLE";
	c2.PrimaryButtonText = "Button1";
	c2.SecondaryButtonText = "Button2";
}
))
...

With x:Uid

base.Content = 
...
.GenericApply(__that, __nameScope, ((c6, __that, __nameScope) => 
{
	global::Uno.UI.FrameworkElementHelper.SetBaseUri(c6, __baseUri_ContentDialog1_5b96bc6f2fa933199356f7b36a0c5f57, "file:///D:/source/repos/cengelha//Presentation/Dialogs/ContentDialog1.xaml", 21, 4);
	c6.CreationComplete();
}
))
Title = global::Uno.UI.Helpers.MarkupHelper.GetResourceStringForXUid("ContentDialog", "ContentDialog1/Title");
SecondaryButtonText = global::Uno.UI.Helpers.MarkupHelper.GetResourceStringForXUid("ContentDialog", "ContentDialog1/SecondaryButtonText");
PrimaryButtonText = global::Uno.UI.Helpers.MarkupHelper.GetResourceStringForXUid("ContentDialog", "ContentDialog1/PrimaryButtonText");
CloseButtonText = global::Uno.UI.Helpers.MarkupHelper.GetResourceStringForXUid("ContentDialog", "ContentDialog1/CloseButtonText");
;

this
.GenericApply(__that, __nameScope, ((c7, __that, __nameScope) => 
{
	// Source ..\..\..\..\Presentation\Dialogs\ContentDialog1.xaml (Line 2:2)

	// WARNING Property c7.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}ContentDialog, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator
	c7.DefaultButton = global::Microsoft.UI.Xaml.Controls.ContentDialogButton.Close;
}
))
...

@ArchieCoder
Copy link
Contributor Author

@cengelha FYI, I was just reporting the bug via discord. What you provided above is great, you went beyond of what I provided. This will help the Uno team. Thanks.

@cengelha
Copy link

Thanks for letting me know!

At Uno team: It may also worth mentioning that it only happens if there is any custom content as otherwise the base.Content =is not there and therefore cannot have a missing ; and produce the compiler error

@MartinZikmund MartinZikmund changed the title Using x:Uid in the ContentDialog main properties produces a compilation error Using x:Uid in the ContentDialog main properties produces a compilation error Sep 30, 2024
@MartinZikmund MartinZikmund added area/code-generation Categorizes an issue or PR as relevant to code generation project/resources 🈷️ Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...) difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation area/i18n Categorizes an issue or PR as relevant to i18n difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/resources 🈷️ Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...)
Projects
None yet
Development

No branches or pull requests

4 participants