Visual Studio Extension - Cannot Import Any Converters in User Control XAML When Using Metalama

15 hours ago 1
ARTICLE AD BOX

In my extension, there is a tool window with a WPF UserControl. For one of the bindings, I am attempting to implement an enum <--> string value converter. I have my converter defined:

enter image description here

and Visual Studio sees it:

enter image description here

However the project won't build. There are no errors after I fully added it, but if I add it then close Visual Studio, delete the hidden .vs folder, as well as the bin & obj folders (based on suggestions I have seen), re-open the solution, do a clean of the solution, and then rebuild the solution, I get a bunch of errors:

enter image description here

If I take out

<converters:EnumToStringConverter x:Key="EnumToStringConverter"></converters:EnumToStringConverter>

from the UserControl.Resources section, then the solution builds with no issue. Notice that the BooleanToVisibilityConverter (the built-in one) works fine. I have also tried recreating the converter with different names in different namespaces, as well as adding a parameterless constructor in the converter (this was another suggestion I had seen) but the issue persists. Is this a limitation of VSIX projects or is there some other requirement to bring in resources from another namespace within the project?

Update #1

After further investigating, this seems to be due to some conflict with Metalama. I am using their Track Changes Sample (without modification) and the build is failing on the statements which use the methods it creates. If I comment out the highlighted section below: enter image description here

then the code builds fine. Otherwise, I can leave that code in (which is tested and working as expected), but I need to take out the

<converters:EnumToStringConverter x:Key="EnumToStringConverter"></converters:EnumToStringConverter>

definition. Again, the built-in converter (i.e., BooleanToVisibilityConverter) does not cause this issue, but there appears to be some conflict between how WPF handles these types of resources and the Metalama build transformation process. Even adding the Metalama.Patterns.Wpf package did not help. Therefore, I have also opened a GitHub issue on their page but still hoping someone here has some suggestions.

Read Entire Article