When using "Introduce Using Statement" the whitespace (empty lines) in the code block are removed. (See attached screenshots)
Steps to Reproduce:
Select a code block with white space between lines of code and use "Introduce Using Statement" and the code will contract as the white space between lines of code is also removed.
For example:
[TestCase]
public static void IndexRedirectsToLandingPage()
{
// Arrange
AdminController controller = new AdminController();
// Act
ActionResult result = controller.Index();
// Assert
Assert.NotNull(result, "Expected non-null result");
RedirectToRouteResult routeResult = result as RedirectToRouteResult;
Assert.NotNull(routeResult, "Expected the result ot be a RedirectToRouteResult");
string controllerName = routeResult.RouteValues["Controller"] as string;
string action = routeResult.RouteValues["Action"] as string;
Assert.AreEqual("Admin", controllerName, "Expected the controller to be 'Admin'");
Assert.AreEqual("Home", action, "Expected the 'Home' action");
}
Actual Results:
[TestCase]
public static void IndexRedirectsToLandingPage()
{
// Arrange
using (AdminController controller = new AdminController())
{
// Act
ActionResult result = controller.Index();
// Assert
Assert.NotNull(result, "Expected non-null result");
RedirectToRouteResult routeResult = result as RedirectToRouteResult;
Assert.NotNull(routeResult, "Expected the result ot be a RedirectToRouteResult");
string controllerName = routeResult.RouteValues["Controller"] as string;
string action = routeResult.RouteValues["Action"] as string;
Assert.AreEqual("Admin", controllerName, "Expected the controller to be 'Admin'");
Assert.AreEqual("Home", action, "Expected the 'Home' action");
}
}
Expected Results:
[TestCase]
public static void IndexRedirectsToLandingPage()
{
// Arrange
using (AdminController controller = new AdminController())
{
// Act
ActionResult result = controller.Index();
// Assert
Assert.NotNull(result, "Expected non-null result");
RedirectToRouteResult routeResult = result as RedirectToRouteResult;
Assert.NotNull(routeResult, "Expected the result ot be a RedirectToRouteResult");
string controllerName = routeResult.RouteValues["Controller"] as string;
string action = routeResult.RouteValues["Action"] as string;
Assert.AreEqual("Admin", controllerName, "Expected the controller to be 'Admin'");
Assert.AreEqual("Home", action, "Expected the 'Home' action");
}
}
Hi Colin,
Thank you for the report. This is a limitation of the current version of the refactoring. We have a suggestion to improve this functionality in the future. You can learn our progress over this item by tracking the following report:
CodeGen - Add options to specify code generation rules
Thanks,
Serge