dotnet / dotnet/roslyn

IntelliSense when writing lambdas is difficult

Open
#85,647 3 comments 0 reactions 0 assignees View on GitHub
Area-Razor
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

_DavidW: Title was "Bring back the legacy editor"_

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Bring-back-the-legacy-Razor-editor/11060985)._

---
[severity:It's more difficult to complete my work]
The new Razor editor still has terrible issues with formatting and Intellisense. It is still not production ready. This significantly slowing down my work in views. Please bring back the legacy editor until major improvement can be made to the new editor.

Some of the most common issues I have ran into are the following:

Intellisense does not recognize x when starting a lambda expression and instead tries to correct to XmlConfigurationExtensions every time writing something like @Html.DisplayFor or OrderBy

Curly brackets are randomly placed on the next line sometimes and not following the setting to keep the opening curly bracket on the same line.

Format document sometimes does not working cshtml files

Sometimes a large section of the current HTML node tree stays highlighted instead of just the currently selected element. This section stays highlighted until you click out of the entire section

---
### Original Comments

#### Feedback Bot on 17/03/2026, 03:54 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

#### David Wengier [MSFT] on 18/03/2026, 03:03 PM:

Thanks for reporting this. There are a few issues here, so let me try to address them one at a time.



  1. Intellisense when starting a lambda: That sounds like a real bug. Could you possibly record what you’re seeing when this happens, just so we’re definitely understanding

  2. Curly brackets randomly places on the next line: Does this happen when you format the document, or just when you press Enter, or type the curly bracket? If its the former, see below for some next steps.

  3. Formatting sometimes doesn’t work: There are a few places where we deliberate abandon formatting if we detect it might break your code. We do have extra logging that you can opt-in to, which can help us work out if this is what you’re seeing, and/or fix the issue if its a false positive. See https://github.com/dotnet/razor/blob/main/docs/Formatting.md#formatting-appears-to-do-nothing for details

  4. Large section stays highlighted: This is an editor bug that you can track at its own bug report, here: https://developercommunity.visualstudio.com/t/HTML-tag-completion-is-incorrectly-leavi/11060779

#### Alex Tiller on 20/03/2026, 11:20 AM:

First issue.

I created a new project using the ASP.NET Core Web App (Model-View-Controller) and accepted all defaults. I created a HomeViewModel class with a List<string> property and added it as the model on the Home/Index page. Then try to order the list in the foreach loop. Intellisense tries to autocorrect to a class. I normally use x but using other variable names causes a similar issue

Image


The second and third might be linked. I noticed that I’m getting an error in the Razor Formatting Feature when these two issues happen. Here’s the error it’s showing:


StreamJsonRpc.RemoteInvocationException: Ran out of formatted lines while trying to process formatted changes after 16 lines. Abandoning further formatting to not corrupt the source file, please report this issue.

at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__1711.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection1.<TryInvokeAsync>d__181.MoveNext() RPC server exception: System.InvalidOperationException: Ran out of formatted lines while trying to process formatted changes after 16 lines. Abandoning further formatting to not corrupt the source file, please report this issue. at Microsoft.CodeAnalysis.Remote.Razor.ThrowingErrorLoggerProvider.Logger.Log(LogLevel logLevel, String message, Exception exception) at Microsoft.CodeAnalysis.Razor.Logging.AbstractLoggerFactory.AggregateLogger.Log(LogLevel logLevel, String message, Exception exception) at Microsoft.CodeAnalysis.Razor.Logging.ILoggerExtensions.LogError(ILogger logger, ErrorLogMessageInterpolatedStringHandler& message) at Microsoft.CodeAnalysis.Razor.Formatting.FormattingUtilities.GetOriginalDocumentChangesFromLineInfo(FormattingContext context, SourceText originalText, ImmutableArray1 formattedLineInfo, SourceText formattedText, ILogger logger, Func2 shouldKeepInsertedNewlineAtPosition, PooledArrayBuilder1& formattingChanges, Int32& lastFormattedTextLine)

at Microsoft.CodeAnalysis.Razor.Formatting.CSharpFormattingPass.ExecuteAsync(FormattingContext context, ImmutableArray1 changes, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Razor.Formatting.RazorFormattingService.GetDocumentFormattingChangesAsync(DocumentContext documentContext, ImmutableArray1 htmlChanges, Nullable1 range, RazorFormattingOptions options, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_01.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext()

— End of stack trace from previous location —

at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func2 implementation, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func2 implementation, CancellationToken cancellationToken)

at Microsoft.CodeAnalysis.Remote.RemoteWorkspaceManager.RunServiceAsync[T](ServiceBrokerClient client, Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)

#### unknown_temp on 20/03/2026, 02:42 PM:

Thanks for the info Alex Tiller. I’m going to move this issue over to our GitHub repo for the IntelliSense issue, so this one will be closed out. For the formatting, that exception is expected when formatting sees something it can’t handle. We’ve fixed about a half dozen different scenarios for this over the past two months, so its likely that the next major update will fix the issue for you. The current Insiders might even do so, if you want to try that (it installs happily side-by-side with stable too, as an option). If not, or if you don’t want to just wait and see, please check the link for formatting logs in my previous comment and create a new issue and I’d be happy to verify. In general I’d recommend separate issues for things anyway, so we can be sure nothing gets lost in the shuffle. Thanks again for reporting the IntelliSense bug though, I don’t see anything existing for it on our GitHub repo so it’s a good find!

Contributor guide

Open the contributing guide

Research direction

Reproduce the IntelliSense problem in an ASP.NET Core MVC project using HomeViewModel, Home/Index, a List, and an OrderBy or foreach lambda as described. Start by isolating the IntelliSense behavior from the separate formatting reports; done means lambda variables are suggested and retained instead of being autocorrected to a class name.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.