Automatically use object initializers during code cleanup

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.