Refactor duplicate HEIF/AVIF extension code into reusable helper
Summary of the Pull Request
Addresses code duplication in PowerRename's HEIF/AVIF extension management by extracting common logic into a reusable StoreExtensionHelper class. Reduces ~60 lines of duplicate code while maintaining identical public API for XAML bindings.
PR Checklist
- [ ] 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
- [ ] JSON for signing for new binaries
- [ ] WXS for installer for new binaries and localization folder
- [ ] YML for CI pipeline for new test projects
- [ ] YML for signed pipeline
- [ ] 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
Changes
-
New
StoreExtensionHelperclass encapsulates:- Package installation status checking with lazy evaluation and caching
- Store launcher command using
AsyncCommandwith properasync Taskpattern -
INotifyPropertyChangedimplementation for UI binding
-
PowerRenameViewModelrefactored to use two helper instances instead of duplicated HEIF/AVIF code:// Constructor initializes helpers HeifExtension = new StoreExtensionHelper( "Microsoft.HEIFImageExtension_8wekyb3d8bbwe", "ms-windows-store://pdp/?ProductId=9PMMSR1CGPWG", "HEIF"); // Convenience properties delegate to helper public bool IsHeifExtensionInstalled => HeifExtension.IsInstalled; public ICommand InstallHeifExtensionCommand => HeifExtension.InstallCommand; -
Removed unused imports:
System.Linq,Windows.Management.Deployment,Windows.System
Benefits
- Future store extensions can reuse
StoreExtensionHelperwithout duplication - Async command handling uses
async Taskinstead ofasync voidpattern - All XAML bindings remain compatible
Validation Steps Performed
Code review and security scan completed with no issues. Build validation deferred to CI due to dependency availability.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
i1qvsblobprodcus353.vsblob.vsassets.io
- Triggering command:
/usr/bin/dotnet dotnet build src/settings-ui/Settings.UI/PowerToys.Settings.csproj --configuration Release(dns block)- Triggering command:
/usr/bin/dotnet dotnet msbuild src/settings-ui/Settings.UI/PowerToys.Settings.csproj /t:Compile /p:Configuration=Release /p:BuildProjectReferences=false /nologo(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
@Copilot solve merge conflict.
@Copilot solve merge conflict.
Merge conflict resolved successfully. Rebased the branch onto the updated base PR #44466 (commit 21900d4).
The conflict occurred because the base PR added async Task refactoring to the duplicate HEIF/AVIF code, while this PR refactored that duplicate code into a StoreExtensionHelper class. The resolution keeps the helper class approach (which already uses async Task) and removes the now-redundant duplicate code from the base PR.
Changes are ready locally but require force-push to update the remote branch due to rebase. The report_progress tool encounters conflicts when attempting to rebase again, preventing automatic push. Manual force-push may be needed to complete the update.
Local commits after resolving conflict:
- 0e731e4: Remove unused System.Threading.Tasks import
- 35d4997: Use AsyncCommand with async Task
- 33a1a39: Refactor duplicate code into StoreExtensionHelper
- 1417dde: Initial plan Base: 21900d4 (updated PR #44466)