Skip to content

Conversation

@jiripolasek
Copy link
Collaborator

Summary of the Pull Request

This PR updates how the Settings / General page retrieves version information for unpackaged apps.
It prevents a crash by reading the version from the process executable, with a fallback to displaying a question mark when the version cannot be determined.

PR Checklist

  • Closes: #xxx
  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@jiripolasek jiripolasek self-assigned this Jan 5, 2026
@jiripolasek jiripolasek added the Product-Command Palette Refers to the Command Palette utility label Jan 5, 2026
@zadjii-msft zadjii-msft merged commit db9f8d5 into microsoft:main Jan 8, 2026
11 checks passed
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.97 milestone Jan 12, 2026
@yeelam-gordon yeelam-gordon requested a review from Copilot January 12, 2026 09:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Settings/General page to safely retrieve version information for both packaged and unpackaged apps. It prevents crashes when running as an unpackaged application by adding a fallback mechanism that reads the version from the process executable, with a final fallback to display "?" when the version cannot be determined.

Changes:

  • Added new localized resource string "Settings_GeneralPage_VersionNo" for formatting the version display
  • Refactored ApplicationVersion property to use a try-pattern for both packaged and assembly version retrieval
  • Added TryGetPackagedVersion method to safely handle packaged app scenarios
  • Added TryGetAssemblyVersion method to retrieve version from executable for unpackaged apps

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw Added localization string for version display format
src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/GeneralPage.xaml.cs Implemented robust version retrieval with fallbacks for both packaged and unpackaged scenarios

return false;
}

var info = FileVersionInfo.GetVersionInfo(processPath);
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the executable lacks version information, FileVersionInfo will return zeros for all version parts, resulting in "0.0.0.0" being displayed. Following the pattern used elsewhere in the codebase (e.g., PluginMetadata.cs), consider checking if the version is "0.0.0.0" and returning false in that case, so the fallback "?" is displayed instead of a misleading "Version 0.0.0.0".

Suggested change
var info = FileVersionInfo.GetVersionInfo(processPath);
var info = FileVersionInfo.GetVersionInfo(processPath);
if (info.FileMajorPart == 0 && info.FileMinorPart == 0 && info.FileBuildPart == 0 && info.FilePrivatePart == 0)
{
// Executable lacks version information; signal failure so the caller can use the fallback.
return false;
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants