regex - .net webservice proxy class organization/regular expression to match c# class definition -
i'm working .net webservice has several hundred methods in it. (i've no control on webservice, can't refactor it).
however i'm working client side of , i've generate client side proxy class whenever changes in ws. (and changes quite often).
i generate proxy class using wsdl.exe.
wsdl.exe http://url.asmx /o:proxy.cs /n:my.name.space
this generated proxy class contains classes return types, input types used in ws.
imagine example:
i've dto assembly called my.application.dto.dll contains class called mydtoclass. assembly referred both webservice project , windows app project calls webservice through proxy class.
imagine webservice has method this
[webmethod] public mydtoclass getsomedtomethod(int id) { ... }
now when generate proxy this, proxy contain definition mydtoclass. inside different namespace of course.
then use proxy class follows:
my.application.dto.mydtoclass dto; dto = wsproxy.getsomedtomethod(x);
this fails saying unable cast webservice.namespage.mydtoclass my.application.dto.mydtoclass because proxy class has own definition of mydtoclass.
if delete class definition in proxy class works fine.
i've manually edit generated proxy class remove these duplicate class definitions work again.
since file huge not easy. , order of these classes changing every generation.
i've tried solve in following ways, none of them did job (or couldn't them to)
- somehow prevent wsdl generating these class definitions proxy. decorating methods attribute example. couldn't find way that.
- automate editing of generated proxy class using powershell. i'm thinking of matching lines defining class using regurlar expression, , delete them file.
- get wsdl generate code elements in predictable order editing becomes easy
i appreciate if can me out of issue.
currently i'm biased towards second option. if can me regular expression match c# partial class definition including new lines, helpful. (in powershell regex flavor, if not ask)
if use "add service reference", can configure reuse types in external assemblies. cannot "add web reference".
Comments
Post a Comment