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

Automatic bool-visibility conversion regressed between C++17 and 20 #9214

Closed
tom-huntington opened this issue Jan 8, 2024 · 6 comments
Closed
Labels
area-Binding bug Something isn't working team-Markup Issue for the Markup team

Comments

@tom-huntington
Copy link

tom-huntington commented Jan 8, 2024

Describe the bug

\App6\App6\Generated Files\MainWindow.xaml.g.hpp(172,92): error C3779: 'winrt::impl::consume_Windows_Foundation_IReference<winrt::Windows::Foundation::IReference,T>::Value': a function that returns 'auto' cannot be used before it is defined

Steps to reproduce the bug

https://github.com/tom-huntington/auto-bool-visibility-conversion-cpp20-regression

MainWindow.xaml

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
    <CheckBox x:Name="myButton" Content="Click Me" />
    <TextBlock Text="Hello" Visibility="{x:Bind myButton.IsChecked, Mode=OneWay}"/>
</StackPanel>

MainWindow.idl

Microsoft.UI.Xaml.Controls.CheckBox myButton{ get; };

Expected behavior

That it compiles with /std:c++20 as it did with /std:c++17

NuGet package version

WinUI 3 - Windows App SDK 1.4.3: 1.4.231115000

Windows version

Windows 11 (21H2): Build 22000

Additional context

docs: https://learn.microsoft.com/en-us/windows/uwp/xaml-platform/x-bind-markup-extension#remarks

Starting in Windows 10, version 1607, the XAML framework provides a built in Boolean to Visibility converter. The converter maps true to the Visible enumeration value and false to Collapsed so you can bind a Visibility property to a Boolean without creating a converter. Note that this is not a feature of function binding, only property binding. To use the built in converter, your app's minimum target SDK version must be 14393 or later. You can't use it when your app targets earlier versions of Windows 10. For more info about target versions, see Version adaptive code.

@tom-huntington tom-huntington added the bug Something isn't working label Jan 8, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 8, 2024
@asklar
Copy link
Member

asklar commented Jan 9, 2024

@tom-huntington that repo is private (I get a 404)

@tom-huntington
Copy link
Author

@tom-huntington that repo is private (I get a 404)

Sorry. Fixed.

@sylveon
Copy link
Contributor

sylveon commented Jan 11, 2024

Looks like a missing #include <winrt/Windows.Foundation.h>

@tom-huntington
Copy link
Author

tom-huntington commented Jan 11, 2024

Looks like a missing #include <winrt/Windows.Foundation.h>

I know that's what the error message is saying.

pch.h includes it and adding extra includes MainWindow.xaml.h doesn't fix it??

@bpulliam bpulliam added area-Binding team-Markup Issue for the Markup team and removed needs-triage Issue needs to be triaged by the area owners labels Jan 18, 2024
@asklar
Copy link
Member

asklar commented Jun 18, 2024

@tom-huntington did this get fixed?

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jun 18, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Jun 20, 2024
@tom-huntington
Copy link
Author

@tom-huntington did this get fixed?

No, but realized there's a work around. Just force the instantiation of IReference<bool>::Value

//MainWindow.xaml.h
#if 1
inline void force_instantiation_of_IRefBoolValue()
{
    &winrt::Windows::Foundation::IReference<bool>::Value;
}
#else
//error C3779 : 'winrt::impl::consume_Windows_Foundation_IReference<winrt::Windows::Foundation::IReference<bool>,T>::Value' : a function that returns 'auto' cannot be used before it is defined
#endif

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jun 21, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Binding bug Something isn't working team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

5 participants