I work with resharper and when I clean my code I get this layout:
mock.Setup(m => m.Products).Returns(new List<Product>{new Product{Name = "Football", Price = 25}, new Product{Name = "Surf board", Price = 179}, new Product{Name = "Running Shoes", Price = 95}}.AsQueryable());
I'd rather have:
mock.Setup(m => m.Products).Returns(new List<Product>{
new Product{Name = "Football", Price = 25},
new Product{Name = "Surf board", Price = 179},
new Product{Name = "Running Shoes", Price = 95}
}.AsQueryable());
is this possible?
Choose ReSharper | Refactor | Inline | Inline… in the main menu. The Inline Method dialog will open. If you have invoked the refactoring at a method usage, you can clear the Inline all usages checkbox to inline only the current usage.
ReSharper provides both a quick-fix and a context action to transform assignment statements into C# object initializers, and both are called ReSharper provides both a quick-fix and a context action to transform assignment statements into C# object initializers, and both are called Product Blogs IDEs AppCode CLion DataGrip DataSpell Fleet GoLand
Besides, initializers are useful in multi-threading. Object initializers are used to assign values to an object’s properties or fields at creation time without invoking the constructor. If you create an object and then right after that assign values to its properties, ReSharper suggests using an object initializer.
Collection initializers can be used if a collection class implements IEnumerable or has an Add method. If you create a collection and then immediately populate it with items, ReSharper suggests using a collection initializer. In the following, ReSharper replaces invocations of the Add method with a collection initializer:
You should be able to do what you want by using the Resharper Options (Main Menu -> Resharper -> Options).
There are two places you need to look:
And here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With