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

Bug:Build failure due to namespace changes in XamlTypeInfo after C++/WinRT update #9471

Closed
takatsuka2022 opened this issue Mar 21, 2024 · 6 comments
Labels
bug Something isn't working team-Markup Issue for the Markup team

Comments

@takatsuka2022
Copy link

Describe the bug

In cppwinrt version 2.0.240111.5

I'm experiencing a build failure when referencing a WinUI 3 runtime component (root namespace: Control1) in a WinUI 3 project (root namespace: App1). The namespaces registered in App1's XamlTypeInfo are different before and after updating C++/WinRT.

Before the update, the entry in XamlTypeInfo looks like this:

L"Control1.UserControl1", L"",
&ActivateType<::winrt::Control1::UserControl1>, nullptr, nullptr, nullptr,
121, // Microsoft.UI.Xaml.Controls.UserControl
85, 0, -1, TypeKind::Metadata,
TypeInfo_Flags_None,
-1,

After the update, it changes to:

L"Control1.UserControl1", L"",
&ActivateLocalType<::winrt::Control1::implementation::UserControl1>, nullptr, nullptr, nullptr,
121, // Microsoft.UI.Xaml.Controls.UserControl
85, 0, -1, TypeKind::Custom,
TypeInfo_Flags_IsLocalType | TypeInfo_Flags_None,
-1,

Steps to reproduce the bug

I'm experiencing a build failure when referencing a WinUI 3 runtime component (root namespace: Control1) in a WinUI 3 project (root namespace: App1).

Expected behavior

No response

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

No response

@takatsuka2022 takatsuka2022 added the bug Something isn't working label Mar 21, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Mar 21, 2024
@DarranRowe
Copy link

DarranRowe commented Mar 21, 2024

Was it just C++/WinRT that changed?
I ask this because C++/WinRT isn't responsible for the generation of any of the files involved in XamlTypeInfo. The way the build process works is:

  1. Midl compiles the .idl files into the individual .winmd files. You can find these in $(IntDir)\Unmerged.

Screenshot 2024-03-21 153453

  1. Mdmerge merges these individual .winmd files into the application combined .winmd file. So it reads the files from $(IntDir)\Unmerged and writes to $(IntDir)\Merged\$(RootNamespace).winmd.

Screenshot 2024-03-21 153747

  1. It copies this merged .winmd file to $(OutDir).

  2. Cppwinrt runs for the first time. This run generates the basic platform headers. These are stored in $(ProjectDir)\Generated Files\winrt.

  3. Cppwinrt runs for the second time. This run generates additional platform headers, this would include SDK references. These are stored in the same place.

  4. Cppwinrt runs for the third time. This run reads the application .winmd files and produces the component headers and implementation source. These are stored in the same place. This means that C++/WinRT is responsible for reading the .winmd file and generating .h files under $(ProjectDir)\Generated Files\winrt.

  5. The first Xaml Compiler pass runs. This reads the various .winmd files and produces some header and source files under $(ProjectDir)\Generated Files.

  6. The second Xaml Compiler pass runs. This reads the various .winmd files and the state from the first pass and produces the remaining source files, this is when XamlTypeInfo.cpp should be generated.

So I could understand an update to the Windows App SDK package causing this, since that is what contains the Xaml Compiler. But an update to C++/WinRT shouldn't cause this.

@kennykerr
Copy link

Possibly related: microsoft/cppwinrt#1397

@Scottj1s
Copy link
Member

@takatsuka2022 Can you share a repro project?

@takatsuka2022
Copy link
Author

We have created a test pro. We have also confirmed that the solution builds successfully and is executable by reverting the CppWinRT version back to 2.0.230706.1.
ControlLib 2.zip

@bpulliam bpulliam added team-Markup Issue for the Markup team and removed needs-triage Issue needs to be triaged by the area owners labels Mar 22, 2024
@Scottj1s
Copy link
Member

Scottj1s commented Apr 4, 2024

@takatsuka2022 thank you for the repro. A fix has been made to CppWinRT: microsoft/cppwinrt#1404

@Scottj1s
Copy link
Member

Scottj1s commented Apr 5, 2024

@Scottj1s Scottj1s closed this as completed Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

5 participants