Code Quality: Enforced usage of FileExtensionHelpers #18050
Open
Lamparter wants to merge 8 commits intofiles-community:mainfrom
Open
Code Quality: Enforced usage of FileExtensionHelpers #18050Lamparter wants to merge 8 commits intofiles-community:mainfrom
FileExtensionHelpers #18050Lamparter wants to merge 8 commits intofiles-community:mainfrom
Conversation
FileExtensionHelpers across the codebase
FileExtensionHelpers across the codebaseFileExtensionHelpers
Member
|
Please fill out the PR template and the steps taken to test each file format and extension. |
Signed-off-by: Lamparter <71598437+Lamparter@users.noreply.github.com>
yair100
reviewed
Jan 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request unifies file extension checking by consolidating extension helper methods from individual preview view models into a central FileExtensionHelpers class, addressing issue #18049.
Changes:
- Adds new helper methods to
FileExtensionHelpers(IsCodeFile,IsPdfFile,IsHtmlFile,IsMarkdownFile,IsRichTextFile,IsTextFile) and migrates the code file extensions dictionary fromCodePreviewViewModel - Removes duplicate
ContainsExtensionmethods from all preview view models (TextPreviewViewModel, RichTextPreviewViewModel, PDFPreviewViewModel, MarkdownPreviewViewModel, ImagePreviewViewModel, HtmlPreviewViewModel, CodePreviewViewModel) - Updates call sites in
InfoPaneViewModelandAdaptiveLayoutHelpersto use the centralized helpers
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 22 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Files.Shared/Helpers/FileExtensionHelpers.cs | Adds new helper methods and CodeFileExtensions dictionary; updates documentation from "Check" to "Checks" |
| src/Files.Shared/Files.Shared.csproj | Adds ColorCode.Core package reference |
| src/Files.App/ViewModels/UserControls/Previews/TextPreviewViewModel.cs | Removes ContainsExtension method |
| src/Files.App/ViewModels/UserControls/Previews/RichTextPreviewViewModel.cs | Removes ContainsExtension method |
| src/Files.App/ViewModels/UserControls/Previews/PDFPreviewViewModel.cs | Removes ContainsExtension method |
| src/Files.App/ViewModels/UserControls/Previews/MarkdownPreviewViewModel.cs | Removes ContainsExtension method |
| src/Files.App/ViewModels/UserControls/Previews/ImagePreviewViewModel.cs | Removes ContainsExtension method and TODO comment |
| src/Files.App/ViewModels/UserControls/Previews/HtmlPreviewViewModel.cs | Removes ContainsExtension method |
| src/Files.App/ViewModels/UserControls/Previews/CodePreviewViewModel.cs | Removes ContainsExtension method and GetDictionary; uses shared CodeFileExtensions |
| src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs | Updates to use centralized FileExtensionHelpers methods |
| src/Files.App/Helpers/Layout/AdaptiveLayoutHelpers.cs | Updates to use FileExtensionHelpers.IsImageFile |
| Directory.Packages.props | Adds ColorCode.Core version 2.0.15 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
yair100
reviewed
Jan 12, 2026
yair100
reviewed
Jan 12, 2026
yair100
reviewed
Jan 12, 2026
Contributor
Author
|
@yaira2 requesting your review |
Member
|
Please fill out the PR template and the steps taken to test each file format and extension. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolved / Related Issues
FileExtensionHelpersto check file extensions across codebase #18049Steps used to test these changes
FileExtensionHelperisn't working correctlySee the images below where I've demonstrated this
Generic file
Code file
Markdown file (unsure whether this is the expected behaviour for the markdown preview, but this PR wouldn't affect that)
RTF file
Plaintext file