c# - Find all references with WCF OperationContract and DataContracts -


i'm trying figure out if there's way "find references" (using vs feature, opposed control+f entire solution). when comes wcf data , operationcontracts. in case unclear:

namespace wcftestreferences {     class program     {         static void main(string[] args)         {             console.writeline("hello world");              dostuff();              servicereference1.service1client client = new servicereference1.service1client();             var results = client.getdata(42);              console.writeline(results);         }          static void dostuff() { }     } }  namespace wcftestreferences.wcfapp {     [servicecontract]     public interface iservice1     {         [operationcontract]         string getdata(int value);     }      public class service1 : iservice1     {         public string getdata(int value)         {             return string.format("you entered: {0}", value);         }     } } 

solution looks this:

enter image description here

now, if @ dostuff() code lens, can see in fact has reference it:

enter image description here

but same not hold true methods being called in wcf service:

enter image description here enter image description here

in above, references interface/method interface/method. understand reference hoping there (from main method):

var results = client.getdata(42); 

is not there, because client generated, , not service1 implementation... there way change this?

in real world, have wcf layer thousands of methods, many of not used - cannot rely on code lens/find references make determination. there way change behavior?

because client generated, , not service1 implementation

this root of problem.

you correct - there no way code analyser determine getdata() call making client semantically same thing getdate() service operation have defined on interface, because binary perspective defined in 2 different types.

the root of you're using service reference. wcf provides service references default way of connecting service, in opinion service references problematic , should avoided.

luckily, wcf provides way of consuming , calling service via user of channelfactory<t>. 1 of many benefits when using instead of service reference client have use of service interface via binary reference assembly containing service definition.

this allow tools code lens resolve references interface methods directly consuming clients.


Comments