Create immutable class from constructor reference

 

I often find myself writing something like this:
 

 
 

            int a = 1;
 

            string s = "test";
 

 
 

            var m = new MyNewClass (a,s);
 

 
 

Is it possible to use Resharper to create MyNewClass with a constructor which populates readonly backing fields with property getters.  i.e. a typical immutable class.
 

Note, that Visual Studio does some of this (i.e. creates the class with constructor setup) but with Resharper installed this function does not seem available and will only create an empty class.
 

1 comment
Comment actions Permalink

C# 6.0 should make it a little easier, but it won't be released for a while.

http://damieng.com/blog/2013/12/09/probable-c-6-0-features-illustrated

0

Please sign in to leave a comment.