R#6 now giving false-positive errors (not just warnings) in XAML

Only just noticed this in 2083/2084 (wasn't there a week or so ago), but R# is now claming that x:Name="MyName" is invalid - the error it gives is:

"Resources of value types and types without a default constructor can't have x:Name attribute"

This is for an x:Name on the definition of a UserControl-derived class - it's true that the class doesn't have a default constructor, but neither WPF nor VS is worried about that, and until last week R# wasn't either.

You can't use Name rather than x:Name, because then you get a genuine error at build time:

error MC6023: Because 'MyBaseControlType' is implemented in the same assembly, you must set the x:Name attribute rather than the Name attribute. Line 6 Position 25.

While I'm moaning about R#'s somewhat erratic WPF support, it also has problems with d:DataContext, for example:

xmlns:my="clr-namespace:MyProjectNamespace"
d:DataContext="{d:DesignInstance my:Screens.MyViewModel, IsDesignTimeCreatable=True}"

In this case, the "xmlns:my="clr-namespace:MyProjectNamespace"" attribute is shown as dead code, and the XAML file is marked as 'orange', but obviously you can't remove it without breaking the d:DataContext attribute - although R# goes from orange to green, the file then doesn't compile.

It would be good if R# could correctly interpret d:DataContext, because perhaps then it could correctly associate ViewModel properties with bindings in XAML views, which would avoid a lot of false-positive warnings about unused properties on ViewModel classes (I use JB attributes to turned them off at the moment).

Please sign in to leave a comment.