Bug 14609 - Data contract name is not correct for a generic type
Summary: Data contract name is not correct for a generic type
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-09-10 12:50 UTC by Jon Goldberger [MSFT]
Modified: 2013-09-28 20:59 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
test project (468.77 KB, application/zip)
2013-09-10 12:50 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 14609 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Jon Goldberger [MSFT] 2013-09-10 12:50:47 UTC
Created attachment 4826 [details]
test project

I'm having the same problem as described here.

For example: [DataContract] public class SomeGenericClass {...}

.NET will determine the data contract name using the name of T and a hash of the type's namespace name. The hash is important to avoid contract name collisions. The possibility of collisions may sound remote, but in our case we can use types such as ModelA.Customer and ModelB.Customer, and a data contract name formed only from the type name, such as "SomeGenericClassOfCustomer", is insufficient.

Xamarin does not appear to support the hash in the data contract name, either by default or passed with the name parameter. For example, the following will fail with a System.ArgumentException - "localName must be a valid NCName.":

[DataContract(Name="SomeGenericClassOf{0}{#}")]
public class SomeGenericClass<T> {...} 
Granted, complex data contracts like this are not a good idea, but we have a legacy WCF service that supports a number of different clients, and data contract name interoperability is important for us.

Are there any plans to make this work the same as it does in .NET?