-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Use Type.GetProperty/GetField instead of GetMember. #103275
Conversation
rt-sz doesn't report any improvement from this (MichalStrehovsky/rt-sz#30), but also it doesn't test with the TodosApi app so I don't know if it would help there. rt-sz saw a small regression with the PR that added this: MichalStrehovsky/rt-sz#28 but the regression was much smaller than what we saw with todosapi so I don't know :/ |
Ah, rt-sz wouldn't really capture improvements in changes like this. It doesn't pick up the new source generator. So a zero diff result is expected. We don't have a good way to measure impact of this in automation. |
I wouldn't expect it to create a lot of impact size-wise. The main issue I would think is finding a good way to make the |
Is the public surface are immutable (i.e. we cannot unseal |
You mean have the source generator override a virtual method? Would that make it more amenable to trimming? |
We're quite a bit limited that the class Provider
{
private PropertyInfo _pi;
public Provider(PropertyInfo pi) =>_pi = pi;
public ICustomAttributeProvider Get() => _pi;
} then do Or even make a custom |
The lambda is there so that attribute provider resolution can be done lazily. By making it eager we'd end up penalizing startup in all uses of the source generator. |
@MichalStrehovsky I'm thinking we should merge this change regardless, given that it has first-class support from the linker. |
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.
This is an improvement from trimming perspective because we no longer root all members on the type (GetMembers is not intrinsically recognized by trimming and will root all members on the typeof). GetProperty/GetField will only root that single field/property.
/ba-g unrelated infra failure |
620d65b
to
a11bfd8
Compare
Following up from the discussion of dotnet/aspnetcore#56139. This PR replaces
Type.GetMember
forMemberInfo
resolution withType.GetField
/GetProperty
.