New CodeRush Community Plugin – DX_GenerateProxy


Generates a new Proxy class P based on source class S


What this amounts to is a new class P which is given properties and methods matching the public ones that are possessed by S.
When methods or properties of S are called their implementation defers to the instance of P held internally.


  • I’m beginning to prefer working in terms of interfaces where possible. I like to mock interfaces rather than classes where possible.
  • I don’t like to modify generated client-side web-service code. This therefore means that I don’t like to extract interfaces from said code.

The solution to this problem is to wrap the client-side web-service code in a proxy of my own from which I can extract an interface without having to alter the client-side web-service itself..

So given a web-service (W1), I can create a proxy (W1_Proxy) with all the same methods and properties as the original class. I can extract an interface from W1_Proxy and write my client-side code in terms of this interface. During testing I can implement this interface a second time in a test class (or more likely I can mock the interface), and pass this to the same code.

This gives me

  • Client code that doesn’t depend on a specific implementation of a service
  • Client code Tests that don’t depend on the web-service in order to run and prove my code works.
  • A good feeling of having done things the right way.


Currently this CodeProvider only acts on Class declarations for which you have source code. a Later revision will add a facility to generate a proxy for compiled types.


Let’s start with the following code…


Place the caret on the name of the class and then press your CodeRush Refactor key


…and the following code will be generated for you…


Download DX_GenerateProxy

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.