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

Crash in VS when editing @(@ #804

@jodavis

Description

@jodavis

Create a new MVC View Page in an ASP.NET Core Web Application, and add the following at the top of the view page:

@{
    var @do = "do";
}

Then attempt to type <div>@(@do) in the view page.

Result:
VS crashes shortly after @(@

System.InvalidCastException: Unable to cast object of type 'Microsoft.AspNetCore.Razor.Chunks.TemplateChunk' to type 'Microsoft.AspNetCore.Razor.Chunks.ExpressionChunk'.
   at Microsoft.AspNetCore.Razor.CodeGenerators.Visitors.CSharpCodeVisitor.RenderDesignTimeExpressionBlockChunk(ExpressionBlockChunk chunk)
   at Microsoft.AspNetCore.Razor.CodeGenerators.Visitors.CSharpCodeVisitor.Visit(ExpressionBlockChunk chunk)
   at Microsoft.AspNetCore.Razor.CodeGenerators.Visitors.ChunkVisitor`1.Accept(Chunk chunk)
   at Microsoft.AspNetCore.Razor.CodeGenerators.Visitors.ChunkVisitor`1.Accept(IList`1 chunks)
   at Microsoft.AspNetCore.Razor.CodeGenerators.CSharpCodeGenerator.Generate()
   at Microsoft.AspNetCore.Razor.RazorTemplateEngine.GenerateCodeCore(ITextDocument input, String className, String rootNamespace, String sourceFileName, String checksum, Nullable`1 cancelToken)
   at Microsoft.AspNetCore.Razor.RazorTemplateEngine.GenerateCode(ITextBuffer input, String className, String rootNamespace, String sourceFileName, Nullable`1 cancelToken)
   at Microsoft.AspNetCore.Razor.Editor.BackgroundParser.BackgroundThread.ParseChange(ITextBuffer buffer, CancellationToken token)
   at Microsoft.AspNetCore.Razor.Editor.BackgroundParser.BackgroundThread.WorkerLoop()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions