.razor parsing forces code blocks, even in functions block
See original GitHub issueDescribe the bug
The compiler does not allow “single-statement control flow statements” In the “cshtml” part of a .razor file. I understand that is required, but currently it also enforces this rule in the “@functions” block. My understanding was that in the @functions block any normal c# syntax can be used.
To Reproduce
“dotnet new blazorserverside” Edit the “components.razor” file and replace the “IncrementCount” function with:
void IncrementCount()
{
if (true)
currentCount++;
}
Expected behavior
It should not give a compile time syntax error
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Multiple code blocks in Razor and Parser Error
I have an issue in my MVC site. I have a using and a fieldlist in that, and in that a code block....
Read more >Ten Tricks for Razor Views
1. Code Blocks and Variables. In Razor you can create blocks of code nearly anywhere using @{ }. A block of code doesn't...
Read more >Razor syntax reference for ASP.NET Core
Razor is a markup syntax for embedding .NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files...
Read more >Help me understand AutoCompletion and .. ...
The project I am working on is currently small, only about 20 files total, but includes many wxWidgets widgets. It still cannot parse...
Read more >ScottGu's Blog - ASP.NET MVC 3: Razor's @: and <text> syntax
One of the techniques that Razor uses to implicitly identify when a code block ends is to look for tag/element content to denote...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/aspnet/AspNetCore-Tooling/commit/cf474c97aa560268abc2334e12799c7c767e356f
Still working on fixing this 😃