Skip to content

Adding Dictionary<K,V> to XsdDataContractExporter adds KeyValuePair<K,V> as well #67949

Closed
@mconnew

Description

@mconnew

Description

When adding Dictionary<K,V> to XsdDataContractExporter, it also implicitly adds KeyValuePair<K,V> to the set. This is causing extra schema to be added when generating a WSDL in CoreWCF compared to .NET Framework.

Reproduction Steps

Add Dictionary<string,string> to XsdDataContractExporter then export all the schema.

Expected behavior

The schema will only contain an entry for ArrayOfKeyValueOfstringstring which corresponds to Dictionary<string,string>.

Actual behavior

The schema contains an entry for ArrayOfKeyValueOfstringstring and KeyValuePairOfstringstring (which corresponds to KeyValuePair<string,string>).

Regression?

This is a regression from .NET Framework.

Known Workarounds

Search for that schema in the resulting schema set and remove it.

Configuration

No response

Other information

The problem is caused by the code here which doesn't exist on .NET Framework. There is a comment that says this is needed for serializing JSON. This comment is obviously not correct as serializing JSON works fine on .NET Framework without this. I looked at the history and this code was there when .NET Core was open sourced and released on GitHub. I suspect this is some old code left over from when the code was originally ported from the silverlight version of .NET.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions