dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
491 stars 190 forks source link

CSharpExplicitExpression not being parsed inside TagHelpers #7053

Open ryanbrandenburg opened 3 years ago

ryanbrandenburg commented 3 years ago

To Reproduce

  1. Open a .razor file and add the following: <DynamicComponent Type="typeof(Counter)" Parameters="@(new Dictionary<string, object> { { "IncrementAmount", 10 }})" />
  2. Observe the Expression type of @(...).

Expectation

@(...) should be parsed as a CSharpExplicitExpression.

Actual

@(...) is parsed as a CSharpImplicitExpression with Children CSharpExpressionLiterals: ['(', 'new Dictionary<string, object> { { "IncrementAmount", 10 }}', ')']

Effect

This causes strange coloration in some Razor scenarios. The ( and ) don't get SemanticColorization because Razor sees them as CSharpExpressionLiterals and expects CSharp to take care of it, but CSharp doesn't have a mapping (or possibly never even generated them in the backing document) so it doesn't produce anything for them. So whatever TextMate is reporting gets blindly used, and that could be way off of the expectation.

This was a user reported issue (https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1389362), so these are things that our users really do.

Further technical details

ryanbrandenburg commented 3 years ago

I just realized that the user who filed this was @danroth27 lol. Still, this is not how you'd expect things to behave and I would expect more users to run into this as they use it.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.