Skip to content

WinAppSdk is difficult to use with reg-free WinRT due to class/file naming, pairs #2352

@riverar

Description

@riverar

Problem

Windows App SDK (WAS) 1.1-preview1 added the ability to ship as part of a self-contained application. What this generally means is that WAS components are now activatable without registration (registration-free WinRT). Instead of relying on registration information stored in the Windows Registry, WAS tooling now/currently stuffs a large manifest into your app replicating that function.

To support this feature outside Visual Studio/Msbuild C++/C#, developers must:

  • carefully author this manifest manually (or carry around a generic one and maintain it)
  • distribute it with their app internally (as a manifest resource) or externally (my.exe.manifest)

To avoid manifestation altogether, projections such as C++/WinRT and C#/WinRT alternatively turn to a simple algorithm to locate activatable classes and their activation factory. These projections:

  1. remove the class name (from the fully-qualified class name)
  2. look for a library with that name
  3. if that's not found, remove the most-specific segment name and repeat step 2

Unfortunately, WAS does not adhere to best WinRT component naming practices. WAS files have unexpected names and/or host classes that don't have related namespaces.

Here's a snippet of what the class <-> file relationship looks like today:

Library Classes
Microsoft.WindowsAppRuntime.dll Microsoft.Windows.ApplicationModel.DynamicDependency.PackageDependency
Microsoft.Windows.ApplicationModel.DynamicDependency.PackageDependencyRank
Microsoft.Windows.System.EnvironmentManager
...
Microsoft.UI.Xaml.dll Microsoft.UI.Xaml.Controls.DragItemsStartingEventArgs
Microsoft.UI.Xaml.Controls.ItemClickEventArgs
Microsoft.UI.Xaml.Controls.SelectionChangedEventArgs
Microsoft.UI.Xaml.Controls.SemanticZoomViewChangedEventArgs
...
Microsoft.UI.Xaml.Controls.dll Microsoft.UI.Xaml.XamlTypeInfo.XamlControlsXamlMetaDataProvider
Microsoft.UI.Xaml.Controls.XamlControlsResources
Microsoft.UI.Private.Controls.MUXControlsTestHooks
Microsoft.UI.Xaml.Controls.Primitives.CornerRadiusToThicknessConverter
Microsoft.UI.Xaml.Controls.Primitives.CornerRadiusFilterConverter
...
WinUIEdit.dll Microsoft.UI.Text.FontWeights
Microsoft.UI.Text.TextConstants
Microsoft.Web.WebView2.Core.dll Microsoft.Web.WebView2.Core.CoreWebView2ControllerWindowReference
Microsoft.Web.WebView2.Core.CoreWebView2Environment
Microsoft.Web.WebView2.Core.CoreWebView2EnvironmentOptions
CoreMessagingXP.dll Microsoft.UI.Dispatching.DispatcherQueue
Microsoft.UI.Dispatching.DispatcherQueueController
...

(The full table, as of 1.1-preview1, can be found here.)

Observe in the above snippet:

  • Microsoft.WindowsAppRuntime.dll hosts classes in the Microsoft.Windows.ApplicationModel.* and Microsoft.Windows.System.* namespaces
  • Both Microsoft.UI.Xaml.dll and Microsoft.UI.Xaml.Controls.dll host classes in the Microsoft.UI.Xaml.Controls.* namespace
  • WinUIEdit.dll hosts classes in the Microsoft.UI.Text namespace
  • etc.

I explored the possibility of simply renaming the libraries to compatible names, but Microsoft.UI.dll and Microsoft.UI.Xaml.dll both contain types that would fail the aforementioned search algorithm.

Considered workarounds/solutions

  1. Rename all WAS libraries and move the classes to the right spots.
    Requires WAS code change. Could be considered a major change (2.0).

  2. Continue using the internal/external manifest.
    This does not follow WinRT component recommendations, is generally non-idiomatic, and is unfriendly for some projections (e.g. Rust).

  3. Change language projections to deal with non-ideal layout.
    Requires all projections to change. Involves working with sensitive projection code.

    Projections could perhaps:

    • consume the manifest (oracle)
    • rename the libraries, creating a saner layout, adding numbers to "dupes" (e.g. UI.Xaml.1, UI.Xaml.2, ...)
    • adjust activation factory search algorithm as needed
  4. Did I miss any?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions