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

XamlTypeInfo.g.cpp adds providers for project references, but doesn't #include needed headers #4907

Closed
DefaultRyan opened this issue Apr 27, 2021 · 4 comments
Labels
area-Tooling product-winui3 WinUI 3 issues team-Markup Issue for the Markup team
Milestone

Comments

@DefaultRyan
Copy link
Member

(See discussion started here: microsoft/WindowsAppSDK#763)

  • Create a blank WinUI app (App1)
  • Add a WinUI Runtime Component (Controls1)
  • Using the template, add a UserControl to the Runtime Component (Controls1)
  • Add a project reference in the app to the component (App1 references Controls1).

Building the project after this results in a build error in XamlTypeInfo.g.cpp:

std::vector<::winrt::Microsoft::UI::Xaml::Markup::IXamlMetadataProvider> const& XamlTypeInfoProvider::OtherProviders()
{
    if (_otherProviders.empty())
    {
        _otherProviders.push_back(::winrt::Controls1::XamlMetaDataProvider()); // <-- ERROR
        _otherProviders.push_back(::winrt::Microsoft::UI::Xaml::XamlTypeInfo::XamlControlsXamlMetaDataProvider());
    }
    return _otherProviders;
}

This breaks because the header for Controls1 wasn't included. XamlTypeInfo.g.cpp should have this added:

#include <winrt/Controls1.h>

It's possible to work around this by adding the missing #include to the precompiled header (pch.h), but XamlTypeInfo.g.cpp really should be self-sufficient.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Apr 27, 2021
@StephenLPeters StephenLPeters added area-Tooling team-Markup Issue for the Markup team product-winui3 WinUI 3 issues labels Apr 28, 2021
@StephenLPeters
Copy link
Contributor

StephenLPeters commented Apr 28, 2021

@evelynwu-msft FYI

@StephenLPeters StephenLPeters added the v0.5 Issues introduced in the Project Reunion 0.5 prerelease label Apr 28, 2021
@evelynwu-msft
Copy link
Contributor

@RealTommyKlein I remember this coming up before around the Preview 1 timeframe, but I don't recall why we left it the way it was.

@RealTommyKlein
Copy link
Contributor

RealTommyKlein commented Apr 28, 2021

@evelynwu-msft - IIRC that was a slightly different self-sufficiency issue that we fixed (some of the compiler's generated code relied on the default pch.h - if the default #includes were removed, we'd get errors similar to this bug). For this issue in particular, the compiler needs to dynamically determine which headers it needs to include.

I don't think that would be too difficult for XamlTypeInfo.g.cpp since we know all the types we're generating for, and can determine the header name to include by the types' namespace (e.g. if we're generating type info a Controls1.UserControl, we need to include the <winrt/Controls1.h> header). We should also do the same thing for our generated per-page files like MainPage.xaml.g.hpp that gets generated for a MainPage.xaml. For them, we'd need to associate which pages use which types so we know which headers to include for each page, which would also lay the foundation for future incremental build improvements by only reparsing .xaml files which we know contain changed types.

@duncanmacmichael
Copy link
Member

Fixed in 1.4.0. @bpulliam please close this issue as I cannot. :)

@bpulliam bpulliam removed the fixed-internally This bug has been fixed, and the fix will be shipped in the next version of WinUI 3. label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tooling product-winui3 WinUI 3 issues team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

6 participants