Skip to content

Use FileExtensionHelpers more widely #10831

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

Closed
QuaintMako opened this issue Dec 23, 2022 · 3 comments · Fixed by #10846
Closed

Use FileExtensionHelpers more widely #10831

QuaintMako opened this issue Dec 23, 2022 · 3 comments · Fixed by #10846

Comments

@QuaintMako
Copy link
Contributor

QuaintMako commented Dec 23, 2022

Description

We are often in need of identifying an item's type, whether it be folder, file, images or anything really.

Currently, we have rogue tests to do this work for us repeated separately in the code. For example when it comes to identify shortcuts :

OpenPath(...) in NavigationHelpers:
path.EndsWith(".lnk", StringComparison.Ordinal) || path.EndsWith(".url", StringComparison.Ordinal);

ToStorageItem(...) in StorageHelpers
if (path.EndsWith(".lnk", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".url", StringComparison.OrdinalIgnoreCase))

FileExtensionHelpers.cs defines a bunch of methods that are cattled to such ends. We should enrich it and make its use wider.

Concerned code

All the codebase.

Gains

  • Reduction of duplication.
  • Regrouping of same logic inside a given class

Requirements

  • FileExtensionHelpers.cs used more when identifying item's type.

Comments

No response

@QuaintMako
Copy link
Contributor Author

Such helper actually exists : FileExtensionHelpers.
We need to extend its usage.

@QuaintMako QuaintMako changed the title Introducing an item extension identifier helper Use FileExtensionHelpers more widely Dec 23, 2022
@Josh65-2201 Josh65-2201 moved this to 🆕 New in Files task board Dec 23, 2022
@yaira2
Copy link
Member

yaira2 commented Dec 25, 2022

Pretty sure @gave92 took care of the shortcuts.

@gave92
Copy link
Member

gave92 commented Dec 25, 2022

#10772 took care of ".url" and ".lnk" shortcuts checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants