-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor ScopeStack
#9158
Refactor ScopeStack
#9158
Conversation
Co-authored-by: Chris Sienkiewicz <chsienki@microsoft.com>
{ | ||
var currentScope = new ScopeEntry("__template", ScopeKind.Template); | ||
_stack.Push(currentScope); | ||
public void OpenTemplateScope(CodeRenderingContext context) => OpenScope(context); | ||
|
||
// Templates always get a lambda scope, because they are defined as a lambda. | ||
OffsetBuilderVarNumber(1); | ||
currentScope.LambdaScope = context.CodeWriter.BuildLambda(BuilderVarName); | ||
private void OpenScope(CodeRenderingContext context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to have both of these methods now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, OpenScope
is private. OpenComponentScope
and OpenTemplateScope
are two public
methods, each does a slightly different thing, the shared code is in the private OpenScope
.
That seems fine to me, or what do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we wouldn't just make OpenScope
internal
, and delete OpenTemplateScope
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One reason could be that OpenTemplateScope
is more descriptive. So there are currently two kinds of scopes - component and template. The methods as defined now perhaps tell that story more clearly than what you suggest.
But I don't know, I'm okay doing what you say if @chsienki agrees
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I originally left it that was as it seemed more descriptive, but I'm fine just having OpenScope
given that the template scope doesn't actually do anything different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@333fred what do you think? Can we leave this as it's more descriptive or you think it's better to have just OpenScope
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel too strongly. I'll approve and you can decide.
Extracting common refactoring needed for
@formname
attribute #9153See #9153 (comment).
CC: @chsienki @333fred