How can I use resharper refactoring to make an object that uses the initalizer object immutable?

I have several summary objects that look like this:

public class ObjectSummary : ISummary { public int Id { get; set;} public string Name { get; set;} ... // other fields } 

With a usage example that looks like this:

 public ISummary Summarize() { return new ObjectSummary { Id = _id, Name = _name, .... // etc with other fields }; } 

And I'm trying to reorganize all instances like this (make them immutable):

 public class ObjectSummary : ISummary { public ObjectSummary(int id, string name,..., /* other params*/) { Id = id; Name = name; } public int Id { get; private set;} public string Name { get; private set;} // other fields } public ISummary Summarize() { return new ObjectSummary(_id, _name,..., /*other params*/); } 

How can I reorganize an object that uses the object initializer to make it immutable (also moving the set logic from the object initializer to the constructor)?

+6
source share

All Articles