fsprojects / FsXaml

F# Tools for working with XAML Projects
http://fsprojects.github.io/FsXaml/
MIT License
171 stars 48 forks source link

Type mismatch of XamlResourceAccessor when working with ResourceDictionary #25

Closed M0ns1gn0r closed 8 years ago

M0ns1gn0r commented 9 years ago

I try to build a XamlProvider on a ResourceDictionary file: type MyResourceDictionary = XAML<"MyResourceDictionary.xaml", true>

After I compile the project, the following error appears:

The type provider 'FsXaml.XamlTypeProvider' reported an error: Type mismatch when splicing expression into quotation literal. The type of the expression tree being inserted doesn't match the type expected by the splicing operation. Expected 'FsXaml.XamlResourceAccessor', but received type 'FsXaml.XamlResourceAccessor'. Consider type-annotating with the expected expression type, e.g., (%% x : string) or (%x : string).

If I remove the true parameter, it compiles, but the whole point of creating a provider gets lost. Here is a sample project.

P.S. Win7 x64 + VS 2013 Community SP4 + F# 3.1

ReedCopsey commented 8 years ago

FsXaml 2 is dropping support for named keys in resource dictionaries. This isn't really supported in the C# world, and the use case seemed limited enough that I'm not sure it's that useful. There were quite a few issues with supporting it in the code, and the usefulness was pretty limited (other than having a real type, which is very useful).

You will still be able to create the RD as a type (using XAML<...>), but will just have to access keyed values as a normal dictionary, ie: dict.["YourKey"] :?> TheType