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.
"dotnet new blazorserverside"
Edit the "components.razor" file and replace the "IncrementCount" function with:
void IncrementCount()
{
if (true)
currentCount++;
}
It should not give a compile time syntax error
I would also like to support the code without using {}
We are able to reproduce this.
(This appears to be a regression in preview4 compared to preview3.)
Using VS 2019 16.1 Preview 2 with 3.0.0 Preview 4
I am facing the same issue using VS2019 16.1 Preview 2 and .NET Core 3.0.0-preview4.
https://gist.github.com/MaherJendoubi/d6e15a1da422dc33cb8b4d27916a5fe5
Razor engine cannot parse the lambda expression at line number 51:
receiveClient.RegisterMessageHandler(
async (message, cancellationToken) => await receiveClient.CompleteAsync(message.SystemProperties.LockToken),
messageHandlerOptions);
Still working on fixing this :)