-
Notifications
You must be signed in to change notification settings - Fork 437
Add source generator for UnbindAllBindables #5764
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
base: master
Are you sure you want to change the base?
Conversation
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.
Code quality inspections need disabling, probably.
{ | ||
public interface ISourceGeneratedUnbindAllBindables | ||
{ | ||
protected internal Type KnownType { get; } |
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 notice that this seems to be the same thing as in #5761 (comment) again. This means that it is possible for a class to receive two KnownType
properties from two disparate sourcegen interfaces with the same value, so I do wonder whether we want to be implementing these case-by-case rather than splitting this one member into a separate interface.
Not sure how much we care about code size but it does look like a potential excess. We may start paying for this in JIT times which we're not going to be able to shave off or hide that easily. On the other side, I also can understand that implementing this to be done as a common thing may not fit in very well into the current syntax target/emitter abstraction.
{ | ||
protected internal Type KnownType { get; } | ||
|
||
void InternalUnbindAllBindables(); |
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.
The Internal
qualifier being a prefix rather than a suffix (as we usually do elsewhere) is slightly annoying me here. How intentional was this?
{ | ||
} | ||
|
||
protected override bool CheckValid(INamedTypeSymbol symbol) => isDrawableSubType(symbol); |
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.
So this means that the generator is going to emit code for every drawable subtype, even if it doesn't introduce any new bindables to unbind? Do we care, and if we do, how much of a pain is it to have it only emit when necessary?
private bool isDrawableType(INamedTypeSymbol type) | ||
=> type.Name == "Drawable" && SyntaxHelpers.GetFullyQualifiedTypeName(type) == "osu.Framework.Graphics.Drawable"; |
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.
Repeat of #5761 (comment). Should probably be moved out to SyntaxHelpers
at this stage.
Prereqs:
Because
UnbindAllBindables()
isvirtual
and has been overridden, I've had to make another methodInternalUnbindAllBindables()
for the SGen.Before:
After:
(note that this doesn't account for reflection memory usage)