Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Issue with arrays in expression when using DotNetCompilerPlatform #2890

Closed
@neoGeneva

Description

@neoGeneva

Hey, not 100% sure if this an MVC issue or Roslyn issue, but the issue exists when using DotNetCompilerPlatform 1.0.0.0 and MVC 5.2.3.0

The issue is that array variables used in an array get the wrong name (the end up being prefixed with "CS$<>8__locals1.") when used with HtmlHelper expression methods, eg Html.NameFor()

Steps to reproduce:

  1. In VS2015 create a new MVC5 project using the ASP.NET 4.6 template "MVC" (which already has Microsoft.CodeDom.Providers.DotNetCompilerPlatform installed)
  2. Replace the content /Views/Home/Index.cshtml with the razor code below
  3. Start the project and view the result in a browser.
@{
    Layout = null;

    var someArray = new[]
    {
        new
        {
            someProperty = ""
        }
    };
}


<html>
<body>
    @Html.NameFor(_ => someArray[0].someProperty)<br />

    @for (var i = 0; i < someArray.Length; ++i)
    {
        @Html.NameFor(_ => someArray[i].someProperty)<br />
    }
</body>
</html>

The content of the page looks like the following, when the two rows of the output should be identical.

someArray[0].someProperty
CS$<>8__locals1.someArray[0].someProperty

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions