Project Description

This project takes, as input, .NET assemblies or class libraries which are neither serializable by the WCF DataContractSerializer nor compatible with Silverlight (SL) , and generates as output, the assembly in WCF-serializable and SL-compatible form. That is, the classes and structs from the source assembly will be output in their equivalent data representation (all properties but not methods). This project makes use of T4 Text Templates.

This project saves the development effort of having to modify the class library with DAL which other applications may currently rely on. Instead you can adapt the old, incompatible assembly to WCF 4.0 and Silverlight 4 by auto-generating a new, yet functionally equivalent assembly. This eliminates the worry of breaking existing code.

Additionally, this project contains a T4 Text Template project that will auto-generate methods to convert types from your source assembly to their WCF-serializable/SL-compatible type counterparts in the destination class library. This is useful for when your DAL is tightly coupled to the data classes in your source assembly. The conversion methods will marshal those types from the DAL to their serializable forms so that they can be serialized across WCF/SL boundaries.


Other benefits:
- You can request the data objects you need directly and minimize payload size, without necessitating encapsulating the data in some container class or a SOAP Message. You can bypass the overhead of these extra layers and can use options such as JSON and REST services (WebHttpBinding) or net.tcp protocol (NetTcpBinding or CustomBinding).

Why not use svcutil.exe to auto-generate the classes? svcutil.exe will actually fail to generate classes from your assembly if it detects that they are not serializable by DataContractSerializer.

What the source code solution contains:
- T4 Text Templates projects, configurable with application settings. For example, you can specify the output paths, namespace mappings, or types to exclude.
- T4 Text Template to auto-generate the new WCF/SL compatible classes.
- T4 Text Template to generate Type conversion methods from your source assembly to the new, generated class library.
- Example Northwind projects and Unit Test projects which demonstrate (1) how a source assembly can fail to serialize, and (2) how the T4-generated classes which the project creates will successfully serialize.
- MSBuild tasks to automate the process from start to finish

Who might find this useful:
- if your .NET class library is designed for highly-customized serialization, or to be backwards-compatible for .ASMX web services.
- if you'd like to minimize your WCF response size, fetch only the data objects you need, and have other options besides SOAP Messages.
- if your .NET assembly's classes don't serialize with DataContractSerializer.
- if your .NET assembly's classes are incompatible with Silverlight.

Feel free to send feedback or suggestions, or requests for documentation.

blog.

Last edited Jun 2, 2011 at 12:14 AM by TWebster, version 4