Automatically use object initializers during code cleanup
Answered
Is it possible to configure R# so that object initializers are automatically used during a code cleanup?
Example:
myParam = new SqlParameter();
myParam.ParameterName = "email";
myParam.SqlDbType = SqlDbType.NVarChar;
myParam.Value = user.Email;
cmd.Parameters.Add(myParam);
I want this during a code cleanup automatically reformatted to:
myParam = new SqlParameter
{
ParameterName = "email",
SqlDbType = SqlDbType.NVarChar,
Value = user.Email
};
cmd.Parameters.Add(myParam);
Right now I have to do this manually in a large files.
Please sign in to leave a comment.
Hello
Has this feature been added in ReSharper? I've searched the settings, I couldn't find anything that would allow that.
Best regards
Hello Armand,
Currently, there's no such option, please refer to the following feature request - https://youtrack.jetbrains.com/issue/RSRP-442195.
Thank you.