Generating object initializers with ReSharper
ReSharper provides both a quick-fix and a context action to transform assignment statements into C# object initializers, and both are called “Use object initializer”.
So what’s the difference between them?
Suppose that you create an object with three assignment statements:
Putting the caret over the “new” keyword lets you apply a quick-fix that will put all assigned fields into an object initializer:
Putting the caret over the object variable or a field name in any of the tree assignment statements lets you apply a context action that will put only this assignment in the object initializer:
That is, using the context action, you can selectively put field assignments into the object initializer, leaving some of them to be declared explicitly.
Subscribe to Blog updates
Creating Custom AI Prompts
AI has swept through the software development industry like a wildfire. So people want to learn how to best use AI in their day to day tasks. In this post we’ll take a look at how to write custom prompts for use with the JetBrains AI Assistant in ReSharper and Rider so you can make the most of AI.&n…
12 Debugging Techniques In JetBrains Rider You Should Know About
Twelve must know debugging features in JetBrains Rider every developer should know.
Interceptors – Using C# 12 in Rider and ReSharper
Welcome to our series, where we take a closer look at the C# 12 language features and how ReSharper and Rider make it easy for you to adopt them in your codebase. If you haven’t yet, download the latest .NET 8 SDK and update your project files! In this series, we are looking at: Primary …