meziantou / Meziantou.Polyfill

MIT License
40 stars 1 forks source link

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

Open rezanid opened 3 weeks ago

rezanid commented 3 weeks ago

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}"
  3. Build.

Other information

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

meziantou commented 3 weeks ago

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

rezanid commented 3 weeks ago

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 commented 3 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

You can use https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools2022 to track all builds in VS.

rezanid commented 2 weeks ago

👍🏼

Best regards, Reza


From: Gérald Barré @.> Sent: Friday, August 23, 2024 5:22:49 PM To: meziantou/Meziantou.Polyfill @.> Cc: Reza @.>; Author @.> Subject: Re: [meziantou/Meziantou.Polyfill] Setting a type as design-time data context of a XAML control will cause issues in the code generator (Issue #42)

You can use https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools2022 to track all builds in VS.

— Reply to this email directly, view it on GitHubhttps://github.com/meziantou/Meziantou.Polyfill/issues/42#issuecomment-2307312045, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADLIVMGAQZWYRLIJND6I7N3ZS5HUTAVCNFSM6AAAAABM33MKGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXGMYTEMBUGU. You are receiving this because you authored the thread.Message ID: @.***>