ASP.NET 4.0 Razor View code clean up cause error.

Sep 19, 2012 at 3:42 AM
Edited Sep 19, 2012 at 3:43 AM

I tried to use resharper to clean up the following .cshtml (ASP.NET MVC Razor view) file:

@if (Roles.IsUserInRole(WebSecurity.CurrentUserName, "Administrators"))

{

    @:@this.Html.MenuItem("Users", "List", "User", null, new { title = "Manage users" })

    @:@this.Html.MenuItem("Roles", "List", "UserRole", null, new { title = "Manage user roles" })

}

The clean up result is:

@if (Roles.IsUserInRole(WebSecurity.CurrentUserName, "Administrators"))
{@:@this.Html.MenuItem("Users", "List", "User", null, new { title = "Manage users" })@:@this.Html.MenuItem("Roles", "List", "UserRole", null, new { title = "Manage user roles" })
}
The two lines inside the @{..} code block are combined to one line, which cause runtime error:

 ":" is not valid at the start of a code block.  Only identifiers, keywords, comments, "(" and "{" are valid.

How to Resolve it ?

About information:

JetBrains ReSharper 7.0.1 Full Edition

Build 7.0.1098.2760 on 2012-08-27T08:31:12

 

Licensed to: wub

Plugins: 1

#1. “StyleCop (4.7.37.0)” v4.7.1000.0 by http://stylecop.codeplex.com

Visual Studio 11.0.50727.1.

 

Copyright © 2003–2012 JetBrains s.r.o. All rights reserved.

Coordinator
Sep 19, 2012 at 1:07 PM

That looks like a ReSharper issue and not a StyleCop bug. Open an issue with jetbrains.com