-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove allocations in BaseUriHelper, improve resource resolution performance #10328
base: main
Are you sure you want to change the base?
Conversation
typeof(BaseUriHelper), | ||
new PropertyMetadata((object)null)); | ||
|
||
public static readonly DependencyProperty BaseUriProperty = DependencyProperty.RegisterAttached("BaseUri", typeof(Uri), typeof(BaseUriHelper), new PropertyMetadata(null)); |
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.
Removing the cast to object means that this code will use this constructor.
I'm not sure if it changes the behavior but might as well keep the same behavior and you can juste use a named parameter (Which IMO is also cleaner than just having null):
public static readonly DependencyProperty BaseUriProperty = DependencyProperty.RegisterAttached("BaseUri", typeof(Uri), typeof(BaseUriHelper), new PropertyMetadata(null)); | |
public static readonly DependencyProperty BaseUriProperty = DependencyProperty.RegisterAttached("BaseUri", typeof(Uri), typeof(BaseUriHelper), new PropertyMetadata(defaultValue: null)); |
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.
Also, what's wrong with the original indentation ? Most dependency/attached property registration in this repo use the same indentation style, I don't see why we should change it. Personally I prefer the previous style and other repos like WinForms have a recommended max line length (WinForms uses recommended < 120 and max < 150)
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.
It won't change behaviour but I like the named argument there, let's use that. Thanks.
As for indentation; since the class is 90% changes, it was auto format. Reverted it as the line is indeed too long but I wouldn't go as far as saying "use the same indentation style", I can select a random file e.g. DataGrid
files and I'll see 6 different ways to indent a dependency property. 😀
8c6e0ca
to
dae54ba
Compare
Currently blocked by #9822, hence draft.
Description
Optimizes methods in
BaseUriHelper
, removes most of the allocations directly in this class and opens up more optimization possibilities; directly builds upon #9739 and #9822.IsSameKeyToken
from SecurityHelper in favour ofReflectionUtils.IsSamePublicKeyToken
.BaseUriHelper.GetAssemblyNameAndPart
is now fully allocation free.AssemblyPackageInfo
ref struct
.FontResourceCache
, we can now useAlternateLookup
to benefit from this change as well.BaseUriHelper.BaseUri
was never set outside static constructor, where it was initialized to thes_packAppBaseUri
value,hence I've removed the property altogether, which also led to removal of
BindUriHelper.BaseUri
which was just proxy.CF_Envelope_Activation_Enabled
macro was removed, most of the code is already missing in .NET Core than what was in reference files for .NET 3.5 and it is never compiled on NetFX nor on .NET Core.GetLoadedAssembly
bring a bit of an improvement but there's more benchmarking needed on how to handle this chain most efficiently, so keeping as it is right now.Cherry-picking some cases:
GetAssemblyNameAndPart
AssemblyMatchesKeyString vs ComparePublicKeyTokens
Customer Impact
Improved performance, decrased allocations.
Regression
No.
Testing
Local build, some assert testing; I'll provide tests before this goes out of draft.
Risk
Low to medium, there are quite a few changes but most of them are rather straightforward.
Microsoft Reviewers: Open in CodeFlow