Include Extension Methods in Generated Proxies File

190 Views Asked by At

We have two assemblies, DataContracts and Core. We are currently using svcutil to generate our DataContracts, while referencing Core. We've got a couple of extension methods on different enum types that would be useful on the client side.

Is there any way to get svcutil to include these extension methods into our generated proxies file?

2

There are 2 best solutions below

1
SliverNinja - MSFT On BEST ANSWER

Any methods that you want exposed you need to have as part of the operational contract. I don't know of any other way to expose the metadata in the WSDL without learning more about how the WSDLImporter works. Irregardless - Metadata is only contracts - you can't share operations/behaviors in your metadata. The only way to share method behaviors (your extensions) is to include them in the shared contract/core assembly or expose them as operation contracts.

1
Laurentiu M On

The classes generated by svcutil are partial. Therefore the functionality of those classes can be split in multiple files. One file is the one generated by the svcutil with the functionality exposed by the service. Other files could contain the functionality you want to append, which is not part of the data contract.

More info on partial classes Partial Classes and Methods (C# Programming Guide) on MSDN