-
Notifications
You must be signed in to change notification settings - Fork 2.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
Clean up extension methods #17051
base: v15/dev
Are you sure you want to change the base?
Clean up extension methods #17051
Conversation
/// </summary> | ||
/// <param name="assembly"></param> | ||
/// <returns></returns> | ||
public static FileInfo GetAssemblyFile(this Assembly assembly) |
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 was unused and can otherwise be easily retrieved using assembly.Location
.
/// </summary> | ||
/// <param name="assemblyName"></param> | ||
/// <returns></returns> | ||
public static FileInfo? GetAssemblyFile(this AssemblyName assemblyName) |
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.
Similar to the other overload, this was unused and can otherwise be easily retrieved.
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.
We can now use collection expressions instead.
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 DataTable
was used for the Node
and DynamicPublishedContent
classes, which don't exist anymore.
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.
These extension methods aren't used, but should otherwise use async Task.Delay()
instead of sleeping the thread anyway.
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.
Deconstructing key value pairs is now natively supported.
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.
These extension methods weren't used.
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've only removed the ToDictionary()
extension method, as that can be replaced with RouteValueDictionary
or HtmlHelper.AnonymousObjectToHtmlAttributes()
. I've reformatted the remaining methods and logically ordered them in the file.
/// null) | ||
/// </param> | ||
/// <returns>The children of the content.</returns> | ||
public static DataTable ChildrenAsTable( |
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.
Similar to the DataTableExtensions
, this is legacy code that isn't used anymore.
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 SanitizeThreadCulture()
isn't used and there's no context why this was necessary (although I believe it was used to automatically get the language name in the invariant culture)...
Any reason not just to obsolete them now, at remove for 16 instead? |
Prerequisites
Description
Umbraco has accumulated quite a lot of extension methods over the years, especially on native .NET types. Most of these extension methods have been added without much thought regarding:
Although this PR removes quite a lot of code, there's a lot more that could be removed after some minor refactors. I'll add justifications for each of the removed extension methods, hopefully making reviewing/testing this PR a bit easier (or otherwise at least start the discussion to clean these up).