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

Setting a type as design-time data context of a XAML control will cause issues in the code generator #42

Open
rezanid opened this issue Aug 21, 2024 · 6 comments

Comments

@rezanid
Copy link

rezanid commented Aug 21, 2024

Version of the Meziantou.Polyfill NuGet package

1.0.39

Description

Earlier today I faced a compilation issue, which I thought was related to upgrading .Net Framework to 4.8, but it turned out that it is related to this issue. In summary setting a type as design-time data context of a XAML control will cause issues in the code generator.

Reproduction Steps

  1. Take the following repo: https://github.com/rezanid/xrmtools
  2. Set the design-time data context of the AssemblySelectionDialog.xaml by adding the following line to the root element.
xmlns:ui="clr-namespace:XrmGen.UI" d:DataContext="{d:DesignInstance Type=ui:AssemblySelectionViewModel}"
  1. Build.

Other information

You might need the Extensibility workload of VS to be able to build.

@meziantou
Copy link
Owner

The linked project doesn't reference Meziantou.Polyfill. Could you provide a repro or the error message?

@rezanid
Copy link
Author

rezanid commented Aug 22, 2024

May bad, try this branch please: https://github.com/rezanid/xrmtools/tree/assembly-to-config-file

To reproduce you can replace line 10 (currently empty) of this file:
https://github.com/rezanid/xrmtools/blob/assembly-to-config-file/UI/AssemblySelectionDialog.xaml

with this:

xmlns:ui="clr-namespace:XrmGen.UI" d:DataContext="{d:DesignInstance Type=ui:AssemblySelectionViewModel}"

@meziantou
Copy link
Owner

I think this issue is because of the Design build, but I'm not an expert with this kind of special builds triggered by VS. This package is a standard source generator package. So, I don't know if there is something I can do to fix your issue. Maybe you can report the issue on VS to understand who can and how to fix that.

@rezanid
Copy link
Author

rezanid commented Aug 23, 2024

I didn't know there can be different kinds of builds. I will try to debug the generator to see if I can understand better what's happening.

@meziantou
Copy link
Owner

@rezanid
Copy link
Author

rezanid commented Aug 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants