Microsoft-ui-xaml: XAML compiler fails for specific cultures

Created on 9 Apr 2019  路  4Comments  路  Source: microsoft/microsoft-ui-xaml

Describe the bug
XAML compiler fails for specific cultures, when a compiled binding has a function in which one of more arguments are decimal values.

Steps to reproduce the bug

  1. Ensure you have your regional settings set to "pt-PT" (Portuguese Portugal)
  2. create a new UWP blank app
  3. add this function to the code behind:
public double TestFunction(double returnValue) => returnValue;
  1. Change the XAML root Grid element to the following:
<Grid Opacity="{x:Bind TestFunction(0.5)}" />
  1. Build!

Observed behavior
Build fails with the following error message:

Invalid binding path 'TestFunction(0.5)': Function parameter '1' is invalid or mismatched"

Expected behavior
Build completes with no errors.

Version Info
Windows 10 version 1903 (OS Build 18362.30)
Visual Studio 2017 version 15.9.11

NuGet package version:

Additional context
This issue was first reported on the Visual Studio Developer Community website (here)
That issue was closed by MSFT Lingling Tong with indication that this should be reported here.

Seems that if your system is set to a culture that uses "," as a decimal separator (pt-PT is an example) this will fail to build!

My fix was easy:

  1. Close visual studio
  2. Change regional settings to "en-GB"
  3. open visual studio and try to build again
  4. Profit (while simultaneously ranting alone about this issue)...

Would be great to get a proper fix for this issue

area-XamlCompiler bug team-Markup

Most helpful comment

@fabiant3 thank you, but I think you might have missed my point here a bit: I don't expect the compiler to support non-English cultures, I expect it to always use Invariant Culture when parsing the code I write!

The problem here is that currently, the compiler is using the user set culture to parse numbers in x:Bind expressions!

I didn't change my code to mitigate this problem, but I had to change my system-wide culture to bypass it, something that should not be required...

In any case, good to know this is getting to the backlog, hopefully, it will get picked sooner rather than later.

For the record, I'm a former Windows Development MVP so I have also reported this on a certain DL list and discussed with a few of your colleagues.

All 4 comments

Just checking, but is there any update on this issue?

@PedroLamas , the short answer is that the compiler does not have support for non-English cultures. But the error you are getting is not something we were expecting, so we would like to take a look at it at some point in time. Moved to Backlog for now, we appreciate you reporting this issue.

@fabiant3 thank you, but I think you might have missed my point here a bit: I don't expect the compiler to support non-English cultures, I expect it to always use Invariant Culture when parsing the code I write!

The problem here is that currently, the compiler is using the user set culture to parse numbers in x:Bind expressions!

I didn't change my code to mitigate this problem, but I had to change my system-wide culture to bypass it, something that should not be required...

In any case, good to know this is getting to the backlog, hopefully, it will get picked sooner rather than later.

For the record, I'm a former Windows Development MVP so I have also reported this on a certain DL list and discussed with a few of your colleagues.

Thank you for the clarification @PedroLamas, that makes sense. A long time ago, the compiler used to support non-English cultures, but since then we switched it to invariant culture. It sounds like we still have some reminiscent issues in that space. We'll take a look as time permits.

Was this page helpful?
0 / 5 - 0 ratings