Skip to content

Conversation

@ghost1372
Copy link
Contributor

@ghost1372 ghost1372 commented Jan 7, 2026

Add a source generator to automatically generate the NavigationPageMappings class, which maps page types to unique IDs. This eliminates the need to use reflection, such as Type.GetType(pageString). #1627

Before:

string pageString = $"{pageRoot}{item.UniqueId}Page";
Type? pageType = Type.GetType(pageString);

After:
NavigationPageMappings.PageDictionary.TryGetValue(item.UniqueId, out Type? pageType);

image

Description

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@ghost1372
Copy link
Contributor Author

Hi
@marcelwgn
@niels9001
can you review this pr?
tnx

"Items": [
{
"UniqueId": "XamlResources",
"UniqueId": "WinUIGallery.ControlPages.XamlResourcesPage",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we need to change the unique id for this?

in the WinUI repo, or the next ItemGroup below when standalone. -->
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.183">
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.264">
Copy link
Contributor

Choose a reason for hiding this comment

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

Intentional change?

@marcelwgn
Copy link
Contributor

Thank you for working on this, great job!

General question, do we need to include the fully qualified type name? I think for simplicity we can get away with just having the type name itself as key instead of having to prepend "WinUIGallery..." everwhere.

@Zakariathr22
Copy link
Contributor

I have a few questions:

  • What value would Native AOT bring to the Gallery, and is it actually necessary? Please correct me if I am mistaken, but my understanding is that Native AOT becomes truly beneficial primarily for very large applications with extensive functionality, where startup time and performance are critical.

  • Is Microsoft planning to make Native AOT adoption easier? At the moment, I see many pull requests relying on workarounds and complex, fragile code paths just to make it work, often without achieving a stable or satisfactory result.

  • Is there any official guide or step-by-step documentation for implementing Native AOT in existing WinUI applications, or should we consider creating such documentation ourselves?

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