Runtime: WPF on .NET Core needs updated TypeConverters for Uri and Enum

Created on 3 Oct 2018  路  7Comments  路  Source: dotnet/runtime

Xaml parsing requires TypeConverters to be implemented and work a certain way.

We have been working on getting some of our Xaml tests running against .NET Core 3, and also porting PresentationBuildTasks to work on .NET Core 3. In the process, we have encountered some problems with UriTypeConverter and EnumConverter.

There are two issues we have seen so far:

  • The .NET Core implementation is missing ConvertTo semantics for TypeDescriptor. This applies to both UriTypeConverter and EnumConverter
  • System.Uri is missing [TypeConverterAttribute(UriTypeConverter)].

I have a working fix for UriTypeConverter to add support for TypeDescriptor.

cc @ericstj, @rladuca

Hackathon area-System.ComponentModel up-for-grabs

Most helpful comment

I have a fix for these, grabbing this issue.

All 7 comments

/cc @safern

Probably related to https://github.com/dotnet/corefx/issues/32600.

The .NET Core implementation is missing ConvertTo semantics for TypeDescriptor. This applies to both UriTypeConverter and EnumConverter

@vatsan-madhavan-msft can you point to the the specific code on https://referencesource.microsoft.com/ that's missing, of elaborate with a sample to help folks identify what needs to come back?

System.Uri is missing [TypeConverterAttribute(UriTypeConverter)].

The .NETCore implementation of TypeConverter is higher in the stack then URI so it uses a static table to apply typeconverters to types below it: https://github.com/dotnet/corefx/blob/a5c7e7295ac2e3c889d347d0285794266797db87/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs#L128

The .NET Core implementation is missing ConvertTo semantics for TypeDescriptor

Did you mean InstanceDescriptor? https://referencesource.microsoft.com/#System/compmod/system/componentmodel/EnumConverter.cs,172

We recently added this to DateTimeConverter -- https://github.com/dotnet/corefx/pull/31558

@safern Yeah I think InstanceDescriptor is missing. For some reason folks excluded this from the initial commits.

https://github.com/dotnet/corefx/commit/aa2a05613e798ea173c2dc32cc78ebcea17fface#diff-7f45f23a644275c5e7cdb8ef12369fb9R86
vs
https://referencesource.microsoft.com/#System/net/System/_UriTypeConverter.cs,84

https://github.com/dotnet/corefx/commit/bf20e99b349b6ee5d9dfa4e6a7cb13088c47b979#diff-ef240985beb99aa2918fe7135a03b201R127
vs
https://referencesource.microsoft.com/#System/compmod/system/componentmodel/EnumConverter.cs,172

Probably because at the time the type wasn't there and was later brought back. It probably makes sense for someone to do an audit of these cases.

Also from looking at some data comparing what converters in full framework can convert to InstanceDescriptor I found that NullableConverter is missing that as well.

https://github.com/dotnet/corefx/blob/master/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs#L90
vs
https://referencesource.microsoft.com/#System/compmod/system/componentmodel/NullableConverter.cs,83

I have a fix for these, grabbing this issue.

Yes, InstanceDescriptor it is. Right now, there are not good reproes - either the reproes are blocked (presentationbuildtasks work, for e.g.) or band-aided (I have some hacks in place to get UriTypeConverter to work in our current System.Xaml .NET Core implementation). Your references/links from referencesource looks right to me.

cc @ryalanms

Yes, the PresentationBuildTasks port has temporary InstanceDescriptor converters in the markup compiler that will need to be replaced when InstanceDescriptor conversion support is added.

Was this page helpful?
0 / 5 - 0 ratings