Fix to Generate Contract Code for Dates

Here's a bonus entry left from last week. Last week I ran a series covering fixes for WCF that may be hard to find and explaining the details behind each problem.

Contract code generation takes a system-independent description of the types used for a messaging operation and generates source code instructions for working with those types. XML schema is an example of a definition language for describing a set of type constraints. Some of the constraints in an XML schema may map very easily to source code in the target language that you're using while other constraints may only map with considerable difficulty. An imperfect map generally results in a source code type that is a broader substitute for the intended type.

The reference importer in svcutil uses type equivalence to recognize types in assemblies that represent the metadata being imported. When there is an imperfect map, the contract type may differ from the mapped type even though it is the closest equivalent to the mapped type. For example, there is an imperfect map for the XML schema date data type because in C# there is no way to express dates independently of times.

In the original code this means that a date in a schema is mapped to the broader string type, which is not equal if compared again to the original date data type. This causes source code generation to fail when referencing an existing contract that has one of these broadening conversions. The fix changes the notion of equivalence when comparing types to identify the output of a broadening operation as still being equal when comparing type references.

This fix is available for download from KB article 960415.