Replies: 1 comment
-
Note that if you have code like this: @code {
private int currentCount = 0;
}
@code {
private void IncrementCount()
{
currentCount++;
}
} Then applying the Extract code block to code behind refactoring ends up with code like the one above. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The documentation says this about partial code-behind classes in Razor components of a Blazor app:
My question is: can I mix these two approaches in the same component? For example, using the Counter example code, is the following supported?
Counter.razor:
Counter.cs:
The confusing thing is that this produces an error in VS (CS0103 The name 'currentCount' does not exist in the current context), but then compiles and works fine. This seems to happen, because at design-time, the Microsoft.CodeAnalysis.Razor.Compiler source generator does not generate any code.
If this is not currently supported, should it be?
Beta Was this translation helpful? Give feedback.
All reactions