Search code examples
.netwcf.net-4.0optional-parametersnamed-parameters

Named and optional parameters, and WCF


so .Net 4 added named and optional parameters which are pretty sweet. I don't need to make as many 1 line overload methods.

Will that work over WCF?


Solution

  • Since these are compiler semantics I'd say no. However you'd expect them to work in the only following way.

    On the Service Code side all code would accept the defaulted parameters.

    On the client side I note that the 'Add Service Reference' tooling on VS2010 doesn't take the defaults and add them to the generated proxy. So You'd have to generate you're own proxy.

    In this way the client code can use the defaults if the the default is specified in the client side contract implementation.

    I would be that the same is true for the named parameters.

    All in all yes, but the stuff is not carried over WCF. All that happens is that the client proxy will have to send into the channel factory as a proper parameter.