Compare commits

..

44 Commits

Author SHA1 Message Date
Kai Tao
761dd2f75a refactor common utils projects into project based instead of pure header based 2026-02-03 17:27:00 +08:00
Kai Tao
27ba536872 UT: Add ut to protect common utils codes (#45290)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
As title

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Tests should be picked up and run and pass
2026-02-03 15:12:45 +08:00
moooyo
18efa0559c Introduce new utility PowerDisplay to control your monitor settings (#42642)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
Introduce a new PowerToys' module PowerDisplay to let user can control
their monitor settings without touching monitor's button.

Support feature list:
Common:
1. Profiles support
2. Integration with LightSwitch (auto switch profile when theme change)
3. TrayIcon
4. Save and restore settings when startup
5. Shortcut
6. Rotation
7. GPO support
8. Auto re-discovery monitor when plugging and unplugging monitors.
9. Identify Monitors
10. Quick profile switch

Especially for DDC/CI monitor:
1. Brightness
2. Contrast
3. Volume
4. Color temperature (preset profile)
5. Input source
6. Power State (poweroff)


Design doc:
https://github.com/microsoft/PowerToys/blob/yuleng/display/pr/3/doc/devdocs/modules/powerdisplay/design.md

AOT compatibility:
I designed this module for AOT from the start, so I'm pretty sure at
least 95% of it is AOT compatible. But unfortunately, PowerToys still
have a AOT blocker to block this module publish with AOT.

Currently PowerToys will check the .net file version (file version not
lib version) to avoid crash. So, all modules should reference Common.UI
or add UseWPF to avoid overwrite the .net file with different version
(which may cause crash).

Todo:
- [ ] BugBash
- [ ] Icon
- [ ] IdentifyWindow UI improvement


Demo

Main UI:
<img width="546" height="671" alt="image"
src="https://github.com/user-attachments/assets/b0ad9ac5-8000-4365-a192-ab8c2d66d4f1"
/>

Input Source:
<img width="536" height="674" alt="image"
src="https://github.com/user-attachments/assets/80f9ccd7-4f8c-4201-b177-cc86c5bcc9e3"
/>


Settings UI:
<img width="1581" height="1191" alt="image"
src="https://github.com/user-attachments/assets/6a82e4bb-8f96-4f28-abf9-d7c45e1c8ef7"
/>

<img width="1525" height="1146" alt="image"
src="https://github.com/user-attachments/assets/aae81e65-08fd-453a-bf52-02a74f2fdea0"
/>



Closes: 
#42942
#42678
#41117
#38109
#35564
#34932
#28500
#1052
#18149

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #1052
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized
- [x] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

---------

Co-authored-by: Yu Leng <yuleng@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: moooyo <lengyuchn@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 13:53:25 +08:00
Jaylyn Barbee
b3e7c9d227 [Light Switch] Fix Light Switch start up logic (#45304)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
Title

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: https://github.com/microsoft/PowerToys/issues/45291
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
Before, there was a function that initialized some variables about the
current system state that were later used to check against if that state
needed to change in a different function. That caused from some issues
because I was reusing the function for a double purpose. Now the
`SyncInitialThemeState()` function in the State Manager will sync those
initial variables and apply the correct theme if needed.

I also removed an unnecessary parameter from `onTick`

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Manual testing
2026-02-03 09:23:54 +08:00
Jiří Polášek
49cc504d94 CmdPal: Improve fuzzy matcher Unicode and emoji robustness (#45275)
## Summary of the Pull Request

Add comprehensive unit tests for emoji, ZWJ sequences, skin tone
modifiers, and UTF-16 edge cases (unpaired surrogates, combining marks,
random garbage). Update matcher logic to skip normalization of lone
surrogates, preventing errors with malformed Unicode. Expand comparison
test data to cover emoji scenarios. Adds regression guards for diacritic
handling and surrogate processing.

Fixes #45246 introduced in #44809.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #45246
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-02-02 12:30:00 -06:00
Jiří Polášek
18c6d6b0f3 CmdPal: Improve loading of application icons (uwp and jumbo icons) - part 2 (#44973)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

This PR improves icons for app items:
- Refactors icon detection and selection from the AppX manifest out of
`UWPApplication`
- Prefer *unplated* UWP app logos so icons no longer appear smaller than
expected
- Adds an icon loader based on `IShellItemImageFactory` to correctly
load large icons
- Jumbo icons loaded from shortcuts are now crisp
- Jumbo icons loaded from shortcuts are no longer scaled down
- Refactors detail loading in `AppListItem` to prevent potential
deadlocks
- Makes PWA icons more crisp
- Fixes fallback item (now it gets used not only when the icon is null,
but also when it's empty).

<table>

<thead>
<tr>
<th></th>
<th>Old</th>
<th>New</th>
</tr>
</thead>

<tr>
<td>1</td>
<td>
<img width="830" height="495" alt="image"
src="https://github.com/user-attachments/assets/bc9875bd-6a8b-4a3d-88e1-07a655a5a5cd"
/>
</td>
<td>
<img width="750" height="533" alt="image"
src="https://github.com/user-attachments/assets/a82ed464-b925-4d0c-95c4-6c04859e886e"
/>
</td>
</tr>

<tr>
<td>2</td>
<td>
<img width="814" height="233" alt="image"
src="https://github.com/user-attachments/assets/d560d3c0-ffc5-4178-a610-4e3b3c7107c8"
/>
</td>
<td>
<img width="760" height="299" alt="image"
src="https://github.com/user-attachments/assets/f29c825e-324f-46f1-b6bb-6edcf286fc9a"
/>

</td>
</tr>


<tr>
<td>3</td>
<td>
<img width="813" height="262" alt="image"
src="https://github.com/user-attachments/assets/d94f724d-ec26-48c8-bb8a-1b10f6a0f7eb"
/>
</td>
<td>
<img width="762" height="260" alt="image"
src="https://github.com/user-attachments/assets/76c5debb-baac-417e-8aba-9cec198e742c"
/>
</td>
</tr>

<tr>
<td>4</td>
<td>
<img width="819" height="250" alt="image"
src="https://github.com/user-attachments/assets/5f16d714-56d8-42f2-ad8b-1c2be6570e5c"
/>
</td>
<td>
<img width="747" height="244" alt="image"
src="https://github.com/user-attachments/assets/485c72cf-ef39-4c05-afdd-877f0a47f51a"
/>
</td>
</tr>


<tr>
<td>5</td>
<td>
<img width="815" height="327" alt="image"
src="https://github.com/user-attachments/assets/4108e36a-5950-43c9-bdff-6a9f58dadcf6"
/>
</td>
<td>
<img width="762" height="272" alt="image"
src="https://github.com/user-attachments/assets/804a3159-a165-4a48-87f6-15849f5f4516"
/>
</td>
</tr>

<tr>
<td>6</td>
<td>
<img width="809" height="257" alt="image"
src="https://github.com/user-attachments/assets/93ad8241-1d75-415f-b08c-4161c0905e41"
/>
</td>
<td>
<img width="756" height="231" alt="image"
src="https://github.com/user-attachments/assets/a0c9bb44-7151-438d-a811-82d5e2080f44"
/>
</td>
</tr>

<tr>
<td></td>
<td>
</td>
<td>
</td>
</tr>

</table>

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44970
- [x] Closes: #43320
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-02-02 11:53:40 -06:00
Jiří Polášek
4d1f92199c CmdPal: Make Indexer great again - part 1 - hotfix (#44729)
## Summary of the Pull Request

This PR introduces a rough hotfix for several indexer-related issues.

- Premise: patch what we can in-place and fix the core later (reworking
`SeachEngine` and `SearchQuery` is slightly trickier). This patch also
removes some dead code for future refactor.
- Adds search cancellation to the File Search page and the indexer
fallback.
- Prevents older searches from overwriting newer model state and reduces
wasted work.
- Stops reusing the search engine; creates a new instance per search to
avoid synchronization issues.
- That `SeachEngine` and `SearchQuery` are not multi-threading friendly.
- Removes search priming to simplify the code and improve performance.
- Since `SearchQuery` cancels and re-primes on every search, priming
provides little benefit and can hide extra work (for example,
cancellation triggering re-priming).
- Fixes the indexer fallback subject line not updating when there is
more than one match.
  - It previously kept the old value, which was confusing.
- ~Shows the number of matched files in the fallback result.~
- Fetching total number of rows was reverted, performance was not stable
:(
- Optimizes the indexer fallback by reducing the number of items
processed but not used.
- Only fetches the item(s) needed for the fallback itself—no extra work
on the hot path.
- Stops reusing the fallback result when navigating to the File Search
page to show more results. This requires querying again, but it
simplifies the flow and keeps components isolated.
- Fixes the English mnemonic keyword `kind` being hardcoded in the
search page filter. Windows Search uses localized mnemonic keyword
names, so this PR replaces it with canonical keyword `System.Kind` that
is universaly recognized.
- Adds extra diagnostics to `SearchQuery` and makes logging more
precise.
- DataPackage for the IndexerListItem now defers including of storage
items - boost performance and we avoid touching the item until its
needed.
- IndexerPage with a prepopulated query will delay loading until the
items are actually enumerated (to avoid populating from fallback hot
path) and it no longer takes external SearchEngine. It just recreates
everything.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Related to: #44728
- [x] Closes: #44731
- [x] Closes: #44732
- [x] Closes: #44743
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-02-02 11:23:34 -06:00
Jiří Polášek
dca532cf4b CmdPal: Icon cache (#44538)
## Summary of the Pull Request

This PR implements actual cache in IconCacheService and adds some fixes
on top for free.

The good
- `IconCacheService` now caches decoded icons
- Ensures that UI thread is not starved by loading icons by limiting
number of threads that can load icons at any given time
- `IconCacheService` decodes bitmaps directly to the required size to
reduce memory usage
- `IconBox` now reacts to theme, DPI scale, and size changes immediately
- Introduced `AdaptiveCache` with time-based decay to improve icon reuse
- Updated `IconCacheProvider` and `IconCacheService` to handle multiple
icon sizes and scale-aware caching
- Added priority-based decoding in `IconCacheService` for more
responsive loading
- Extended `IconPathConverter` to support target icon sizes
- Switched hero images in `ShellPage` to use the jumbo icon cache
- Made `MainWindow` title bar logic resilient to a null `XamlRoot`
- Fixed Tag icon positioning
- Removes custom `TypedEventHandlerExtensions` in favor of
`CommunityToolkit.WinUI.Deferred`.

The bad
- Since IconData lacks a unique identity, when it includes a stream, it
relies on simple reference equality, acknowledging that it might not be
stable. We might cache some obsolete garbage because of this, but it is
fast and better than nothing at all. Yet another task for the future me.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: 
- [ ] Closes: #38284
- [ ] Related to: #44407
- [ ] Related to: https://github.com/zadjii-msft/PowerToys/issues/333
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-02-02 11:16:43 -06:00
Jiří Polášek
b5991642f8 CmdPal: Add trailing backslash to OutDir in Microsoft.Terminal.UI project file (#45250)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

Ensures the OutDir path in Microsoft.Terminal.UI.vcxproj ends with a
backslash, making it explicit as a directory, and fixes warning MSB8004.


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-02-02 11:10:36 -06:00
Jaylyn Barbee
84b39a9edc [Light Switch] Changed the rules surrounding the max/min value of the Offset field (#45125)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This PR introduces new logic that dictates the max and min value for the
`Offset` field that the user can change when using Sunrise to Sunset
mode.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44959
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
The new logic is as follows:
- The sunrise offset cannot go into the previous day and cannot overlap
the current sunset transition time
- The sunset offset cannot overlap the last sunrise time and cannot
overlap into the next day.

These values are dynamic and update when the VM updates with new times.
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
- Manual testing
2026-02-02 09:33:25 -05:00
Kai Tao
67d96b0a13 PowerToys extension: Bundle localization files into installer (#45194)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #45171
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
<img width="925" height="612" alt="image"
src="https://github.com/user-attachments/assets/214ead95-504a-4e48-bc25-138323d973f9"
/>
2026-02-02 11:31:21 +08:00
Kai Tao
c5d4f992c1 Workspace: Fix an overlay issue for workspace snapshot draw (#45183)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
Root cause: Workspaces uses DPI-unaware coordinates (via
GetDpiUnawareScreens()
which runs in a temporary DPI-unaware thread) to store/match window
positions
across different DPI settings. However, WorkspacesEditor itself uses
PerMonitorV2
DPI awareness for UI clarity. When assigning these DPI-unaware
coordinates directly
to WPF window properties, WPF automatically scaled them again based on
current DPI,
causing incorrect overlay positioning.

Fix: Use SetWindowPositionDpiUnaware() to bypass WPF's automatic DPI
scaling
by temporarily switching to DPI-unaware context when calling Win32
SetWindowPos.

Fix #45174

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #45174
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Verified in local build vs production build, and the problem fixed in
local build.
2026-02-02 09:34:50 +08:00
Kai Tao
11b406feee Build: Fix release pipeline and local build failure (#45211)
## Summary of the Pull Request
Release pipeline is keeping failed, and local build failed at ut.

This pull request introduces changes to improve how test projects are
handled during release builds, ensuring that test code is not compiled
or analyzed when not needed - in doing release build, to - succeed the
execution and reduce built time.

And, to upgrade from VS17 to VS18 in cmdpal sdk build, this is to keep
consistency with all other build step


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Local build & release pipeline build should all pass:

Local build:
<img width="1815" height="281" alt="image"
src="https://github.com/user-attachments/assets/f350cf3f-b856-432d-97f3-e392d38ef7fa"
/>

Release pipeline is working too:
<img width="1195" height="163" alt="image"
src="https://github.com/user-attachments/assets/ce58de38-f0fb-45ad-9d70-2b8eb1c4db60"
/>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-02 09:15:53 +08:00
Jiří Polášek
256af8f6e0 Spellcheck: Add missing words and sort expect.txt (#45251)
## PR Checklist

This PR adds missing words to the spell checker dictionary.

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-02-01 20:14:37 +08:00
Gordon Lam
87c65f9eec docs(paste): add AI preview credit documentation (#45236)
docs(paste): add AI preview credit documentation

```markdown
## Summary of the Pull Request

Adds documentation clarifying that the "Show preview" setting for Paste with AI does not consume additional AI credits. The preview displays the same AI response that was already generated from a single API call, cached locally.

## PR Checklist

- [x] Closes: #32950
- [x] **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 - N/A (documentation only)
- [ ] **Localization:** All end-user-facing strings can be localized - N/A (dev docs only)
- [x] **Dev docs:** Added/updated
- [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx

## Detailed Description of the Pull Request / Additional comments

This PR addresses the question raised in issue #32950 about whether enabling preview for Paste with AI costs extra AI quota.

Changes to `doc/devdocs/modules/advancedpaste.md`:
- Added new "Paste with AI Preview" section explaining:
  - The `ShowCustomPreview` setting behavior
  - Confirmation that preview does **not** consume additional AI credits
  - The implementation flow showing a single API call with local caching
  - Reference to `OptionsViewModel.cs` lines 702-717
- Added settings documentation table for `ShowCustomPreview`

Fixes #32950

## Validation Steps Performed

- Verified documentation renders correctly in Markdown preview
- Confirmed technical accuracy by referencing `OptionsViewModel.cs` implementation
```

---------

Co-authored-by: yeelam-gordon <yeelam-gordon@users.noreply.github.com>
2026-01-31 09:03:24 -08:00
Gordon Lam
971c7e9fba docs(settings-ui): update Advanced Paste OOBE description for AI features (#45233)
## Summary of the Pull Request

Updates the Advanced Paste OOBE (Out-of-Box Experience) description to
accurately reflect that AI features no longer require specifically an
OpenAI API key. The new text clarifies:
- Changed "markdown" to "Markdown" and "json" to "JSON" for proper
casing
- Replaced "100% opt-in and requires an Open AI key" with "opt-in AI
feature that can use an online or local language model endpoint"

This fixes the outdated description that still referenced OpenAI as the
only option.

## PR Checklist

- [x] Closes: #44044
- [x] **Communication:** Documentation/string fix, no core contributor
discussion needed
- [ ] **Tests:** N/A - string-only change
- [x] **Localization:** The updated string is in the localizable
Resources.resw file
- [ ] **Dev docs:** N/A
- [ ] **New binaries:** N/A
- [ ] **Documentation updated:** N/A

## Detailed Description of the Pull Request / Additional comments

The change updates
\src/settings-ui/Settings.UI/Strings/en-us/Resources.resw\ to fix the
\Oobe_AdvancedPaste.Description\ string that incorrectly stated AI
features require an OpenAI key.

## Validation Steps Performed

- Verified the string change is valid XML
- Confirmed the updated description accurately reflects current Advanced
Paste AI capabilities
2026-01-31 08:46:31 -08:00
Jaylyn Barbee
055c3011cc Documentation walking through important steps for writing a New PowerToy (#44242)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This new document serves as a handy guide, packed with key details and
helpful tips to keep in mind when creating a new PowerToy.
2026-01-30 14:45:35 +01:00
leileizhang
2f7fc91956 Fix OOBE pages Launch buttons remain clickable when modules are disabled (#44736)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
Fixes the issue where Launch/Open buttons on OOBE (Welcome to PowerToys)
pages remain clickable even when the corresponding module is disabled.

Added enabled state checks to the following OOBE pages:
- **OobeColorPicker** - checks `ModuleType.ColorPicker`
- **OobeEnvironmentVariables** - checks
`ModuleType.EnvironmentVariables`
- **OobeHosts** - checks `ModuleType.Hosts`
- **OobeRun** - checks `ModuleType.PowerLauncher`
- **OobeRegistryPreview** - checks `ModuleType.RegistryPreview`
- **OobeShortcutGuide** - checks `ModuleType.ShortcutGuide`

<img width="1538" height="239" alt="image"
src="https://github.com/user-attachments/assets/da20628e-9c82-4619-8a5c-4b75a22b6901"
/>

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44737
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-30 14:48:09 +08:00
Kai Tao
6d4f56cd83 Always on top: Add transparent support for on topped window (#44815)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
Transparency support (best-effort)
> Not every window can be made transparent. Transparency is applied on a
best-effort basis and depends on how the target app/window is built and
rendered.

## When it may not work
* Windows with special rendering pipelines (e.g., certain
hardware-accelerated / compositor-managed surfaces).
* Some tool/popup/owned windows where the foreground window isn’t the
actual surface being drawn.

## How it works (high-level)
* Resolve the best target window (preferring the top-level/root window
over transient children).
* Apply Windows’ standard layered-window alpha mechanism (per-window
opacity) to adjust transparency.
* When unpinned, Restore the original opacity/state when possible.

If transparency doesn’t change, it means the window doesn’t support this
mechanism in its current configuration.
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [X] Closes: 
#43278 
#42929
#28773

<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed


https://github.com/user-attachments/assets/c97a87f2-3126-4e19-990f-8c684dbeb631

<img width="1119" height="426" alt="image"
src="https://github.com/user-attachments/assets/547671ee-81d3-4c94-8199-bf0c4b1b7760"
/>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-29 13:48:27 +08:00
Jiří Polášek
4986915dae CmdPal: Batch ViewModel property change notifications (#44545)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

This PR introduces batching for property change notifications emitted by
Command Palette view models. It also adds a secondary notification path
that is guaranteed to execute on a background thread.

- Introduces **`BatchUpdateManager`**, which batches
`INotifyPropertyChanged` events from view models and replays them in a
coordinated way.
- Slightly reduces UI thread contention and allows related UI updates to
be applied together, reducing visual "tearing" in list items (when
title, subtitle and icon are updated separately with slight delay).
Batching won't mitigate all occurences, but its good enough and works
auto-magically.
- Adds a complementary background notification event that:
  - Is guaranteed to run on a background thread.
  - Fires before UI-thread notifications.
- Allows consumers to attach handlers without blocking COM out-of-proc
objects.

- Updates `TopLevelViewModel` to subscribe to the background property
change event instead of the UI-thread one.
- This avoids unintentionally shifting work onto the UI thread and
re-triggering expensive operations there.
- Previously, because `TopLevelViewModel` wraps another view model and
our view models raise `INPC` on the UI thread by default, its handler
was executing on the UI thread and re-raising the event as
`IListItem.PropertyChanged`, causing `FetchProperty` methods to run on
the UI thread again.
- Ideally, `TopLevelViewModel` should be reworked to address this more
cleanly, but that turned out to be a non-trivial change. This PR applies
a targeted mitigation in the meantime.








<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:56:11 -06:00
Jiří Polášek
cc2dce8816 CmdPal: replace custom fuzzy matching in Window Walker (#44807)
## Summary of the Pull Request

This PR replaces the custom search controller and fuzzy matching with
standard classes from the Extension SDK Toolkit.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:23:50 -06:00
Jiří Polášek
0de2af77ac CmdPal: Make Calculator Great Again (#44594)
## Summary of the Pull Request

This PR continues the tradition of alphabetical progress. After
[MBGA](#41961), we move on to **MCBA — Make Calculator Better Again!**

- Introduces limited automatic correction and completion of expressions.
- The goal is to allow uninterrupted typing and avoid disruptions when a
partially entered expression is temporarily invalid (which previously
caused the result to be replaced by an error message or hidden by the
fallback).
  - The implementation intentionally aims for a sweet spot:
    - Ignores trailing binary operators.
    - Automatically closes all opened parentheses.
- It is not exhaustive; for example, incomplete constants or functions
may still result in an invalid query.
- Copy current result to the search bar.
- Adds an option to copy the current result to the search bar when the
user types `=` at the end of the expression.
  - Adds a new menu item for the same action.
  - Fixes the **Save** command to also copy the result to the query.
- Adds support for the `factorial(x)` function and the `x!` expression.
- Factorial calculations are supported up to `170!` (limited by
`double`), but display is constrained by decimal conversion and allows
direct display of results up to `20!`.
- Adds support for the `sign(x)` function.
- Adds support for the `π` symbol as an alternative to the `pi`
constant.
- Adds a context menu item to the result list item and fallback that
displays the octal representation of the result.
- Implements beautification of the query:
- Converts technical symbols such as `*` or `/` to `×` or `÷`,
respectively.
- Not enabled for fallbacks for now, since the item text should match
the query to keep the score intact.
- Implements additional normalization of symbols in the query:
  - Percent: `%`, `%`, `﹪`
  - Minus: `−`, `-`, `–`, `—`
  - Factorial: `!`, `!`
- Multiplication: `*`, `×`, `∗`, `·`, `⋅`, `✕`, `✖`, `\u2062` (invisible
times)
  - Division: `/`, `÷`, ``, `:`
- Allows use of `²` and `³` as alternatives to `^2` and `^3`.
- Updates the unit test that was culture sensitive to force en-US output
(not an actual fix, but at least it clears false positive for now)
- Fixes pre-parsing of scientific notation to prevent capturing minus
sign as part of it.
- Fixes normalization/rounding of the result, so it can display small
values (the current solution turned it into a string with scientific
notation and couldn't parse it back).
- Updates test with new cases

## Pictures? Moving!

Previous behavior:


https://github.com/user-attachments/assets/ebcdcd85-797a-44f9-a8b1-a0f2f33c6b42

New behavior:


https://github.com/user-attachments/assets/5bd94663-a0d0-4d7d-8032-1030e79926c3





<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #43481
- [x] Closes: #43460
- [x] Closes: #42078
- [x] Closes: #41839
- [x] Closes: #39659
- [x] Closes: #40502
- [x] Related to: #41715
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:23:39 -06:00
Jiří Polášek
4694e99477 CmdPal: Upgrade FuzzyStringMatcher in the Command Palette Extensions SDK (#44809)
## Summary of the Pull Request

This PR upgrades the `FuzzyStringMatcher` used in the Command Palette
Extensions SDK with a focus on performance, memory efficiency, and
improved matching behavior, while preserving compatibility with the
existing API. This PR is a backwards compatible alternative to
precomputed fuzzy matcher introduces in another PR.

The new implementation is designed as a drop-in replacement. Any
behavioral differences are intentional and primarily related to improved
diacritic handling, scoring consistency, and correctness of highlight
positions.

Changes:
- Keeps the existing public API intact and preserves behavior in nearly
all cases.
- Enables diacritics-insensitive matching by default, improving results
across accented and non-English languages.
- Significantly improves performance, with measured speedups in the
range of ~5–20 times, depending on scenario and input size.
- Reduces heap allocations to near zero by using stack allocation and
pooled buffers instead of large per-match DP arrays.
- Simplifies and optimizes matching logic:
  - Folds the haystack only once per match.
  - Uses rolling DP buffers instead of `O(query × target)` tables.
- Replaces large match tables with a compact bitset when tracking
highlight positions.
- Improves consistency and correctness:
  - Normalizes path separators (`\` → `/`) during folding.
- Avoids returning highlight positions for PinYin-only matches where no
1:1 mapping exists.
- Introduces unit tests, including comparison tests against the legacy
implementation to validate compatibility.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44066
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:23:12 -06:00
Jiří Polášek
64cabc8789 CmdPal: Fix window centering when moving to a display with different DPI (#45057)
## Summary of the Pull Request

This PR fixes centering of main window, when the window also moves
between move display with a different DPI.

- The centered position was calculated using the current window width
and height, but those values change after the window is moved to
accommodate the new display’s DPI.
- Calculations have been refactored out of main window to a helper
class.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44932
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:21:11 -06:00
Jiří Polášek
989e005500 CmdPal: Run shutdown and restart commands in a hidden window (#45062)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #40621 
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:20:52 -06:00
Jiří Polášek
5f124cec55 CmdPal: Cache and show information for disabled command providers (#44278)
## Summary of the Pull Request

This PR adds a cache of command provider information so we can show
providers even when the command provider isn’t loaded.

It also updates the description for disabled extensions on the
Extensions page to always include the extension name.

Finally, it adds a placeholder icon for cases where an extension icon
isn’t loaded. Note that this doesn’t address fully transparent icons
that some extensions may inherit from the default template.

Before:

<img width="1883" height="167" alt="image"
src="https://github.com/user-attachments/assets/7ccaa669-9516-4b57-9646-4e755d29d75c"
/>


After:

<img width="1873" height="190" alt="image"
src="https://github.com/user-attachments/assets/f29549c2-ddd5-4688-ba9c-d1abd4b523a0"
/>


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:19:25 -06:00
Jiří Polášek
8ec530c65e CmdPal: GEH per partes; part 1: error report builder, sanitizer and internals tools setting page (#44140)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

This PR adds three parts of the original big bad global error handler
(error report builder, sanitization and internal tools UI).

### Error Report Generation

- `ErrorReportBuilder`: Produces a detailed, technical report with
system context.
- Comprehensive data: OS version, architecture, culture, app version,
elevation status, etc.
- Exception analysis: Coalesces nested exception messages and HRESULT
details for clearer diagnostics.

<details><summary>Example</summary>
<pre>

This is an error report generated by Windows Command Palette.
If you are seeing this, it means something went a little sideways in the
app.
You can help us fix it by filing a report at
https://aka.ms/powerToysReportBug.

(While you’re at it, give the details below a quick skim — just to make
sure there’s nothing personal you’d prefer not to share. It’s rare, but
sometimes little surprises sneak in.)
============================================================
Summary:
  Message:               Test exception; thrown from the UI thread
  Type:                  System.NotImplementedException
  Source:                Microsoft.CmdPal.UI
  Time:                  2025-08-25 18:54:44.3854569
  HRESULT:               0x80004001 (-2147467263)
  Context:               MainThreadException

Application:
  App version:           0.0.1.0
  Is elevated:           no

Environment:
  OS version:            Microsoft Windows 10.0.26120
  OS architecture:       X64
  Runtime identifier:    win-x64
  Framework:             .NET 9.0.8
  Process architecture:  X64
  Culture:               cs-CZ
  UI culture:            en-US

Stack Trace:
at
Microsoft.CmdPal.UI.Settings.InternalPage.ThrowPlainMainThreadException_Click(Object
sender, RoutedEventArgs e)
at
WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.<GetEventInvoke>b__1_0(Object
sender, RoutedEventArgs e)
at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr
thisPtr, IntPtr sender, IntPtr e)

------------------ Full Exception Details ------------------
System.NotImplementedException: Test exception; thrown from the UI
thread
at
Microsoft.CmdPal.UI.Settings.InternalPage.ThrowPlainMainThreadException_Click(Object
sender, RoutedEventArgs e)
at
WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.<GetEventInvoke>b__1_0(Object
sender, RoutedEventArgs e)
at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr
thisPtr, IntPtr sender, IntPtr e)

============================================================

</pre>
</details> 

Real-world example: #41362

### PII Sanitization Framework

- `ErrorReportSanitizer`: Multi-layer sanitization pipeline for
sensitive data.
- Nine specialized rule providers:
- `PiiRuleProvider`: Personally identifiable information (emails, phone
numbers, SSNs).
- `ProfilePathAndUsernameRuleProvider`: Windows user profiles and
usernames.
- `NetworkRuleProvider`: IP addresses, MAC addresses, network
identifiers.
- `SecretKeyValueRulesProvider`: API keys, tokens, passwords in
key/value formats.
  - `FilenameMaskRuleProvider`: Sensitive file paths and extensions.
  - `UrlRuleProvider`: URLs and web addresses.
  - `TokenRuleProvider`: JWT and other auth tokens.
  - `ConnectionStringRuleProvider`: Database connection strings.
- `EnvironmentPropertiesRuleProvider`: Environment variables and system
properties.

### Internals Tools Page

A page in settings available in non-CI-builds:

<img width="1305" height="745" alt="image"
src="https://github.com/user-attachments/assets/3145ecfd-997f-491d-8c8a-6096634b6045"
/>


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 21:09:37 -06:00
Jeremy Sinclair
f82afdf384 [Dev][Build] VS 2026 Support (#44304)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This PR updates the PowerToys solution to support **Visual Studio 2026
(PlatformToolset v145)**. It centralizes the build configuration,
updates the C++ language standards, and fixes an issue with a MouseJump
unit test that appears while using the VS 2026 supported build agent.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [x] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

**Build System & Configuration:**
- Updated `Cpp.Build.props` to use `v145` (VS 2026) as the default
`PlatformToolset`, with fall back to `v143` for VS 2022.
- Configured C++ Language Standard:
  - `stdcpplatest` for production projects.
- Removed explicit `<PlatformToolset>` definitions from individual
project files (approx. 37 modules) to inherit correctly from the central
`Cpp.Build.props`.

**Code Refactoring & Fixes:**
- Updated `DrawingHelperTests.cs` in MouseJump Unit Test to ease the
pixel difference tolerance. This became an issue after switching to the
new VS2026 build agent.
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

- Validated successful compilation of the entire solution. Similar
updates have been made to the .NET 10 branch, but these are much cleaner
and will be merged into that branch once fully confirmed working.

---------

Co-authored-by: Kai Tao (from Dev Box) <kaitao@microsoft.com>
Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
2026-01-28 15:46:34 -08:00
Kai Tao
aa2ba0c325 0.97.1 change log (#45112)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

97.1 change log

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-28 15:04:00 +08:00
Kai Tao
f534e5b8e5 [ZoomIt] Show users full hotkey list in settings (#43073)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

This PR enhances the ZoomIt settings UI by refactoring some of the XAML
code and putting instructions as part of the settingsexpanders.
Additionally, the alternate hotkey combinations are now shown too and
will be updated based on the configured hotkey.
so that **Users will now be able to see all the hotkeys**.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #42236
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

### ZoomIt Extended (Derived) Hotkeys

Feature | Base Key Property | Default Base Key | Derived Key Property |
XOR Logic | Default Derived Key | Description
-- | -- | -- | -- | -- | -- | --
LiveZoom | LiveZoomToggleKey | Ctrl+4 | LiveZoomToggleKeyDraw | XOR
Shift | Ctrl+Shift+4 | Enter drawing mode in LiveZoom
Record | RecordToggleKey | Ctrl+5 | RecordToggleKeyCrop | XOR Shift |
Ctrl+Shift+5 | Record selected region (crop)
Record | RecordToggleKey | Ctrl+5 | RecordToggleKeyWindow | XOR Alt |
Ctrl+Alt+5 | Record specific window
Snip | SnipToggleKey | Ctrl+6 | SnipToggleKeySave | XOR Shift |
Ctrl+Shift+6 | Snip and save to file
DemoType | DemoTypeToggleKey | Ctrl+7 | DemoTypeToggleKeyReset | XOR
Shift | Ctrl+Shift+7 | Rewind to previous segment


<img width="832" height="3679" alt="Frame 2018778631"
src="https://github.com/user-attachments/assets/bebddcd8-d705-4582-ae8a-c847cb1c3e88"
/>

---------

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Kai Tao <vanzue@users.noreply.github.com>
2026-01-28 10:37:22 +08:00
Jiří Polášek
08715a6e46 CmdPal: Allow list item context menu (#45086)
## Summary of the Pull Request

This PR enables pointer-invoked context menus for list items when the
list contains at least one item, including the primary item.

The command bar "More" button or Ctrl+K hotkey remain unaffected - the
menu is not accessible through those.

<img width="453" height="210" alt="image"
src="https://github.com/user-attachments/assets/af0f38e3-e1e7-4968-9e2d-6d9293785ab1"
/>


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #45083
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-27 13:52:12 -06:00
Mike Hall
d26d9f745a CursorWrap improvements (#44936)
## Summary of the Pull Request
- Updated engine for better multi-monitor support.
- Closing the laptop lid will now update the monitor topology
- New settings/dropdown to support wrapping on horizontal, vertical, or
both

<img width="1103" height="643" alt="image"
src="https://github.com/user-attachments/assets/ff4f0835-a8ca-4603-9441-123b71747d5c"
/>

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44820
- [x] Closes: #44864
- [x] Closes: #44952

- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

## Detailed Description of the Pull Request / Additional comments
Feedback for CursorWrap shows that users want the ability to constrain
wrapping for horizontal only, vertical only, or both (default behavior).
This PR adds a new dropdown to CursorWrap settings to enable a user to
select the appropriate wrapping model.

## Validation Steps Performed
Local build and running on Surface Laptop 7 Pro - will also validate on
a multi-monitor setup.

---------

Co-authored-by: vanzue <vanzue@outlook.com>
2026-01-27 13:27:11 +08:00
Gordon Lam
6661adbd5c chore(prompts): add fix active PR comments prompt with scoped changes (#44996)
## Summary of the Pull Request
Enhance the active PR comments prompt to allow for scoped changes while
removing outdated model references from various prompt files.

## 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
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

## Detailed Description of the Pull Request / Additional comments
The changes include the addition of a new prompt for fixing active PR
comments with scoped changes, ensuring that only simple fixes are
applied. Additionally, references to the model 'GPT-5.1-Codex-Max' have
been removed from several prompt files to streamline the prompts.

## Validation Steps Performed
Manual validation of the new prompt functionality was conducted to
ensure it correctly identifies and resolves active PR comments.
```
2026-01-26 20:34:11 -08:00
Heiko
5ecb97b4e0 [Enterprise; Policy] Add policy for CursorWrap to ADMX (#45028)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

Added missing policy definition.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44897
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **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
- [x] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** See PR for issue #44484 

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-27 11:24:02 +08:00
Jiří Polášek
13ce5db6b1 CmdPal: Add solution filter for Microsoft.CmdPal.Ext.PowerToys (#45096)
## Summary of the Pull Request

This PR adds a new solution filter (.slnf) for the
Microsoft.CmdPal.Ext.PowerToys extension project and its dependencies.

This is added as a separate solution filter alongside
CommandPalette.slnf, since the extension is not directly dependent on
Command Palette. Instead, it relies on the public SDK distributed via
NuGet. It also depends on other PowerToys projects, which would
unnecessarily clutter CommandPalette.slnf.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-26 21:14:05 -06:00
Jiří Polášek
f0831742d6 CmdPal: Remove deadlock bait from AppListItem (#45076)
## Summary of the Pull Request

This PR removes a Task.Wait() call from lazy-loading AppListItem details
that could be invoked on the UI thread and lead to a deadlock.

It now follows the same pattern previously used for loading icons in the
same class, which has proven to work well.

Prevents #44938 from stepping on this landmine.

Cherry-picked from #44973.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #45074 
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-27 09:51:16 +08:00
Shawn Yuan
ea43974287 [Settings] [Advanced Paste] Upgrade advanced paste settings safely to fix settings ui crash (#44862)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This pull request makes a minor fix in the `AdvancedPasteViewModel`
constructor to ensure the correct settings repository is used for null
checking. The change improves code correctness by verifying
`advancedPasteSettingsRepository` instead of the generic
`settingsRepository`.

- Fixed null check to use `advancedPasteSettingsRepository` instead of
`settingsRepository` in the `AdvancedPasteViewModel` constructor for
more accurate validation.
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44835
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-26 15:28:59 +08:00
Gordon Lam
0b3dc089ac [Peek] Fix Space key triggering during file rename (#44845) (#44995)
Don't show error window when CurrentItem is null - just return silently.
This restores the original behavior where CaretVisible() detection in
GetSelectedItems() would suppress Peek by returning null, and no window
would be shown.

PR #44703 added an error window for virtual folders (Home/Recent), but
this also triggered when user was typing (rename, search, address bar),
stealing focus and cancelling the operation.

Fixes #44845

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
2026-01-26 15:20:07 +08:00
Shawn Yuan
4ba6fd2723 Add telemetry for tray icon (#44985)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This pull request adds telemetry tracking for user interactions with the
application's tray icon. Specifically, it introduces new methods for
logging `left-click`, `right-click`, and `double-click` events, and
integrates these telemetry calls into the tray icon event handling
logic.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-26 09:44:10 +08:00
Shawn Yuan
086c63b6af [Settings] Fix right click menu display issue (#44982)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This pull request updates the tray icon context menu logic to better
reflect the state of the "Quick Access" feature. The menu now
dynamically updates its items and labels based on whether Quick Access
is enabled or disabled, improving clarity for users.

**Menu behavior improvements:**

* The tray icon menu now reloads itself when the Quick Access setting
changes, ensuring the menu always matches the current state.
* The "Settings" menu item label changes to "Settings\tLeft-click" when
Quick Access is disabled, providing clearer instructions to users.
[[1]](diffhunk://#diff-e5efbda4c356e159a6ca82a425db84438ab4014d1d90377b98a2eb6d9632d32dR176-R179)
[[2]](diffhunk://#diff-7139ecb2cf76e472c574a155268c19e919e2cce05d9d345c50c1f1bffc939e1aR198-R248)
* The Quick Access menu item is removed from the context menu when the
feature is disabled, preventing confusion.

**Internal state tracking:**

* Added a new variable `last_quick_access_state` to track the previous
Quick Access state and trigger menu reloads only when necessary.
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44810
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
- When Quick Access is disabled

<img width="1537" height="312" alt="image"
src="https://github.com/user-attachments/assets/5d51f24e-ccb4-4973-afaa-8b64cc35db87"
/>

- When Quick Access is enabled
<img width="1601" height="201" alt="image"
src="https://github.com/user-attachments/assets/56366d10-bcec-4892-b2d2-f8213ad726aa"
/>

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-23 14:47:35 +08:00
moooyo
d192672c74 fix: Improve Unicode normalization and add regex metachar tests (#44944)
Enhanced SanitizeAndNormalize to handle Unicode normalization more
robustly, ensuring correct buffer sizing and error handling. Added unit
tests for regex metacharacters `$` and `^` to verify correct replacement
behavior at string boundaries. Improves Unicode support and test
coverage for regex edge cases.

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44942 #44892
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

---------

Co-authored-by: Yu Leng <yuleng@microsoft.com>
2026-01-23 14:43:21 +08:00
Kai Tao
60b8419366 Runner TrayIcon: Monochrome icon should adapt to windows theme instead of the app theme (#44931)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
As title
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [X] Closes: #44891
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
============ System light + App Light
<img width="903" height="239" alt="image"
src="https://github.com/user-attachments/assets/581606fb-99b5-4df9-a520-545a0c04676c"
/>
============ System Light + App Dark
<img width="991" height="239" alt="image"
src="https://github.com/user-attachments/assets/822009e9-57cf-452b-b3aa-f1cbc25883f8"
/>
============ System Dark + App Light
<img width="932" height="236" alt="image"
src="https://github.com/user-attachments/assets/98a56d48-31f0-4f75-95a4-8c7dc83c3866"
/>
============ System Dark + App Dark
<img width="903" height="236" alt="image"
src="https://github.com/user-attachments/assets/2500a0d5-6b27-403e-89b4-69b7d3b91e79"
/>
============
2026-01-23 10:47:19 +08:00
Kai Tao
d46a996fcd Cmdpal: use latest msix to install (#44886)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
We should install latest cmdpal msix
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #44860
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-23 09:58:53 +08:00
Jiří Polášek
395850389f CmdPal: Improve loading of application icons - part 1 (#44938)
## Summary of the Pull Request

This PR improves loading of application icons:

- Fixes loading of icons from internet shortcuts

## Pictures? Pictures!

<img width="683" height="399" alt="image"
src="https://github.com/user-attachments/assets/5e566648-7b1a-4254-8afd-557a321b19d6"
/>


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #44819
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
2026-01-22 19:25:24 +01:00
1835 changed files with 43399 additions and 8167 deletions

View File

@@ -0,0 +1,8 @@
{
"permissions": {
"allow": [
"Bash(grep:*)",
"Bash(ls:*)"
]
}
}

View File

@@ -565,7 +565,7 @@ perl(?:\s+-[a-zA-Z]\w*)+
regexp?\.MustCompile\((?:`[^`]*`|".*"|'.*')\)
# regex choice
\(\?:[^)]+\|[^)]+\)
# \(\?:[^)]+\|[^)]+\)
# proto
^\s*(\w+)\s\g{-1} =

View File

@@ -101,11 +101,16 @@
^doc/devdocs/akaLinks\.md$
^NOTICE\.md$
^src/common/CalculatorEngineCommon/exprtk\.hpp$
^src/common/UnitTests-CommonUtils/
^src/common/ManagedCommon/ColorFormatHelper\.cs$
^src/common/notifications/BackgroundActivatorDLL/cpp\.hint$
^src/common/sysinternals/Eula/
^src/modules/cmdpal/Tests/Microsoft\.CommandPalette\.Extensions\.Toolkit\.UnitTests/FuzzyMatcherComparisonTests.cs$
^src/modules/cmdpal/Tests/Microsoft\.CommandPalette\.Extensions\.Toolkit\.UnitTests/FuzzyMatcherDiacriticsTests.cs$
^src/modules/cmdpal/doc/initial-sdk-spec/list-elements-mock-002\.pdn$
^src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleMarkdownImagesPage\.cs$
^src/modules/cmdpal/Microsoft\.CmdPal\.UI/Settings/InternalPage\.SampleData\.cs$
^src/modules/cmdpal/Tests/Microsoft\.CmdPal\.Core\.Common\.UnitTests/.*\.TestData\.cs$
^src/modules/colorPicker/ColorPickerUI/Shaders/GridShader\.cso$
^src/modules/launcher/Plugins/Microsoft\.PowerToys\.Run\.Plugin\.TimeDate/Properties/
^src/modules/MouseUtils/MouseJumpUI/MainForm\.resx$

View File

@@ -11,6 +11,7 @@ ACCESSDENIED
ACCESSTOKEN
acfs
ACIE
ACR
AClient
AColumn
acrt
@@ -22,7 +23,6 @@ ADate
ADDSTRING
ADDUNDORECORD
ADifferent
adjacents
ADMINS
adml
admx
@@ -45,6 +45,7 @@ ALLCHILDREN
ALLINPUT
Allman
Allmodule
ALLNOISE
ALLOWUNDO
ALLVIEW
ALPHATYPE
@@ -58,7 +59,6 @@ AOC
aocfnapldcnfbofgmbbllojgocaelgdd
AOklab
aot
APARTMENTTHREADED
APeriod
apicontract
apidl
@@ -96,6 +96,7 @@ asf
Ashcraft
AShortcut
ASingle
ASUS
ASSOCCHANGED
ASSOCF
ASSOCSTR
@@ -103,9 +104,9 @@ ASYNCWINDOWPLACEMENT
ASYNCWINDOWPOS
atl
ATRIOX
ATX
aumid
authenticode
AUO
AUTOBUDDY
AUTOCHECKBOX
AUTOHIDE
@@ -123,6 +124,10 @@ azureaiinference
azureinference
azureopenai
backticks
Backlight
Badflags
Badmode
Badparam
bbwe
BCIE
bck
@@ -131,6 +136,7 @@ bezelled
bhid
BIF
bigbar
BIGGERSIZEOK
bigobj
binlog
binres
@@ -195,6 +201,7 @@ Carlseibert
CAtl
caub
CBN
Cds
cch
CCHDEVICENAME
CCHFORMNAME
@@ -214,20 +221,22 @@ checkmarks
CHILDACTIVATE
CHILDWINDOW
CHOOSEFONT
Chunghwa
CIBUILD
cidl
CIELCh
cim
CImage
cla
claude
CLASSDC
classguid
classmethod
CLASSNOTAVAILABLE
claude
CLEARTYPE
clickable
clickonce
CLIENTEDGE
clientedge
clientid
clientside
CLIPBOARDUPDATE
@@ -239,6 +248,7 @@ CLSCTX
clsids
Clusion
cmder
CMN
CMDNOTFOUNDMODULEINTERFACE
cmdpal
CMIC
@@ -262,7 +272,6 @@ colorhistory
colorhistorylimit
COLORKEY
colorref
Convs
comctl
comdlg
comexp
@@ -283,6 +292,7 @@ CONTEXTHELP
CONTEXTMENUHANDLER
contractversion
CONTROLPARENT
Convs
copiedcolorrepresentation
coppied
copyable
@@ -293,12 +303,12 @@ Corpor
cotaskmem
COULDNOT
countof
Cowait
covrun
cpcontrols
cph
cplusplus
CPower
cppcoreguidelines
cpptools
cppvsdbg
cppwinrt
@@ -312,11 +322,14 @@ CRECT
CRH
critsec
cropandlock
crt
CROPTOSQUARE
Crossdevice
csdevkit
CSearch
CSettings
cso
CSOT
CSRW
CStyle
cswin
@@ -327,7 +340,7 @@ CURRENTDIR
CURSORINFO
cursorpos
CURSORSHOWING
CURSORWRAP
cursorwrap
customaction
CUSTOMACTIONTEST
CUSTOMFORMATPLACEHOLDER
@@ -350,18 +363,23 @@ datareader
datatracker
dataversion
Dayof
dbcc
DBID
DBLCLKS
DBLEPSILON
DBPROP
DBPROPIDSET
DBPROPSET
DBT
DCBA
DCapabilities
DCOM
DComposition
DCR
ddc
DDEIf
Deact
debouncer
debugbreak
decryptor
Dedup
@@ -373,13 +391,13 @@ DEFAULTICON
defaultlib
DEFAULTONLY
DEFAULTSIZE
DEFAULTTONEAREST
Defaulttonearest
defaulttonearest
DEFAULTTONULL
DEFAULTTOPRIMARY
DEFERERASE
DEFPUSHBUTTON
deinitialization
DELA
DELETEDKEYIMAGE
DELETESCANS
DEMOTYPE
@@ -396,31 +414,38 @@ DESKTOPVERTRES
devblogs
devdocs
devenv
DEVICEINTERFACE
devicetype
DEVINTERFACE
devmgmt
DEVMODE
DEVMODEW
DEVNODES
devpal
DEVTYP
dfx
DIALOGEX
digicert
diffs
digicert
DINORMAL
DISABLEASACTIONKEY
DISABLENOSCROLL
diskmgmt
DISPLAYCHANGE
DISPLAYCONFIG
displayconfig
DISPLAYFLAGS
DISPLAYFREQUENCY
displayname
DISPLAYORIENTATION
diu
divyan
Dlg
DLGFRAME
DLGMODALFRAME
dlgmodalframe
dlib
dllhost
dllmain
Dmdo
DNLEN
DONOTROUND
DONTVALIDATEPATH
@@ -430,6 +455,7 @@ downsampling
downscale
DPICHANGED
DPIs
DPMS
DPSAPI
DQTAT
DQTYPE
@@ -467,15 +493,19 @@ DWMWINDOWMAXIMIZEDCHANGE
DWORDLONG
dworigin
dwrite
Dxva
dxgi
eab
EAccess
easeofaccess
ecount
Edid
edid
EDITKEYBOARD
EDITSHORTCUTS
EDITTEXT
EFile
EInvalid
eep
eku
emojis
ENABLEDELAYEDEXPANSION
@@ -485,14 +515,15 @@ ENABLETEMPLATE
encodedlaunch
encryptor
ENDSESSION
ENot
ENSUREVISIBLE
ENTERSIZEMOVE
ENTRYW
ENU
environmentvariables
EOAC
EPO
epu
EProvider
ERASEBKGND
EREOF
EResize
@@ -546,7 +577,7 @@ fdx
FErase
fesf
FFFF
FInc
FFh
Figma
FILEEXPLORER
fileexploreraddons
@@ -567,6 +598,7 @@ FILESYSPATH
Filetime
FILEVERSION
FILTERMODE
FInc
findfast
findmymouse
FIXEDFILEINFO
@@ -588,11 +620,13 @@ formatetc
FORPARSING
foundrylocal
FRAMECHANGED
Framechanged
FRestore
frm
FROMTOUCH
fsanitize
fsmgmt
ftps
fuzzingtesting
fxf
FZE
@@ -630,6 +664,7 @@ GMEM
GNumber
googleai
googlegemini
Gotchas
gpedit
gpo
GPOCA
@@ -647,6 +682,8 @@ gwl
GWLP
GWLSTYLE
hangeul
Hann
Hantai
Hanzi
Hardlines
hardlinks
@@ -668,13 +705,14 @@ HCRYPTPROV
hcursor
hcwhite
hdc
HDEVNOTIFY
hdr
hdrop
hdwwiz
Helpline
helptext
HGFE
hgdiobj
HGFE
hglobal
hhk
HHmmssfff
@@ -704,6 +742,7 @@ HKPD
HKU
HMD
hmenu
HMON
hmodule
hmonitor
homies
@@ -721,6 +760,7 @@ hotkeys
hotlight
hotspot
HPAINTBUFFER
HPhysical
HRAWINPUT
hredraw
hres
@@ -731,6 +771,7 @@ hsb
HSCROLL
hsi
HSpeed
HSync
HTCLIENT
hthumbnail
HTOUCHINPUT
@@ -740,6 +781,7 @@ HVal
HValue
Hvci
hwb
HWP
HWHEEL
HWINEVENTHOOK
hwnd
@@ -750,9 +792,10 @@ HWNDPARENT
HWNDPREV
hyjiacan
IAI
icf
ICONERROR
ICONLOCATION
icf
ICONONLY
IDCANCEL
IDD
idk
@@ -796,6 +839,7 @@ INITTOLOGFONTSTRUCT
INLINEPREFIX
inlines
Inno
Innolux
INPC
inproc
INPUTHARDWARE
@@ -837,19 +881,21 @@ istep
ith
ITHUMBNAIL
IUI
IVO
IUWP
IWIC
jeli
jfif
jgeosdfsdsgmkedfgdfgdfgbkmhcgcflmi
jjw
JOBOBJECT
jobject
JOBOBJECT
jpe
jpnime
Jsons
jsonval
jxr
Kantai
keybd
KEYBDDATA
KEYBDINPUT
@@ -871,6 +917,7 @@ KILLFOCUS
killrunner
kmph
kvp
KVM
Kybd
LARGEICON
lastcodeanalysissucceeded
@@ -886,11 +933,15 @@ Lclean
Ldone
Ldr
LEFTALIGN
leftclick
LEFTSCROLLBAR
LEFTTEXT
LError
LEVELID
LExit
Lenovo
LGD
LFU
lhwnd
LIBFUZZER
LIBID
@@ -930,9 +981,9 @@ LOWORD
lparam
LPBITMAPINFOHEADER
LPCFHOOKPROC
lpch
LPCITEMIDLIST
LPCLSID
lpch
lpcmi
LPCMINVOKECOMMANDINFO
LPCREATESTRUCT
@@ -948,6 +999,7 @@ LPMONITORINFO
LPOSVERSIONINFOEXW
LPQUERY
lprc
LPrivate
LPSAFEARRAY
lpstr
lpsz
@@ -957,7 +1009,6 @@ lptpm
LPTR
LPTSTR
lpv
LPrivate
LPW
lpwcx
lpwndpl
@@ -995,24 +1046,27 @@ MAPTOSAMESHORTCUT
MAPVK
MARKDOWNPREVIEWHANDLERCPP
MAXIMIZEBOX
Maximizebox
MAXSHORTCUTSIZE
maxversiontested
mber
MBM
MBR
Mbuttondown
mcp
MDICHILD
MDL
mdtext
mdtxt
mdwn
mccs
meme
mcp
memicmp
MENUITEMINFO
MENUITEMINFOW
MERGECOPY
MERGEPAINT
Metacharacter
metadatamatters
Metadatas
metafile
@@ -1027,6 +1081,7 @@ mikeclayton
mindaro
Minimizable
MINIMIZEBOX
Minimizebox
MINIMIZEEND
MINIMIZESTART
MINMAXINFO
@@ -1042,8 +1097,8 @@ mmi
mmsys
mobileredirect
mockapi
modelcontextprotocol
MODALFRAME
modelcontextprotocol
MODESPRUNED
MONITORENUMPROC
MONITORINFO
@@ -1062,7 +1117,8 @@ mouseutils
MOVESIZEEND
MOVESIZESTART
MRM
MRT
Mrt
mrt
mru
MSAL
msc
@@ -1087,9 +1143,10 @@ MSLLHOOKSTRUCT
Mso
msrc
msstore
mstsc
mswhql
msvcp
MT
mstsc
MTND
MULTIPLEUSE
multizone
@@ -1099,12 +1156,13 @@ muxxc
muxxh
MVPs
mvvm
myorg
myrepo
MVVMTK
MWBEx
MYICON
myorg
myrepo
NAMECHANGE
Nanjing
namespaceanddescendants
nao
NCACTIVATE
@@ -1173,6 +1231,7 @@ NOMCX
NOMINMAX
NOMIRRORBITMAP
NOMOVE
Nomove
NONANTIALIASED
nonclient
NONCLIENTMETRICSW
@@ -1194,6 +1253,7 @@ NORMALUSER
NOSEARCH
NOSENDCHANGING
NOSIZE
Nosize
NOTHOUSANDS
NOTICKS
NOTIFICATIONSDLL
@@ -1201,9 +1261,11 @@ NOTIFYICONDATA
NOTIFYICONDATAW
NOTIMPL
NOTOPMOST
Notopmost
NOTRACK
NOTSRCCOPY
NOTSRCERASE
Notupdated
notwindows
NOTXORPEN
nowarn
@@ -1244,11 +1306,10 @@ opencode
OPENFILENAME
openrdp
opensource
openxmlformats
ollama
onnx
openurl
openxmlformats
OPTIMIZEFORINVOKE
Optronics
ORPHANEDDIALOGTITLE
ORSCANS
oss
@@ -1284,6 +1345,7 @@ PATINVERT
PATPAINT
pbc
pbi
PBP
PBlob
pbrush
pcb
@@ -1298,6 +1360,7 @@ PDBs
PDEVMODE
pdisp
PDLL
pdmodels
pdo
pdto
pdtobj
@@ -1320,12 +1383,13 @@ pguid
phbm
phbmp
phicon
PHL
Photoshop
phwnd
pici
pidl
PIDLIST
PII
pii
pinfo
pinvoke
pipename
@@ -1352,6 +1416,8 @@ Popups
POPUPWINDOW
POSITIONITEM
POWERBROADCAST
powerdisplay
POWERDISPLAYMODULEINTERFACE
POWERRENAMECONTEXTMENU
powerrenameinput
POWERRENAMETEST
@@ -1406,6 +1472,7 @@ projectname
PROPERTYKEY
Propset
PROPVARIANT
prot
PRTL
prvpane
psapi
@@ -1433,12 +1500,16 @@ PTOKEN
PToy
ptstr
pui
pvct
PWAs
pwcs
PWSTR
pwsz
pwtd
Qdc
QDC
qdc
QDS
qit
QITAB
QITABENT
@@ -1464,7 +1535,6 @@ rbhid
Rbuttondown
rclsid
RCZOOMIT
remotedesktop
rdp
RDW
READMODE
@@ -1483,7 +1553,9 @@ regfile
REGISTERCLASSFAILED
REGISTRYHEADER
REGISTRYPREVIEWEXT
registryroot
regkey
regroot
regsvr
REINSTALLMODE
releaseblog
@@ -1493,6 +1565,7 @@ remappings
REMAPSUCCESSFUL
REMAPUNSUCCESSFUL
Remotable
remotedesktop
remoteip
Removelnk
renamable
@@ -1526,8 +1599,8 @@ RIGHTSCROLLBAR
riid
RKey
RNumber
rop
rollups
rop
ROUNDSMALL
ROWSETEXT
rpcrt
@@ -1659,6 +1732,7 @@ sigdn
Signedness
SIGNINGSCENARIO
signtool
SIIGBF
SINGLEKEY
sipolicy
SIZEBOX
@@ -1711,6 +1785,7 @@ srw
srwlock
sse
ssf
Ssn
sszzz
STACKFRAME
stackoverflow
@@ -1722,6 +1797,7 @@ STARTUPINFOW
startupscreen
STATFLAG
STATICEDGE
Staticedge
staticmethod
STATSTG
stdafx
@@ -1758,9 +1834,9 @@ subkeys
sublang
SUBMODULEUPDATE
subresource
swp
Superbar
sut
swe
svchost
SVGIn
SVGIO
@@ -1787,8 +1863,7 @@ SYSKEY
syskeydown
SYSKEYUP
SYSLIB
SYSMENU
Sysmenu
sysmenu
systemai
SYSTEMAPPS
SYSTEMMODAL
@@ -1823,12 +1898,15 @@ TEXTBOXNEWLINE
textextractor
TEXTINCLUDE
tfopen
tgamma
tgz
THEMECHANGED
themeresources
THH
THICKFRAME
Thickframe
THISCOMPONENT
Tianma
throughs
TILEDWINDOW
TILLSON
@@ -1892,9 +1970,9 @@ uitests
UITo
ULONGLONG
Ultrawide
ums
UMax
UMin
ums
uncompilable
UNCPRIORITY
UNDNAME
@@ -1909,13 +1987,13 @@ UNLEN
UNORM
unremapped
Unsubscribes
unsubscribes
unvirtualized
unwide
unzoom
UOffset
UOI
UPDATENOW
UPDATEREGISTRY
updown
UPGRADINGPRODUCTCODE
upscaling
@@ -1942,6 +2020,8 @@ vcamp
vcenter
vcgtq
VCINSTALLDIR
vcp
vcpname
Vcpkg
VCRT
vcruntime
@@ -1954,6 +2034,8 @@ VERIFYCONTEXT
VERSIONINFO
VERTRES
VERTSIZE
VESA
vesa
VFT
vget
vgetq
@@ -1985,6 +2067,7 @@ VSM
vso
vsonline
VSpeed
VSync
vstemplate
vstest
VSTHRD
@@ -2026,7 +2109,7 @@ winapi
winappsdk
windir
WINDOWCREATED
WINDOWEDGE
windowedge
WINDOWINFO
WINDOWNAME
WINDOWPLACEMENT
@@ -2050,12 +2133,12 @@ WINL
winlogon
winmd
winml
WINNT
winres
winrt
winsdk
winsta
WINTHRESHOLD
WINNT
WINVER
winxamlmanager
withinrafael
@@ -2067,6 +2150,7 @@ WKSG
Wlkr
wmain
Wman
wmi
WMI
WMICIM
wmimgmt
@@ -2079,6 +2163,7 @@ WNDCLASSEX
WNDCLASSEXW
WNDCLASSW
WNDPROC
Wndproc
wnode
wom
WORKSPACESEDITOR

View File

@@ -274,5 +274,18 @@ St&yle
# 0x6f677548 is user name but user folder causes a flag
\bx6f677548\b
# Windows API constants and hardware interface terms
\bCOINIT[_A-Z]*\b
\bEOAC[_A-Z]*\b
\b(?:RPC_C_AUTHN_)?WINNT\b
\bUPDATEREGISTRY\b
\b(?:CDS_)?UPDATEREGISTRY\b
# Display interface terms (HDMI, DVI, DisplayPort)
\b(?:HDMI|DVI|DisplayPort)(?:-\d+)?\b
# 2D Region struct names
\bDisplayConfig2?D?Region\b
# Microsoft Store URLs and product IDs
ms-windows-store://\S+

View File

@@ -1,6 +1,5 @@
---
agent: 'agent'
model: 'GPT-5.1-Codex-Max'
description: 'Generate an 80-character git commit title for the local diff'
---

View File

@@ -1,6 +1,5 @@
---
agent: 'agent'
model: 'GPT-5.1-Codex-Max'
description: 'Generate a PowerToys-ready pull request description from the local diff'
---

View File

@@ -1,6 +1,5 @@
---
agent: 'agent'
model: 'GPT-5.1-Codex-Max'
description: 'Execute the fix for a GitHub issue using the previously generated implementation plan'
---

View File

@@ -0,0 +1,70 @@
---
description: 'Fix active pull request comments with scoped changes'
name: 'fix-pr-active-comments'
agent: 'agent'
argument-hint: 'PR number or active PR URL'
---
# Fix Active PR Comments
## Mission
Resolve active pull request comments by applying only simple fixes. For complex refactors, write a plan instead of changing code.
## Scope & Preconditions
- You must have an active pull request context or a provided PR number.
- Only implement simple changes. Do not implement large refactors.
- If required context is missing, request it and stop.
## Inputs
- Required: ${input:pr_number:PR number or URL}
- Optional: ${input:comment_scope:files or areas to focus on}
- Optional: ${input:fixing_guidelines:additional fixing guidelines from the user}
## Workflow
1. Locate all active (unresolved) PR review comments for the given PR.
2. For each comment, classify the change scope:
- Simple change: limited edits, localized fix, low risk, no broad redesign.
- Large refactor: multi-file redesign, architecture change, or risky behavior change.
3. For each large refactor request:
- Do not modify code.
- Write a planning document to Generated Files/prReview/${input:pr_number}/fixPlan/.
4. For each simple change request:
- Implement the fix with minimal edits.
- Run quick checks if needed.
- Commit and push the change.
5. For comments that seem invalid, unclear, or not applicable (even if simple):
- Do not change code.
- Add the item to a summary table in Generated Files/prReview/${input:pr_number}/fixPlan/overview.md.
- Consult back to the end user in a friendly, polite tone.
6. Respond to each comment that you fixed:
- Reply in the active conversation.
- Use a polite or friendly tone.
- Keep the response under 200 words.
- Resolve the comment after replying.
## Output Expectations
- Simple fixes: code changes committed and pushed.
- Large refactors: a plan file saved to Generated Files/prReview/${input:pr_number}/fixPlan/.
- Invalid or unclear comments: captured in Generated Files/prReview/${input:pr_number}/fixPlan/overview.md.
- Each fixed comment has a reply under 200 words and is resolved.
## Plan File Template
Use this template for each large refactor item:
# Fix Plan: <short title>
## Context
- Comment link:
- Impacted areas:
## Overview Table Template
Use this table in Generated Files/prReview/${input:pr_number}/fixPlan/overview.md:
| Comment link | Summary | Reason not applied | Suggested follow-up |
| --- | --- | --- | --- |
| | | | |
## Quality Assurance
- Verify plan file path exists.
- Ensure no code changes were made for large refactor items.
- Confirm replies are under 200 words and comments are resolved.

View File

@@ -1,6 +1,5 @@
---
agent: 'agent'
model: 'GPT-5.1-Codex-Max'
description: 'Resolve Code scanning / check-spelling comments on the active PR'
---

View File

@@ -1,6 +1,5 @@
---
agent: 'agent'
model: 'GPT-5.1-Codex-Max'
description: 'Review a GitHub issue, score it (0-100), and generate an implementation plan'
---

View File

@@ -1,6 +1,5 @@
---
agent: 'agent'
model: 'GPT-5.1-Codex-Max'
description: 'Perform a comprehensive PR review with per-step Markdown and machine-readable outputs'
---

View File

@@ -210,6 +210,11 @@
"PowerToys.PowerAccentModuleInterface.dll",
"PowerToys.PowerAccentKeyboardService.dll",
"PowerToys.PowerDisplayModuleInterface.dll",
"WinUI3Apps\\PowerToys.PowerDisplay.dll",
"WinUI3Apps\\PowerToys.PowerDisplay.exe",
"PowerDisplay.Lib.dll",
"WinUI3Apps\\PowerToys.PowerRenameExt.dll",
"WinUI3Apps\\PowerToys.PowerRename.exe",
"WinUI3Apps\\PowerToys.PowerRenameContextMenu.dll",
@@ -378,6 +383,8 @@
"UnitsNet.dll",
"UtfUnknown.dll",
"Wpf.Ui.dll",
"WmiLight.dll",
"WmiLight.Native.dll",
"Shmuelie.WinRTServer.dll",
"ToolGood.Words.Pinyin.dll"
],

View File

@@ -35,7 +35,9 @@ stages:
${{ else }}:
name: SHINE-OSS-L
${{ if eq(parameters.useVSPreview, true) }}:
demands: ImageOverride -equals SHINE-VS17-Preview
demands: ImageOverride -equals SHINE-VS18-Preview
${{ else }}:
demands: ImageOverride -equals SHINE-VS18-Latest
buildPlatforms:
- ${{ parameters.platform }}
buildConfigurations: [Release]

View File

@@ -51,7 +51,9 @@ extends:
pool:
name: SHINE-INT-S
${{ if eq(parameters.useVSPreview, true) }}:
demands: ImageOverride -equals SHINE-VS17-Preview
demands: ImageOverride -equals SHINE-VS18-Preview
${{ else }}:
demands: ImageOverride -equals SHINE-VS18-Latest
os: windows
sdl:
tsa:
@@ -74,7 +76,9 @@ extends:
demands:
# Our INT agents have a large disk mounted at P:\
- ${{ if eq(parameters.useVSPreview, true) }}:
- ImageOverride -equals SHINE-VS17-Preview
- ImageOverride -equals SHINE-VS18-Latest-Preview
- ${{ else }}:
- ImageOverride -equals SHINE-VS18-Latest
os: windows
variables:
IsPipeline: 1 # The installer uses this to detect whether it should pick up localizations
@@ -87,6 +91,7 @@ extends:
official: true
codeSign: true
runTests: false
buildTests: false
signingIdentity:
serviceName: $(SigningServiceName)
appId: $(SigningAppId)

View File

@@ -253,11 +253,12 @@ jobs:
displayName: Build PowerToys main project
inputs:
solution: 'PowerToys.slnx'
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore -graph
/p:RestorePackagesConfig=true
/p:CIBuild=true
/p:BuildTests=${{ parameters.buildTests }}
/bl:$(LogOutputDirectory)\build-0-main.binlog
${{ parameters.additionalBuildOptions }}
$(MSBuildCacheParameters)
@@ -276,7 +277,7 @@ jobs:
condition: and(succeeded(), eq(variables['BuildPlatform'], 'arm64'))
inputs:
solution: PowerToys.slnx
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore
/p:Configuration=$(BuildConfiguration)
@@ -338,7 +339,7 @@ jobs:
displayName: Build BugReportTool
inputs:
solution: '**/tools/BugReportTool/BugReportTool.sln'
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore -graph
/p:RestorePackagesConfig=true
@@ -359,7 +360,7 @@ jobs:
displayName: Build StylesReportTool
inputs:
solution: '**/tools/StylesReportTool/StylesReportTool.sln'
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore -graph
/p:RestorePackagesConfig=true
@@ -381,7 +382,7 @@ jobs:
displayName: Publish ${{ project }} for Packaging
inputs:
solution: ${{ project }}
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
/target:Publish
/graph

View File

@@ -82,7 +82,7 @@ jobs:
displayName: Build UI Test Projects
inputs:
solution: '**/*UITest*.csproj'
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore
-graph
@@ -103,7 +103,7 @@ jobs:
displayName: 'Build UI Test Module: ${{ module }}'
inputs:
solution: '**/*${{ module }}*.csproj'
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore
-graph

View File

@@ -49,7 +49,9 @@ stages:
${{ else }}:
name: SHINE-OSS-L
${{ if eq(parameters.useVSPreview, true) }}:
demands: ImageOverride -equals SHINE-VS17-Preview
demands: ImageOverride -equals SHINE-VS18-Preview
${{ else }}:
demands: ImageOverride -equals SHINE-VS18-Latest
buildPlatforms:
- ${{ platform }}
buildConfigurations: [Release]
@@ -57,6 +59,7 @@ stages:
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
msBuildCacheIsReadOnly: ${{ parameters.msBuildCacheIsReadOnly }}
runTests: ${{ parameters.runTests }}
buildTests: true
useVSPreview: ${{ parameters.useVSPreview }}
useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }}
${{ if eq(parameters.useLatestWinAppSDK, true) }}:
@@ -76,7 +79,9 @@ stages:
${{ else }}:
name: SHINE-OSS-L
${{ if eq(parameters.useVSPreview, true) }}:
demands: ImageOverride -equals SHINE-VS17-Preview
demands: ImageOverride -equals SHINE-VS18-Preview
${{ else }}:
demands: ImageOverride -equals SHINE-VS18-Latest
buildConfigurations: [Release]
official: false
codeSign: false

View File

@@ -29,7 +29,9 @@ stages:
${{ else }}:
name: SHINE-OSS-L
${{ if eq(parameters.useVSPreview, true) }}:
demands: ImageOverride -equals SHINE-VS17-Preview
demands: ImageOverride -equals SHINE-VS18-Preview
${{ else }}:
demands: ImageOverride -equals SHINE-VS18-Latest
buildPlatforms:
- ${{ parameters.platform }}
buildConfigurations: [Release]

View File

@@ -36,7 +36,7 @@ steps:
displayName: Build Shared Support DLLs
inputs:
solution: "**/installer/PowerToysSetup.slnx"
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
/t:PowerToysSetupCustomActionsVNext;SilentFilesInUseBAFunction
/p:RunBuildEvents=true;RestorePackagesConfig=true;CIBuild=true
@@ -75,7 +75,7 @@ steps:
displayName: 💻 Build VNext MSI
inputs:
solution: "**/installer/PowerToysSetup.slnx"
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore
/t:PowerToysInstallerVNext
@@ -92,7 +92,7 @@ steps:
displayName: 👤 Build VNext MSI
inputs:
solution: "**/installer/PowerToysSetup.slnx"
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
/t:PowerToysInstallerVNext
/p:RunBuildEvents=false;PerUser=true;BuildProjectReferences=false;CIBuild=true
@@ -143,7 +143,7 @@ steps:
displayName: 💻 Build VNext Bootstrapper
inputs:
solution: "**/installer/PowerToysSetup.slnx"
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
-restore
/t:PowerToysBootstrapperVNext
@@ -160,7 +160,7 @@ steps:
displayName: 👤 Build VNext Bootstrapper
inputs:
solution: "**/installer/PowerToysSetup.slnx"
vsVersion: 17.0
vsVersion: 18.0
msbuildArgs: >-
/t:PowerToysBootstrapperVNext
/p:PerUser=true;BuildProjectReferences=false;CIBuild=true

View File

@@ -1,9 +1,16 @@
$VSInstances = ([xml](& 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -include packages -format xml))
# Build common vswhere base arguments
$vsWhereBaseArgs = @('-latest', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64')
if ($env:VCWhereExtraVersionTarget) {
# Add version target if specified (e.g., '-version [18.0,19.0)' for VS2026)
$vsWhereBaseArgs += $env:VCWhereExtraVersionTarget.Split(' ')
}
$VSInstances = ([xml](& 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' @vsWhereBaseArgs -include packages -format xml))
$VSPackages = $VSInstances.instances.instance.packages.package
$LatestVCPackage = ($VSPackages | ? { $_.id -eq "Microsoft.VisualCpp.Tools.Core" })
$LatestVCToolsVersion = $LatestVCPackage.version;
$VSRoot = (& 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property 'resolvedInstallationPath')
$VSRoot = (& 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' @vsWhereBaseArgs -property 'resolvedInstallationPath')
$VCToolsRoot = Join-Path $VSRoot "VC\Tools\MSVC"
# We have observed a few instances where the VC tools package version actually
@@ -24,5 +31,12 @@ If ($Null -Eq (Get-Item $PackageVCToolPath -ErrorAction:Ignore)) {
}
Write-Output "Latest VCToolsVersion: $LatestVCToolsVersion"
Write-Output "Updating VCToolsVersion environment variable for job"
Write-Output "##vso[task.setvariable variable=VCToolsVersion]$LatestVCToolsVersion"
# VS2026 (MSVC 14.50+) doesn't need explicit VCToolsVersion - let MSBuild auto-select
$MajorMinorVersion = [Version]::Parse($LatestVCToolsVersion)
If ($MajorMinorVersion.Major -eq 14 -and $MajorMinorVersion.Minor -ge 50) {
Write-Output "VS2026 detected (MSVC 14.50+). Skipping VCToolsVersion override to allow MSBuild auto-selection."
} Else {
Write-Output "Updating VCToolsVersion environment variable for job"
Write-Output "##vso[task.setvariable variable=VCToolsVersion]$LatestVCToolsVersion"
}

View File

@@ -90,9 +90,15 @@ if ($noticeMatch.Success) {
$currentNoticePackageList = ""
}
# Test-only packages that are allowed to be in NOTICE.md but not in the build
# (e.g., when BuildTests=false, these packages won't appear in the NuGet list)
$allowedExtraPackages = @(
"- Moq"
)
if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
{
Write-Host -ForegroundColor Red "Notice.md does not match NuGet list."
Write-Host -ForegroundColor Yellow "Notice.md does not exactly match NuGet list. Analyzing differences..."
# Show detailed differences
$generatedPackages = $returnList -split "`r`n|`n" | Where-Object { $_.Trim() -ne "" } | Sort-Object
@@ -105,7 +111,7 @@ if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
# Find packages in proj file list but not in NOTICE.md
$missingFromNotice = $generatedPackages | Where-Object { $noticePackages -notcontains $_ }
if ($missingFromNotice.Count -gt 0) {
Write-Host -ForegroundColor Red "MissingFromNotice:"
Write-Host -ForegroundColor Red "MissingFromNotice (ERROR - these must be added to NOTICE.md):"
foreach ($pkg in $missingFromNotice) {
Write-Host -ForegroundColor Red " $pkg"
}
@@ -114,10 +120,23 @@ if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
# Find packages in NOTICE.md but not in proj file list
$extraInNotice = $noticePackages | Where-Object { $generatedPackages -notcontains $_ }
if ($extraInNotice.Count -gt 0) {
Write-Host -ForegroundColor Yellow "ExtraInNotice:"
foreach ($pkg in $extraInNotice) {
Write-Host -ForegroundColor Yellow " $pkg"
# Filter out allowed extra packages (test-only dependencies)
$unexpectedExtra = $extraInNotice | Where-Object { $allowedExtraPackages -notcontains $_ }
$allowedExtra = $extraInNotice | Where-Object { $allowedExtraPackages -contains $_ }
if ($allowedExtra.Count -gt 0) {
Write-Host -ForegroundColor Green "ExtraInNotice (OK - allowed test-only packages):"
foreach ($pkg in $allowedExtra) {
Write-Host -ForegroundColor Green " $pkg"
}
Write-Host ""
}
if ($unexpectedExtra.Count -gt 0) {
Write-Host -ForegroundColor Red "ExtraInNotice (ERROR - unexpected packages in NOTICE.md):"
foreach ($pkg in $unexpectedExtra) {
Write-Host -ForegroundColor Red " $pkg"
}
Write-Host ""
}
@@ -127,10 +146,17 @@ if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
Write-Host " Proj file list has $($generatedPackages.Count) packages"
Write-Host " NOTICE.md has $($noticePackages.Count) packages"
Write-Host " MissingFromNotice: $($missingFromNotice.Count) packages"
Write-Host " ExtraInNotice: $($extraInNotice.Count) packages"
Write-Host " ExtraInNotice (allowed): $($allowedExtra.Count) packages"
Write-Host " ExtraInNotice (unexpected): $($unexpectedExtra.Count) packages"
Write-Host ""
exit 1
# Fail if there are missing packages OR unexpected extra packages
if ($missingFromNotice.Count -gt 0 -or $unexpectedExtra.Count -gt 0) {
Write-Host -ForegroundColor Red "FAILED: NOTICE.md mismatch detected."
exit 1
} else {
Write-Host -ForegroundColor Green "PASSED: NOTICE.md matches (with allowed test-only packages)."
}
}
exit 0

View File

@@ -40,7 +40,7 @@ These instruction files are automatically applied when working in their respecti
### Prerequisites
- Visual Studio 2022 17.4+
- Visual Studio 2022 17.4+ or Visual Studio 2026
- Windows 10 1803+ (April 2018 Update or newer)
- Initialize submodules once: `git submodule update --init --recursive`

View File

@@ -2,6 +2,12 @@
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Skip building C++ test projects when BuildTests=false -->
<PropertyGroup Condition="'$(_IsSkippedTestProject)' == 'true'">
<UsePrecompiledHeaders>false</UsePrecompiledHeaders>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<!-- Project configurations -->
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
@@ -51,7 +57,7 @@
<PrecompiledHeader Condition="'$(UsePrecompiledHeaders)' != 'false'">Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<DisableSpecificWarnings>4679;5271;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>4679;4706;4874;5271;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableAnalyzeExternal >true</DisableAnalyzeExternal>
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
<ConformanceMode>false</ConformanceMode>
@@ -110,6 +116,7 @@
<!-- Props that are constant for both Debug and Release configurations -->
<PropertyGroup Label="Configuration">
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '18.0'">v145</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<DesktopCompatible>true</DesktopCompatible>
<SpectreMitigation>Spectre</SpectreMitigation>

View File

@@ -19,6 +19,39 @@
<PlatformTarget>$(Platform)</PlatformTarget>
</PropertyGroup>
<!--
Completely skip building test projects when BuildTests=false (e.g., Release pipeline).
This avoids InternalsVisibleTo/signing issues by not compiling test code at all.
Match: projects ending in Test, Tests, UnitTests, UITests, FuzzTests, or in a folder named Tests.
Also matches projects starting with UnitTests- (e.g., UnitTests-CommonLib).
Also removes all PackageReference/ProjectReference to prevent NuGet restore and dependency builds.
Note: Checking both 'false' and 'False' to handle YAML boolean serialization.
-->
<PropertyGroup Condition="'$(BuildTests)' == 'false' or '$(BuildTests)' == 'False'">
<_ProjectName>$(MSBuildProjectName)</_ProjectName>
<!-- Match any project ending with "Test" or "Tests" (covers UnitTests, UITests, FuzzTests, etc.) -->
<_IsSkippedTestProject Condition="$(_ProjectName.EndsWith('Test'))">true</_IsSkippedTestProject>
<_IsSkippedTestProject Condition="$(_ProjectName.EndsWith('Tests'))">true</_IsSkippedTestProject>
<!-- Match projects starting with UnitTests- or UITest- prefix -->
<_IsSkippedTestProject Condition="$(_ProjectName.StartsWith('UnitTests-'))">true</_IsSkippedTestProject>
<_IsSkippedTestProject Condition="$(_ProjectName.StartsWith('UITest-'))">true</_IsSkippedTestProject>
<!-- Match projects in a Tests folder -->
<_IsSkippedTestProject Condition="$(MSBuildProjectDirectory.Contains('\Tests\'))">true</_IsSkippedTestProject>
</PropertyGroup>
<PropertyGroup Condition="'$(_IsSkippedTestProject)' == 'true'">
<EnableDefaultItems>false</EnableDefaultItems>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateGlobalUsings>false</GenerateGlobalUsings>
<ImplicitUsings>disable</ImplicitUsings>
<!-- Disable all code analysis for skipped test projects -->
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<RunAnalyzers>false</RunAnalyzers>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<Version>$(Version).0</Version>
<RepositoryUrl>https://github.com/microsoft/PowerToys</RepositoryUrl>
@@ -30,7 +63,9 @@
<_PropertySheetDisplayName>PowerToys.Root.Props</_PropertySheetDisplayName>
<ForceImportBeforeCppProps>$(MsbuildThisFileDirectory)\Cpp.Build.props</ForceImportBeforeCppProps>
</PropertyGroup>
<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj' and '$(_IsSkippedTestProject)' != 'true'">
<PackageReference Include="StyleCop.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@@ -28,4 +28,41 @@
<PropertyGroup Condition="'$(IgnoreExperimentalWarnings)' == 'true'">
<NoWarn>$(NoWarn);CS8305;SA1500;CA1852</NoWarn>
</PropertyGroup>
</Project>
<!-- Skipped test projects when BuildTests=false: no-op build and remove references.
This must be in targets (not props) so it runs AFTER the project file adds its items. -->
<PropertyGroup Condition="'$(_IsSkippedTestProject)' == 'true'">
<BuildDependsOn />
<CoreBuildDependsOn />
<RebuildDependsOn />
</PropertyGroup>
<!-- For C# projects: remove all items -->
<ItemGroup Condition="'$(_IsSkippedTestProject)' == 'true' and '$(MSBuildProjectExtension)' == '.csproj'">
<PackageReference Remove="@(PackageReference)" />
<ProjectReference Remove="@(ProjectReference)" />
<Reference Remove="@(Reference)" />
<Compile Remove="@(Compile)" />
<Content Remove="@(Content)" />
<EmbeddedResource Remove="@(EmbeddedResource)" />
<None Remove="@(None)" />
<Using Remove="@(Using)" />
<GlobalUsing Remove="@(GlobalUsing)" />
</ItemGroup>
<!-- For C++ projects (vcxproj): remove all compile/link items to prevent build -->
<ItemGroup Condition="'$(_IsSkippedTestProject)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">
<ClCompile Remove="@(ClCompile)" />
<ClInclude Remove="@(ClInclude)" />
<Link Remove="@(Link)" />
<Lib Remove="@(Lib)" />
<ProjectReference Remove="@(ProjectReference)" />
<None Remove="@(None)" />
<ResourceCompile Remove="@(ResourceCompile)" />
<Midl Remove="@(Midl)" />
</ItemGroup>
<!-- Note: For C++ skipped test projects, build is effectively skipped by removing all compile items above.
We don't define empty Build/Rebuild/Clean targets here because MSBuild Target definitions with Condition
on the Target element still override the default targets even when condition is false. -->
</Project>

View File

@@ -93,6 +93,7 @@
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageVersion Include="NLog.Schema" Version="5.2.8" />
<PackageVersion Include="OpenAI" Version="2.5.0" />
<PackageVersion Include="Polly.Core" Version="8.6.5" />
<PackageVersion Include="ReverseMarkdown" Version="4.1.0" />
<PackageVersion Include="RtfPipe" Version="2.0.7677.4303" />
<PackageVersion Include="ScipBe.Common.Office.OneNote" Version="3.0.1" />
@@ -104,6 +105,7 @@
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<!-- Package System.CodeDom added as a hack for being able to exclude the runtime assets so they don't conflict with 8.0.1. This is a dependency of System.Management but the 8.0.1 version wasn't published to nuget. -->
<PackageVersion Include="System.CodeDom" Version="9.0.10" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.ComponentModel.Composition" Version="9.0.10" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.10" />
@@ -133,6 +135,7 @@
<PackageVersion Include="UnitsNet" Version="5.56.0" />
<PackageVersion Include="UTF.Unknown" Version="2.6.0" />
<PackageVersion Include="WinUIEx" Version="2.8.0" />
<PackageVersion Include="WmiLight" Version="6.14.0" />
<PackageVersion Include="WPF-UI" Version="3.0.5" />
<PackageVersion Include="WyHash" Version="1.0.5" />
<PackageVersion Include="WixToolset.Heat" Version="5.0.2" />

View File

@@ -10,6 +10,7 @@ This software incorporates material from third parties.
- Installer/Runner
- Measure tool
- Peek
- PowerDisplay
- Registry Preview
## Utility: Color Picker
@@ -1519,6 +1520,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
## Utility: PowerDisplay
### Twinkle Tray
PowerDisplay's DDC/CI implementation references techniques from Twinkle Tray.
**Source**: https://github.com/xanderfrangos/twinkle-tray
MIT License
Copyright © 2020 Xander Frangos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## NuGet Packages used by PowerToys
@@ -1557,6 +1587,7 @@ SOFTWARE.
- NLog.Extensions.Logging
- NLog.Schema
- OpenAI
- Polly.Core
- ReverseMarkdown
- ScipBe.Common.Office.OneNote
- SharpCompress
@@ -1569,5 +1600,6 @@ SOFTWARE.
- UnitsNet
- UTF.Unknown
- WinUIEx
- WmiLight
- WPF-UI
- WyHash

View File

@@ -55,6 +55,7 @@
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/common/UnitTests-CommonLib/UnitTests-CommonLib.vcxproj" Id="1a066c63-64b3-45f8-92fe-664e1cce8077" />
<Project Path="src/common/UnitTests-CommonUtils/UnitTests-CommonUtils.vcxproj" Id="8b5cfb38-ccba-40a8-ad7a-89c57b070884" />
<Project Path="src/common/updating/updating.vcxproj" Id="17da04df-e393-4397-9cf0-84dabe11032e" />
<Project Path="src/common/version/version.vcxproj" Id="cc6e41ac-8174-4e8a-8d22-85dd7f4851df" />
</Folder>
@@ -197,99 +198,113 @@
<Project Path="src/modules/cmdpal/CmdPalModuleInterface/CmdPalModuleInterface.vcxproj" Id="0adeb797-c8c7-4ffa-acd5-2af6cad7ecd8" />
</Folder>
<Folder Name="/modules/CommandPalette/Built-in Extensions/">
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.Apps/Microsoft.CmdPal.Ext.Apps.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Microsoft.CmdPal.Ext.Apps.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.Bookmark/Microsoft.CmdPal.Ext.Bookmarks.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Microsoft.CmdPal.Ext.Bookmarks.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.Calc/Microsoft.CmdPal.Ext.Calc.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Microsoft.CmdPal.Ext.Calc.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.ClipboardHistory/Microsoft.CmdPal.Ext.ClipboardHistory.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Microsoft.CmdPal.Ext.ClipboardHistory.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.Indexer/Microsoft.CmdPal.Ext.Indexer.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Microsoft.CmdPal.Ext.Indexer.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Deploy />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.PowerToys/Microsoft.CmdPal.Ext.PowerToys.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Microsoft.CmdPal.Ext.PowerToys.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Deploy />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.RemoteDesktop/Microsoft.CmdPal.Ext.RemoteDesktop.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.RemoteDesktop/Microsoft.CmdPal.Ext.RemoteDesktop.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.Shell/Microsoft.CmdPal.Ext.Shell.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Microsoft.CmdPal.Ext.Shell.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.System/Microsoft.CmdPal.Ext.System.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Microsoft.CmdPal.Ext.System.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.TimeDate/Microsoft.CmdPal.Ext.TimeDate.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Microsoft.CmdPal.Ext.TimeDate.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Deploy />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.WebSearch/Microsoft.CmdPal.Ext.WebSearch.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Microsoft.CmdPal.Ext.WebSearch.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.WindowsServices/Microsoft.CmdPal.Ext.WindowsServices.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Microsoft.CmdPal.Ext.WindowsServices.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.WindowsSettings/Microsoft.CmdPal.Ext.WindowsSettings.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Microsoft.CmdPal.Ext.WindowsSettings.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.WindowsTerminal/Microsoft.CmdPal.Ext.WindowsTerminal.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Microsoft.CmdPal.Ext.WindowsTerminal.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.WindowWalker/Microsoft.CmdPal.Ext.WindowWalker.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Microsoft.CmdPal.Ext.WindowWalker.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Extensions/Microsoft.CmdPal.Ext.WinGet/Microsoft.CmdPal.Ext.WinGet.csproj">
<Project Path="src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Microsoft.CmdPal.Ext.WinGet.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Deploy />
</Project>
</Folder>
<Folder Name="/modules/CommandPalette/Core/">
<Project Path="src/modules/cmdpal/Core/Microsoft.CmdPal.Core.Common/Microsoft.CmdPal.Core.Common.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
</Folder>
<Folder Name="/modules/CommandPalette/Extension SDK/">
<Project Path="src/modules/cmdpal/SDK/Microsoft.CommandPalette.Extensions.Toolkit/Microsoft.CommandPalette.Extensions.Toolkit.csproj">
<Project Path="src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Microsoft.CommandPalette.Extensions.Toolkit.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/SDK/Microsoft.CommandPalette.Extensions/Microsoft.CommandPalette.Extensions.vcxproj" Id="305dd37e-c85d-4b08-aafe-7381fa890463" />
<Project Path="src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions/Microsoft.CommandPalette.Extensions.vcxproj" Id="305dd37e-c85d-4b08-aafe-7381fa890463" />
</Folder>
<Folder Name="/modules/CommandPalette/Sample Extensions/">
<Project Path="src/modules/cmdpal/Extensions/ProcessMonitorExtension/ProcessMonitorExtension.csproj">
<Project Path="src/modules/cmdpal/ext/ProcessMonitorExtension/ProcessMonitorExtension.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Deploy />
</Project>
<Project Path="src/modules/cmdpal/Extensions/SamplePagesExtension/SamplePagesExtension.csproj">
<Project Path="src/modules/cmdpal/ext/SamplePagesExtension/SamplePagesExtension.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Deploy />
</Project>
</Folder>
<Folder Name="/modules/CommandPalette/Tests/">
<Project Path="src/modules/cmdpal/Tests/Microsoft.CmdPal.Core.Common.UnitTests/Microsoft.CmdPal.Core.Common.UnitTests.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Apps.UnitTests/Microsoft.CmdPal.Ext.Apps.UnitTests.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
@@ -346,26 +361,22 @@
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/Tests/Microsoft.CommandPalette.Extensions.Toolkit.UnitTests/Microsoft.CommandPalette.Extensions.Toolkit.UnitTests.csproj" Id="2eca18b7-33b7-4829-88f1-439b20fd60f6">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
</Folder>
<Folder Name="/modules/CommandPalette/UI/">
<Project Path="src/modules/cmdpal/Microsoft.Terminal.UI/Microsoft.Terminal.UI.vcxproj" Id="6515f03f-e56d-4db4-b23d-ac4fb80db36f" />
<Project Path="src/modules/cmdpal/UI/Microsoft.CmdPal.UI.Common/Microsoft.CmdPal.UI.Common.csproj" Id="b0131363-c9e5-41e5-a541-8dc60760f03f">
<Project Path="src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Microsoft.CmdPal.UI.ViewModels.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/UI/Microsoft.CmdPal.UI.Services/Microsoft.CmdPal.UI.Services.csproj" Id="014f1320-7d89-4d9f-a247-f68737c0f46b">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/UI/Microsoft.CmdPal.UI.ViewModels/Microsoft.CmdPal.UI.ViewModels.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/cmdpal/UI/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj">
<Project Path="src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Deploy />
</Project>
<Project Path="src/modules/cmdpal/Microsoft.Terminal.UI/Microsoft.Terminal.UI.vcxproj" Id="6515f03f-e56d-4db4-b23d-ac4fb80db36f" />
</Folder>
<Folder Name="/modules/CropAndLock/">
<Project Path="src/modules/CropAndLock/CropAndLock/CropAndLock.vcxproj" Id="f5e1146e-b7b3-4e11-85fd-270a500bd78c" />
@@ -418,7 +429,7 @@
</Project>
</Folder>
<Folder Name="/modules/FileLocksmith/">
<Project Path="src/modules/FileLocksmith/FileLocksmithCLI/FileLocksmithCLI.vcxproj" Id="49d456d3-f485-45af-8875-45b44f193ddc" />
<Project Path="src/modules/FileLocksmith/FileLocksmithCLI/FileLocksmithCLI.vcxproj" Id="49D456D3-F485-45AF-8875-45B44F193DDC" />
<Project Path="src/modules/FileLocksmith/FileLocksmithContextMenu/FileLocksmithContextMenu.vcxproj" Id="799a50d8-de89-4ed1-8ff8-ad5a9ed8c0ca" />
<Project Path="src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj" Id="57175ec7-92a5-4c1e-8244-e3fbca2a81de" />
<Project Path="src/modules/FileLocksmith/FileLocksmithLib/FileLocksmithLib.vcxproj" Id="9d52fd25-ef90-4f9a-a015-91efc5daf54f" />
@@ -429,7 +440,7 @@
</Project>
</Folder>
<Folder Name="/modules/FileLocksmith/Tests/">
<Project Path="src/modules/FileLocksmith/FileLocksmithCLI/tests/FileLocksmithCLIUnitTests.vcxproj" Id="a1b2c3d4-e5f6-7890-1234-567890abcdef" />
<Project Path="src/modules/FileLocksmith/FileLocksmithCLI/tests/FileLocksmithCLIUnitTests.vcxproj" Id="A1B2C3D4-E5F6-7890-1234-567890ABCDEF" />
</Folder>
<Folder Name="/modules/Hosts/">
<Project Path="src/modules/Hosts/Hosts/Hosts.csproj">
@@ -455,16 +466,16 @@
</Folder>
<Folder Name="/modules/imageresizer/">
<Project Path="src/modules/imageresizer/dll/ImageResizerExt.vcxproj" Id="0b43679e-edfa-4da0-ad30-f4628b308b1b" />
<Project Path="src/modules/imageresizer/ImageResizerCLI/ImageResizerCLI.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/imageresizer/ImageResizerContextMenu/ImageResizerContextMenu.vcxproj" Id="93b72a06-c8bd-484f-a6f7-c9f280b150bf" />
<Project Path="src/modules/imageresizer/ImageResizerLib/ImageResizerLib.vcxproj" Id="18b3db45-4ffe-4d01-97d6-5223feee1853" />
<Project Path="src/modules/imageresizer/ui/ImageResizerUI.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/imageresizer/ImageResizerCLI/ImageResizerCLI.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
</Folder>
<Folder Name="/modules/imageresizer/Tests/">
<Project Path="src/modules/imageresizer/tests/ImageResizer.UnitTests.csproj">
@@ -674,6 +685,23 @@
<Deploy />
</Project>
</Folder>
<Folder Name="/modules/PowerDisplay/">
<Project Path="src/modules/powerdisplay/PowerDisplay.Lib/PowerDisplay.Lib.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/powerdisplay/PowerDisplay/PowerDisplay.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/powerdisplay/PowerDisplayModuleInterface/PowerDisplayModuleInterface.vcxproj" Id="d1234567-8901-2345-6789-abcdef012345" />
</Folder>
<Folder Name="/modules/PowerDisplay/Tests/">
<Project Path="src/modules/powerdisplay/PowerDisplay.Lib.UnitTests/PowerDisplay.Lib.UnitTests.csproj">
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
</Folder>
<Folder Name="/modules/MeasureTool/">
<Project Path="src/modules/MeasureTool/MeasureToolCore/PowerToys.MeasureToolCore.vcxproj" Id="54a93af7-60c7-4f6c-99d2-fbb1f75f853a">
<BuildDependency Project="src/common/Display/Display.vcxproj" />

View File

@@ -51,19 +51,19 @@ But to get started quickly, choose one of the installation methods below:
Go to the <a href="https://aka.ms/installPowerToys">PowerToys GitHub releases</a>, click Assets to reveal the downloads, and choose the installer that matches your architecture and install scope. For most devices, that's the x64 per-user installer.
<!-- items that need to be updated release to release -->
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.97%22
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.96%22
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.0/PowerToysUserSetup-0.97.0-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.0/PowerToysUserSetup-0.97.0-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.0/PowerToysSetup-0.97.0-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.0/PowerToysSetup-0.97.0-arm64.exe
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.98%22
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.97%22
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.1/PowerToysUserSetup-0.97.1-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.1/PowerToysUserSetup-0.97.1-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.1/PowerToysSetup-0.97.1-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.97.1/PowerToysSetup-0.97.1-arm64.exe
| Description | Filename |
|----------------|----------|
| Per user - x64 | [PowerToysUserSetup-0.97.0-x64.exe][ptUserX64] |
| Per user - ARM64 | [PowerToysUserSetup-0.97.0-arm64.exe][ptUserArm64] |
| Machine wide - x64 | [PowerToysSetup-0.97.0-x64.exe][ptMachineX64] |
| Machine wide - ARM64 | [PowerToysSetup-0.97.0-arm64.exe][ptMachineArm64] |
| Per user - x64 | [PowerToysUserSetup-0.97.1-x64.exe][ptUserX64] |
| Per user - ARM64 | [PowerToysUserSetup-0.97.1-arm64.exe][ptUserArm64] |
| Machine wide - x64 | [PowerToysSetup-0.97.1-x64.exe][ptMachineX64] |
| Machine wide - ARM64 | [PowerToysSetup-0.97.1-arm64.exe][ptMachineArm64] |
</details>
@@ -103,18 +103,38 @@ There are <a href="https://learn.microsoft.com/windows/powertoys/install#communi
</details>
## ✨ What's new
**Version 0.97 (January 2026)**
**Version 0.97.1 (January 2026)**
For an in-depth look at the latest changes, visit the [Windows Command Line blog](https://aka.ms/powertoys-releaseblog).
This patch release fixes several important stability issues identified in v0.97.0 based on incoming reports. Check out the [v0.97.0](https://github.com/microsoft/PowerToys/releases/tag/v0.97.0) notes for the full list of changes.
**Highlights**
- **Command Palette**: Major expansion with PowerToys extension (Windows 11 only), Remote Desktop built-in extension, theme customization, drag-and-drop support, fallback ranking controls, sections/separators for pages, pinyin Chinese matching, and many UX refinements.
- **Settings**: Quick Access flyout is now a standalone process for significantly faster startup, theme-adaptive tray icon, AOT serialization, and multiple UI/accessibility fixes
- **CursorWrap (New!)**: New mouse utility that lets your cursor wrap around screen edges, making multi-monitor navigation faster and more seamless.
- **Advanced Paste**: Image input for AI, color detection in clipboard history, Foundry Local improvements, Azure AI icons, and multiple bug fixes
- **CLI Support Expanded**: FancyZones, Image Resizer, and File Locksmith can now be controlled from the command line for layout management, batch image resizing, and file lock inspection.
- **LightSwitch**: Added support for automatically following Windows Night Light mode.
- **Release Experience & Quality**: Refreshed "Whats new" dialog, plus many performance improvements, stability fixes, and refinements across PowerToys.
**Highlights**
### Advanced Paste
- #44862: Fixed Settings UI advanced paste page crash by using correct settings repository for null checking.
### Command Palette
- #44886: Fixed personalization section not appearing by using latest MSIX for installation.
- #44938: Fixed loading of icons from internet shortcuts. Thanks [@jiripolasek](https://github.com/jiripolasek)!
- #45076: Fixed potential deadlock from lazy-loading AppListItem details. Thanks [@jiripolasek](https://github.com/jiripolasek)!
### Cursor Wrap
- #44936: Added improved multi-monitor support; Added laptop lid close detection for dynamic monitor topology updates. Thanks [@mikehall-ms](https://github.com/mikehall-ms)!
- #44936: Added new settings dropdown to constrain wrapping to horizontal-only, vertical-only, or both directions. Thanks [@mikehall-ms](https://github.com/mikehall-ms)!
### Peek
- #44995: Fixed Space key triggering Peek during file rename, search, or address bar typing.
### PowerRename
- #44944: Fixed regex `$` not working, preventing users from adding text at the end of filenames.
### Runner
- #44931: Monochrome tray icon now adapts to Windows system theme instead of app theme.
- #44982: Fixed right-click menu to dynamically update based on Quick Access enabled/disabled state.
### GPO / Enterprise
- #45028: Added CursorWrap policy definition to ADMX templates. Thanks [@htcfreek](https://github.com/htcfreek)!
For the full list of v0.97 changes, visit the [Windows Command Line blog](https://aka.ms/powertoys-releaseblog).
## Advanced Paste
@@ -289,7 +309,7 @@ For an in-depth look at the latest changes, visit the [Windows Command Line blog
- Stabilized FancyZones UI tests with more reliable selectors and screen recordings.
## 🛣️ Roadmap
We are planning some nice new features and improvements for the next releases PowerDisplay, Command Palette improvements and a brand-new Shortcut Guide experience! Stay tuned for [v0.97][github-next-release-work]!
We are planning some nice new features and improvements for the next releases PowerDisplay, Command Palette improvements and a brand-new Shortcut Guide experience! Stay tuned for [v0.98][github-next-release-work]!
## ❤️ PowerToys Community
The PowerToys team is extremely grateful to have the [support of an amazing active community][community-link]. The work you do is incredibly important. PowerToys wouldn't be nearly what it is today without your help filing bugs, updating documentation, guiding the design, or writing features. We want to say thank you and take time to recognize your work. Your contributions and feedback improve PowerToys month after month!

View File

@@ -88,7 +88,7 @@
### Building PowerToys Locally
#### One stop script for building installer
1. Open developer powershell for vs 2022
1. Open `Developer Powershell for VS 2022` or `Developer PowerShell for VS` for VS 2026.
2. Run tools\build\build-installer.ps1
> For the first-time setup, please run the installer as an administrator. This ensures that the Wix tool can move wix.target to the desired location and trust the certificate used to sign the MSIX packages.
@@ -109,7 +109,7 @@ dotnet tool install --global wix --version 5.0.2
##### From the command line
1. From the start menu, open a `Developer Command Prompt for VS 2022`
1. From the start menu, open a `Developer Command Prompt for VS 2022` or `Developer Command Prompt for VS`
1. Ensure `nuget.exe` is in your `%path%`
1. In the repo root, run these commands:
@@ -140,7 +140,7 @@ If you prefer, you can alternatively build prerequisite projects for the install
The resulting installer will be available in the `installer\PowerToysSetupVNext\x64\Release\` folder.
To build the installer from the command line, run `Developer Command Prompt for VS 2022` in admin mode and execute the following commands. The generated installer package will be located at `\installer\PowerToysSetupVNext\{platform}\Release\MachineSetup`.
To build the installer from the command line, run `Developer Command Prompt for VS 2022` or `Developer Command Prompt for VS` in admin mode and execute the following commands. The generated installer package will be located at `\installer\PowerToysSetupVNext\{platform}\Release\MachineSetup`.
```
git clean -xfd -e *exe -- .\installer\

View File

@@ -15,7 +15,7 @@ Before you can start debugging PowerToys, you need to set up your development en
You can build the entire solution from the command line, which is sometimes faster than building within Visual Studio:
1. Open Developer Command Prompt for VS 2022
1. Open `Developer Command Prompt for VS 2022` or `Developer Command Prompt for VS`
2. Navigate to the repository root directory
3. Run the following command(don't forget to set the correct platform):
```pwsh
@@ -105,7 +105,7 @@ If you encounter build errors about missing image files (e.g., `.png`, `.ico`, o
1. **Clean the solution in Visual Studio**: Build > Clean Solution
Or from the command line (Developer Command Prompt for VS 2022):
Or from the command line (Developer Command Prompt for VS 2022 or Developer Command Prompt for VS):
```pwsh
msbuild PowerToys.slnx /t:Clean /p:Platform=x64 /p:Configuration=Debug
```

View File

@@ -15,9 +15,11 @@ VS Code extensions Needed:
---
## Building in VS Code
### Configure developer powershell for vs2022 for more convenient dev in vscode.
### Configure Developer Powershell for VS 2022 or Developer Powershell for VS for more convenient dev in vscode.
1. Configure profile in in settings, entry: "terminal.integrated.profiles.windows"
2. Add below config as entry:
2. Add below config as entry (choose VS 2022 or VS 2026 based on your installation):
**For Visual Studio 2022:**
```json
"Developer PowerShell for VS 2022": {
// Configure based on your preference
@@ -27,16 +29,35 @@ VS Code extensions Needed:
"-Command",
"& {",
"$orig = Get-Location;",
// Configure based on your environment
// Adjust path based on your edition (Community/Professional/Enterprise)
"& 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools\\Launch-VsDevShell.ps1';",
"Set-Location $orig",
"}"
]
},
```
3. [Optional] Set Developer PowerShell for VS 2022 as your default profile, so that you can get a deep integration with vscode coding agent.
4. Now You can build with plain `msbuild` or configure tasks.json in below section
**For Visual Studio 2026:**
```json
"Developer PowerShell for VS": {
// Configure based on your preference
"path": "C:\\Program Files\\WindowsApps\\Microsoft.PowerShell_7.5.2.0_arm64__8wekyb3d8bbwe\\pwsh.exe",
"args": [
"-NoExit",
"-Command",
"& {",
"$orig = Get-Location;",
// Adjust path based on your edition (Community/Professional/Enterprise)
"& 'C:\\Program Files\\Microsoft Visual Studio\\18\\Enterprise\\Common7\\Tools\\Launch-VsDevShell.ps1';",
"Set-Location $orig",
"}"
]
},
```
3. [Optional] Set your Developer PowerShell profile as the default, so that you can get a deep integration with vscode coding agent.
4. Now you can build with plain `msbuild` or configure tasks.json in below section.
Or reach out to "tools\build\BUILD-GUIDELINES.md"
### Sample plain msbuild command

View File

@@ -0,0 +1,311 @@
# 🧭 Creating a new PowerToy: end-to-end developer guide
First of all, thank you for wanting to contribute to PowerToys. The work we do would not be possible without the support of community supporters like you.
This guide documents the process of building a new PowerToys utility from scratch, including architecture decisions, integration steps, and common pitfalls.
---
## 1. Overview and prerequisites
A PowerToy module is a self-contained utility integrated into the PowerToys ecosystem. It can be UI-based, service-based, or both.
### Requirements
- [Visual Studio 2026](https://visualstudio.microsoft.com/downloads/) and the following workloads/individual components:
- Desktop Development with C++
- WinUI application development
- .NET desktop development
- Windows 10 SDK (10.0.22621.0)
- Windows 11 SDK (10.0.26100.3916)
- .NET 8 SDK
- Fork the [PowerToys repository](https://github.com/microsoft/PowerToys/tree/main) locally
- [Validate that you are able to build and run](https://github.com/microsoft/PowerToys/blob/main/doc/devdocs/development/debugging.md) `PowerToys.slnx`.
Optional:
- [WiX v5 toolset](https://github.com/microsoft/PowerToys/tree/main) for the installer
> [!NOTE]
> To ensure all the correct VS Workloads are installed, use [the WinGet configuration files](https://github.com/microsoft/PowerToys/tree/e13d6a78aafbcf32a4bb5f8581d041e1d057c3f1/.config) in the project repository. (Use the one that matches your VS distribution. ie: VS Community would use `configuration.winget`)
### Folder structure
```
src/
modules/
your_module/
YourModule.sln
YourModuleInterface/
YourModuleUI/ (if needed)
YourModuleService/ (if needed)
```
---
## 2. Design and planning
### Decide the type of module
Think about how your module works and which existing modules behave similarly. You are going to want to think about the UI needed for the application, the lifecycle, whether it is a service that is always running or event based. Below are some basic scenarios with some modules to explore. You can write your application in C++ or C#.
- **UI-only:** e.g., ColorPicker
- **Background service:** e.g., LightSwitch, Awake
- **Hybrid (UI + background logic):** e.g., ShortcutGuide
- **C++/C# interop:** e.g., PowerRename
### Write your module interface
Begin by setting up the [PowerToy module template project](https://github.com/microsoft/PowerToys/tree/main/tools/project_template). This will generate boilerplate for you to begin your new module. Below are the key headers in the Module Interface (`dllmain.cpp`) and an explanation of their purpose:
1. This is where module settings are defined. These can be anything from strings, bools, ints, and even custom Enums.
```c++
struct ModuleSettings {};
```
2. This is the header for the full class. It inherits the PowerToyModuleIface
```c++
class ModuleInterface : public PowertoyModuleIface
{
private:
// the private members of the class
// Can include the enabled variable, logic for event handlers, or hotkeys.
public:
// the public members of the class
// Will include the constructor and initialization logic.
}
```
> [!NOTE]
> Many of the class functions are boilerplate and need simple string replacements with your module name. The rest of the functions below will require bigger changes.
3. GPO stands for "Group Policy Object" and allows for administrators to configure settings across a network of machines. It is required that your module is on this list of settings. You can right click the `powertoys_gpo` object to go to the definition and set up the `getConfiguredModuleEnabledValue` for your module.
```c++
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
{
return powertoys_gpo::getConfiguredModuleEnabledValue();
}
```
4. `init_settings()` initializes the settings for the interface. Will either pull from existing settings.json or use defaults.
```c++
void ModuleInterface::init_settings()
```
5. `get_config` retrieves the settings from the settings.json file.
```c++
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
```
6. `set_config` sets the new settings to the settings.json file.
```c++
virtual void set_config(const wchar_t* config) override
```
7. `call_custom_action` allows custom actions to be called based on signals from the settings app.
```c++
void call_custom_action(const wchar_t* action) override
```
8. Lifecycle events control whether the module is enabled or not, as well as the default status of the module.
```c++
virtual void enable() // starts the module
virtual void disable() // terminates the module and performs any cleanup
virtual bool is_enabled() // returns if the module is currently enabled
virtual bool is_enabled_by_default() const override // allows the module to dictate whether it should be enabled by default in the PowerToys app.
```
9. Hotkey functions control the status of the hotkey.
```c++
// takes the hotkey from settings into a format that the interface can understand
void parse_hotkey(PowerToysSettings::PowerToyValues& settings)
// returns the hotkeys from settings
virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override
// performs logic when the hotkey event is fired
virtual bool on_hotkey(size_t hotkeyId) override
```
### Notes
- Keep module logic isolated under `/modules/<YourModule>`
- Use shared utilities from [`common`](https://github.com/microsoft/PowerToys/tree/main/src/common) instead of cross-module dependencies
- init/set/get config use preset functions to access the settings. Check out the [`settings_objects.h`](https://github.com/microsoft/PowerToys/blob/main/src/common/SettingsAPI/settings_helpers.h) in `src\common\SettingsAPI`
---
## 3. Bootstrapping your module
1. Use the [template](https://github.com/microsoft/PowerToys/tree/main/tools/project_template) to generate the module interface starter code.
2. Update all projects and namespaces with your module name.
3. Update GUIDs in `.vcxproj` and solution files.
4. Update the functions mentioned in the above section with your custom logic.
5. In order for your module to be detected by the runner you are required to add references to various lists. In order to register your module, add the corresponding module reference to the lists that can be found in the following files. (Hint: search other modules names to find the lists quicker)
- `src/runner/modules.h`
- `src/runner/modules.cpp`
- `src/runner/resource.h`
- `src/runner/settings_window.h`
- `src/runner/settings_window.cpp`
- `src/runner/main.cpp`
- `src/common/logger.h` (for logging)
6. ModuleInterface should build your `ModuleInterface.dll`. This will allow the runner to interact with your service.
> [!TIP]
> Mismatched module IDs are one of the most common causes of load failures. Keep your ID consistent across manifest, registry, and service.
---
## 4. Write your service
This is going to look different for every PowerToy. It may be easier to develop the application independently, and then link in the PowerToys settings logic later. But you have to write the service first, before connecting it to the runner.
### Notes
- This is a separate project from the Module Interface.
- You can develop this project using C# or C++.
- Set the service icon using the `.rc` file.
- Set the service name in the `.vcxproj` by setting the `<TargetName>`
```
<PropertyGroup>
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutDir>
<TargetName>PowerToys.LightSwitchService</TargetName>
</PropertyGroup>
```
- To view the code of the `.vcxproj`, right click the item and select **Unload project**
- Use the following functions to interact with settings from your service
```
ModuleSettings::instance().InitFileWatcher();
ModuleSettings::instance().LoadSettings();
auto& settings = ModuleSettings::instance().settings();
```
These come from the `ModuleSettings.h` file that lives with the Service. You can copy this from another module (e.g., Light Switch) and adjust to fit your needs.
If your module has a user interface:
- Use the **WinUI Blank App** template when setting up your project
- Use [Windows design best practices](https://learn.microsoft.com/windows/apps/design/basics/)
- Use the [WinUI 3 Gallery](https://apps.microsoft.com/detail/9p3jfpwwdzrc) for help with your UI code, and additional guidance.
## 5. Settings integration
PowerToys settings are stored per-module as JSON under:
```
%LOCALAPPDATA%\Microsoft\PowerToys\<module>\settings.json
```
### Implementation steps
- In `src\settings-ui\Settings.UI.Library\` create `<module>Properties.cs` and `<module>Settings.cs`
- `<module>Properties.cs` is where you will define your defaults. Every setting needs to be represented here. This should match what was set in the Module Interface.
- `<module>Settings.cs`is where your settings.json will be built from. The structure should match the following
```cs
public ModuleSettings()
{
Name = ModuleName;
Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
Properties = new ModuleProperties(); // settings properties you set above.
}
```
- In `src\settings-ui\Settings.UI\ViewModels` create `<module>ViewModel.cs` this is where the interaction happens between your settings page in the PowerToys app and the settings file that is stored on the device. Changes here will trigger the settings watcher via a `NotifyPropertyChanged` event.
- Create a `SettingsPage.xaml` at `src\settings-ui\Settings.UI\SettingsXAML\Views`. This will be the page where the user interacts with the settings of your module.
- Be sure to use resource strings for user facing strings so they can be localized. (`x:Uid` connects to Resources.resw)
```xaml
// LightSwitch.xaml
<ComboBoxItem
x:Uid="LightSwitch_ModeOff"
AutomationProperties.AutomationId="OffCBItem_LightSwitch"
Tag="Off" />
// Resources.resw
<data name="LightSwitch_ModeOff.Content" xml:space="preserve">
<value>Off</value>
</data>
```
> [!IMPORTANT]
> In the above example we use `.Content` to target the content of the Combobox. This can change per UI element (e.g., `.Text`, `.Header`, etc.)
> **Reminder:** Manual changes via external editors (VS Code, Notepad) do **not** trigger the settings watcher. Only changes written through PowerToys trigger reloads.
---
### Gotchas:
- Only use the WinUI 3 framework, _not_ UWP.
- Use [`DispatcherQueue`](https://learn.microsoft.com/windows/apps/develop/dispatcherqueue) when updating UI from non-UI threads.
---
## 6. Building and debugging
### Debugging steps
1. If this is your first time debugging PowerToys, be sure to follow [these steps first](https://github.com/microsoft/PowerToys/blob/main/doc/devdocs/development/debugging.md#pre-debugging-setup).
2. Set "runner" as the start up project and ensure your build configuration is set to match your system (ARM64/x64)
3. Select <kbd>F5</kbd> or the **Local Windows Debugger** button to begin debugging. This should start the PowerToys runner.
4. To set breakpoints in your service, select Ctrl+Alt+P and search for your service to attach to the runner.
5. Use logs to document changes. The logs live at `%LOCALAPPDATA%\Microsoft\PowerToys\RunnerLogs` and `%LOCALAPPDATA%\Microsoft\PowerToys\Module\Service\<version>` for the specific module.
> [!TIP]
> PowerToys caches `.nuget` artifacts aggressively. Use `git clean -xfd` when builds behave unexpectedly.
---
## 7. Installer and packaging (WiX)
### Add your module to installer
1. Install [`WixToolset.Heat`](https://www.nuget.org/packages/WixToolset.Heat/) for Wix5 via nuget
2. Inside `installer\PowerToysInstallerVNext` add a new file for your module: `Module.wxs`
3. Inside of this file you will need copy the format from another module (ie: Light Switch) and replace the strings and GUID values.
4. The key part will be `<!--ModuleNameFiles_Component_Def-->` which is a placeholder for code that will be generated by `generateFileComponents.ps1`.
5. Inside `Product.wxs` add a line item in the `<Feature Id="CoreFeature" ... >` section. It will look like a list of ` <ComponentGroupRef Id="ModuleComponentGroup" />` items.
6. Inside `generateFileComponents.ps1` you will need to add an entry to the bottom for your new module. It will follow the following format. `-fileListName <Module>Files` will match the string you set in `Module.wxs`, `<ModuleServiceName>` will match the name of your exe.
```bash
# Module Name
Generate-FileList -fileDepsJson "" -fileListName <Module>Files -wxsFilePath $PSScriptRoot\<Module>.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\<ModuleServiceName>"
Generate-FileComponents -fileListName "<Module>Files" -wxsFilePath $PSScriptRoot\<Module>.wxs -regroot $registryroot
```
---
## 8. Testing and validation
### UI tests
- Place under `/modules/<YourModule>/Tests`
- Create a new [WinUI Unit Test App](https://learn.microsoft.com/windows/apps/winui/winui3/testing/create-winui-unit-test-project)
- Write unit tests following the format from previous modules (ie: Light Switch). This can be to test your standalone UI (if you're a module like Color Picker) or to verify that the Settings UI in the PowerToys app is controlling your service.
### Manual validation
- Enable/disable in PowerToys Settings
- Check initialization in logs
- Confirm icons, tooltips, and OOBE page appear correctly
### Pro tips
1. Validate wake/sleep and elevation states. Background modules often fail silently after resume if event handles arent recreated.
2. Use Windows Sandbox to simulate clean install environments
3. To simulate a "new user" you can delete the PowerToys folder from `%LOCALAPPDATA%\Microsoft`
### Shortcut conflict detection
If your module has a shortcut, ensure that it is properly registered following [the steps listed in the documentation](https://github.com/microsoft/PowerToys/blob/main/doc/devdocs/core/settings/settings-implementation.md#shortcut-conflict-detection) for conflict detection.
---
## 9. The final touches
### Out-of-Box experience (OOBE) page
The OOBE page is a custom settings page that gives the user at a glance information about each module. This window opens before the Settings application for new users and after updates. Create `OOBE<ModuleName>.xaml` at `src\settings-ui\Settings.UI\SettingsXAML\OOBE\Views`. You will also need to add your module name to the enum at `src\settings-ui\Settings.UI\OOBE\Enums\PowerToysModules.cs`.
### Module assets
Now that your PowerToy is _done_ you can start to think about the assets that will represent your module.
- Module Icon: This will be displayed in a number of places: OOBE page, in the README, on the home screen of PowerToys, on your individual module settings page, etc.
- Module Image: This is the image you see at the top of each individual settings page.
- OOBE Image: This is the header you see on the OOBE page for each module
> [!NOTE]
> This step is something that the Design team will handle internally to ensure consistency throughout the application. If you have ideas or recommendations on what the icon or screenshots should be for your module feel free to leave it in the "Additional Comments" section of the PR and the team will take it into consideration.
### Documentation
There are two types of documentation that will be required when submitting a new PowerToy:
1. Developer documentation: This will live in the [PowerToys repo](https://github.com/microsoft/PowerToys/blob/main/doc/devdocs/modules) at `/doc/devdocs/modules/` and should tell a developer how to work on your app. It should outline the module architecture, key files, testing, and tips on debugging if necessary.
2. Microsoft Learn documentation: When your new Module is ready to be merged into the PowerToys repository, an internal team member will create Microsoft Learn documentation so that users will understand how to use your module. There is not much work on your end as the developer for this step, but keep an eye on your PR in case we need more information about your PowerToy for this step.
---
Thank you again for contributing! If you need help, feel free to [open an issue](https://github.com/microsoft/PowerToys/issues/new/choose) and use the `Needs-Team-Response` label so we know you need attention.

View File

@@ -18,13 +18,28 @@ Advanced Paste is a PowerToys module that provides enhanced clipboard pasting wi
TODO: Add implementation details
### Paste with AI Preview
The "Show preview" setting (`ShowCustomPreview`) controls whether AI-generated results are displayed in a preview window before pasting. **The preview feature does not consume additional AI credits**—the preview displays the same AI response that was already generated, cached locally from a single API call.
The implementation flow:
1. User initiates "Paste with AI" action
2. A single AI API call is made via `ExecutePasteFormatAsync`
3. The result is cached in `GeneratedResponses`
4. If preview is enabled, the cached result is displayed in the preview UI
5. User can paste the cached result without any additional API calls
See the `ExecutePasteFormatAsync(PasteFormat, PasteActionSource)` method in `OptionsViewModel.cs` for the implementation.
## Debugging
TODO: Add debugging information
## Settings
TODO: Add settings documentation
| Setting | Description |
|---------|-------------|
| `ShowCustomPreview` | When enabled, shows AI-generated results in a preview window before pasting. Does not affect AI credit consumption. |
## Future Improvements

View File

@@ -152,7 +152,7 @@ FancyZones is divided into several projects:
## Development Environment Setup
### Prerequisites
- Visual Studio 2022: Required for building and debugging
- Visual Studio 2022 or 2026: Required for building and debugging
- Windows 10 SDK: Ensure the latest version is installed
- PowerToys Repository: Clone from GitHub
@@ -183,7 +183,7 @@ FancyZones is divided into several projects:
## Debugging
### Setup for Debugging
1. In Visual Studio 2022, set FancyZonesEditor as the startup project
1. In Visual Studio 2022 or 2026, set FancyZonesEditor as the startup project
2. Set breakpoints in the code where needed
3. Click Run to start debugging

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,223 @@
# MCCS Capabilities String Parser - Recursive Descent Design
## Overview
This document describes the recursive descent parser implementation for DDC/CI MCCS (Monitor Control Command Set) capabilities strings.
### Attention!
This document and the code implement are generated by Copilot.
## Grammar Definition (BNF)
```bnf
capabilities ::= ['('] segment* [')']
segment ::= identifier '(' segment_content ')'
segment_content ::= text | vcp_entries | hex_list
vcp_entries ::= vcp_entry*
vcp_entry ::= hex_byte [ '(' hex_list ')' ]
hex_list ::= hex_byte*
hex_byte ::= [0-9A-Fa-f]{2}
identifier ::= [a-z_A-Z]+
text ::= [^()]+
```
## Example Input
```
(prot(monitor)type(lcd)model(PD3220U)cmds(01 02 03 07)vcp(10 12 14(04 05 06) 16 60(11 12 0F) DC DF)mccs_ver(2.2)vcpname(F0(Custom Setting)))
```
## Parser Architecture
### Component Hierarchy
```
MccsCapabilitiesParser (main parser)
├── ParseCapabilities() → MccsParseResult
├── ParseSegment() → ParsedSegment?
├── ParseBalancedContent() → string
├── ParseIdentifier() → ReadOnlySpan<char>
├── ApplySegment() → void
│ ├── ParseHexList() → List<byte>
│ ├── ParseVcpEntries() → Dictionary<byte, VcpCodeInfo>
│ └── ParseVcpNames() → void
├── VcpEntryParser (sub-parser for vcp() content)
│ └── TryParseEntry() → VcpEntry
├── VcpNameParser (sub-parser for vcpname() content)
│ └── TryParseEntry() → (byte code, string name)
└── WindowParser (sub-parser for windowN() content)
├── Parse() → WindowCapability
└── ParseSubSegment() → (name, content)?
```
### Design Principles
1. **ref struct for Zero Allocation**
- Main parser uses `ref struct` to avoid heap allocation
- Works with `ReadOnlySpan<char>` for efficient string slicing
- No intermediate string allocations during parsing
2. **Recursive Descent Pattern**
- Each grammar rule has a corresponding parse method
- Methods call each other recursively for nested structures
- Single-character lookahead via `Peek()`
3. **Error Recovery**
- Errors are accumulated, not thrown
- Parser attempts to continue after errors
- Returns partial results when possible
4. **Sub-parsers for Specialized Content**
- `VcpEntryParser` for VCP code entries
- `VcpNameParser` for custom VCP names
- Each sub-parser handles its own grammar subset
## Parse Methods Detail
### ParseCapabilities()
Entry point. Handles optional outer parentheses and iterates through segments.
```csharp
private MccsParseResult ParseCapabilities()
{
// Handle optional outer parens
// while (!IsAtEnd()) { ParseSegment() }
// Return result with accumulated errors
}
```
### ParseSegment()
Parses a single `identifier(content)` segment.
```csharp
private ParsedSegment? ParseSegment()
{
// 1. ParseIdentifier()
// 2. Expect '('
// 3. ParseBalancedContent()
// 4. Expect ')'
}
```
### ParseBalancedContent()
Extracts content between balanced parentheses, handling nested parens.
```csharp
private string ParseBalancedContent()
{
int depth = 1;
while (depth > 0) {
if (char == '(') depth++;
if (char == ')') depth--;
}
}
```
### ParseVcpEntries()
Delegates to `VcpEntryParser` for the specialized VCP entry grammar.
```csharp
vcp_entry ::= hex_byte [ '(' hex_list ')' ]
Examples:
- "10" code=0x10, values=[]
- "14(04 05 06)" code=0x14, values=[4, 5, 6]
- "60(11 12 0F)" code=0x60, values=[0x11, 0x12, 0x0F]
```
## Comparison with Other Approaches
| Approach | Pros | Cons |
|----------|------|------|
| **Recursive Descent** (this) | Clear structure, handles nesting, extensible | More code |
| **Regex** (DDCSharp) | Concise | Hard to debug, limited nesting |
| **Mixed** (original) | Pragmatic | Inconsistent, hard to maintain |
## Performance Characteristics
- **Time Complexity**: O(n) where n = input length
- **Space Complexity**: O(1) for parsing + O(m) for output where m = number of VCP codes
- **Allocations**: Minimal - only for output structures
## Supported Segments
| Segment | Description | Parser |
|---------|-------------|--------|
| `prot(...)` | Protocol type | Direct assignment |
| `type(...)` | Display type (lcd/crt) | Direct assignment |
| `model(...)` | Model name | Direct assignment |
| `cmds(...)` | Supported commands | ParseHexList |
| `vcp(...)` | VCP code entries | VcpEntryParser |
| `mccs_ver(...)` | MCCS version | Direct assignment |
| `vcpname(...)` | Custom VCP names | VcpNameParser |
| `windowN(...)` | PIP/PBP window capabilities | WindowParser |
### Window Segment Format
The `windowN` segment (where N is 1, 2, 3, etc.) describes PIP/PBP window capabilities:
```
window1(type(PIP) area(25 25 1895 1175) max(640 480) min(10 10) window(10))
```
| Sub-field | Format | Description |
|-----------|--------|-------------|
| `type` | `type(PIP)` or `type(PBP)` | Window type (Picture-in-Picture or Picture-by-Picture) |
| `area` | `area(x1 y1 x2 y2)` | Window area coordinates in pixels |
| `max` | `max(width height)` | Maximum window dimensions |
| `min` | `min(width height)` | Minimum window dimensions |
| `window` | `window(id)` | Window identifier |
All sub-fields are optional; missing fields default to zero values.
## Error Handling
```csharp
public readonly struct ParseError
{
public int Position { get; } // Character position
public string Message { get; } // Human-readable error
}
public sealed class MccsParseResult
{
public VcpCapabilities Capabilities { get; }
public IReadOnlyList<ParseError> Errors { get; }
public bool HasErrors => Errors.Count > 0;
public bool IsValid => !HasErrors && Capabilities.SupportedVcpCodes.Count > 0;
}
```
## Usage Example
```csharp
// Parse capabilities string
var result = MccsCapabilitiesParser.Parse(capabilitiesString);
if (result.IsValid)
{
var caps = result.Capabilities;
Console.WriteLine($"Model: {caps.Model}");
Console.WriteLine($"MCCS Version: {caps.MccsVersion}");
Console.WriteLine($"VCP Codes: {caps.SupportedVcpCodes.Count}");
}
if (result.HasErrors)
{
foreach (var error in result.Errors)
{
Console.WriteLine($"Parse error at {error.Position}: {error.Message}");
}
}
```
## Edge Cases Handled
1. **Missing outer parentheses** (Apple Cinema Display)
2. **No spaces between hex bytes** (`010203` vs `01 02 03`)
3. **Nested parentheses** in VCP values
4. **Unknown segments** (logged but not fatal)
5. **Malformed input** (partial results returned)

View File

@@ -79,7 +79,7 @@ Once you've discussed your proposed feature/fix/etc. with a team member, and an
### Prerequisites for Compiling PowerToys
1. Windows 10 April 2018 Update (version 1803) or newer
1. Visual Studio Community/Professional/Enterprise 2022 17.4 or newer
1. Visual Studio Community/Professional/Enterprise 2022 17.4 or newer, or Visual Studio 2026
1. A local clone of the PowerToys repository
1. Enable long paths in Windows (see [Enable Long Paths](https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation#enabling-long-paths-in-windows-10-version-1607-and-later) for details)

View File

@@ -1549,7 +1549,7 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
}
processes.resize(bytes / sizeof(processes[0]));
std::array<std::wstring_view, 44> processesToTerminate = {
std::array<std::wstring_view, 45> processesToTerminate = {
L"PowerToys.PowerLauncher.exe",
L"PowerToys.Settings.exe",
L"PowerToys.AdvancedPaste.exe",
@@ -1565,6 +1565,7 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
L"PowerToys.PowerRename.exe",
L"PowerToys.ImageResizer.exe",
L"PowerToys.LightSwitchService.exe",
L"PowerToys.PowerDisplay.exe",
L"PowerToys.GcodeThumbnailProvider.exe",
L"PowerToys.BgcodeThumbnailProvider.exe",
L"PowerToys.PdfThumbnailProvider.exe",

View File

@@ -14,13 +14,13 @@
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="..\..\deps\spdlog.props" />

View File

@@ -18,6 +18,7 @@
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="Module_CmdPal" Value="" KeyPath="yes" />
</RegistryKey>
<RemoveFile Id="RemoveOldCmdPalMsix" Name="Microsoft.CmdPal.UI_*.msix" On="install" />
<?if $(sys.BUILDARCH) = x64 ?>
<File Id="Microsoft.CmdPal.UI___var.CmdPalVersion_._x64.msix" Source="$(var.CmdPalBuildDir)AppPackages\Microsoft.CmdPal.UI_$(var.CmdPalVersion)_Test\Microsoft.CmdPal.UI_$(var.CmdPalVersion)_x64.msix" />
<?else?>

View File

@@ -1,5 +1,5 @@
<Project>
<Import Project="..\..\src\Version.props" Condition="Exists('..\..\src\Version.props')" />
<Import Project="..\..\Directory.Build.props" />
<PropertyGroup>
<!-- Set BaseIntermediateOutputPath for each project to avoid conflicts -->
<BaseIntermediateOutputPath Condition="'$(MSBuildProjectName)' == 'PowerToysInstallerVNext'">obj\Installer\</BaseIntermediateOutputPath>

View File

@@ -0,0 +1,29 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util" >
<?include $(sys.CURRENTDIR)\Common.wxi?>
<?define PowerDisplayAssetsFiles=?>
<?define PowerDisplayAssetsFilesPath=$(var.BinDir)WinUI3Apps\Assets\PowerDisplay?>
<Fragment>
<!-- Power Display -->
<DirectoryRef Id="WinUI3AppsAssetsFolder">
<Directory Id="PowerDisplayAssetsInstallFolder" Name="PowerDisplay" />
</DirectoryRef>
<DirectoryRef Id="PowerDisplayAssetsInstallFolder" FileSource="$(var.PowerDisplayAssetsFilesPath)">
<!-- Generated by generateFileComponents.ps1 -->
<!--PowerDisplayAssetsFiles_Component_Def-->
</DirectoryRef>
<ComponentGroup Id="PowerDisplayComponentGroup">
<Component Id="RemovePowerDisplayFolder" Guid="B8F2E3A5-72C1-4A2D-9B3F-8E5D7C6A4F9B" Directory="PowerDisplayAssetsInstallFolder" >
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="RemovePowerDisplayFolder" Value="" KeyPath="yes"/>
</RegistryKey>
<RemoveFolder Id="RemoveFolderPowerDisplayAssetsFolder" Directory="PowerDisplayAssetsInstallFolder" On="uninstall"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>

View File

@@ -47,6 +47,7 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil
call move /Y ..\..\..\NewPlus.wxs.bk ..\..\..\NewPlus.wxs
call move /Y ..\..\..\Peek.wxs.bk ..\..\..\Peek.wxs
call move /Y ..\..\..\PowerRename.wxs.bk ..\..\..\PowerRename.wxs
call move /Y ..\..\..\PowerDisplay.wxs.bk ..\..\..\PowerDisplay.wxs
call move /Y ..\..\..\Product.wxs.bk ..\..\..\Product.wxs
call move /Y ..\..\..\RegistryPreview.wxs.bk ..\..\..\RegistryPreview.wxs
call move /Y ..\..\..\Resources.wxs.bk ..\..\..\Resources.wxs
@@ -123,6 +124,7 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil
<Compile Include="KeyboardManager.wxs" />
<Compile Include="Peek.wxs" />
<Compile Include="PowerRename.wxs" />
<Compile Include="PowerDisplay.wxs" />
<Compile Include="DscResources.wxs" />
<Compile Include="RegistryPreview.wxs" />
<Compile Include="Run.wxs" />

View File

@@ -53,6 +53,7 @@
<ComponentGroupRef Id="LightSwitchComponentGroup" />
<ComponentGroupRef Id="PeekComponentGroup" />
<ComponentGroupRef Id="PowerRenameComponentGroup" />
<ComponentGroupRef Id="PowerDisplayComponentGroup" />
<ComponentGroupRef Id="RegistryPreviewComponentGroup" />
<ComponentGroupRef Id="RunComponentGroup" />
<ComponentGroupRef Id="SettingsComponentGroup" />

View File

@@ -367,6 +367,12 @@
</RegistryKey>
<File Id="BgcodePreviewHandler_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)\$(var.Language)\PowerToys.BgcodePreviewHandler.resources.dll" />
</Component>
<Component Id="CmdPalExtPowerToys_$(var.IdSafeLanguage)_Component" Directory="Resource$(var.IdSafeLanguage)INSTALLFOLDER" Guid="$(var.CompGUIDPrefix)23">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="CmdPalExtPowerToys_$(var.IdSafeLanguage)_Component" Value="" KeyPath="yes" />
</RegistryKey>
<File Id="CmdPalExtPowerToys_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)\$(var.Language)\Microsoft.CmdPal.Ext.PowerToys.resources.dll" />
</Component>
<?undef IdSafeLanguage?>
<?undef CompGUIDPrefix?>
<?endforeach?>

View File

@@ -37,14 +37,14 @@
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -68,11 +68,10 @@
<ClCompile Include="SilentFilesInUseBAFunctions.cpp" />
<ClCompile Include="bafunctions.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>precomp.h</PrecompiledHeaderFile>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="precomp.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,6 +1,6 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
#include "precomp.h"
#include "pch.h"
#include "BalBaseBAFunctions.h"
#include "BalBaseBAFunctionsProc.h"
@@ -18,7 +18,6 @@ public: // IBootstrapperApplication
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "*** CUSTOM BA FUNCTION SYSTEM ACTIVE *** Running detect begin BA function. fCached=%d, registrationType=%d, cPackages=%u, fCancel=%d", fCached, registrationType, cPackages, *pfCancel);
LExit:
return hr;
}
@@ -37,7 +36,6 @@ public: // IBAFunctions
// BalExitOnFailure(hr, "Change this message to represent real error handling.");
//-------------------------------------------------------------------------------------------------
LExit:
return hr;
}
@@ -58,7 +56,7 @@ public: // IBAFunctions
__in DWORD cFiles,
__in_ecount_z(cFiles) LPCWSTR* rgwzFiles,
__in int nRecommendation,
__in BOOTSTRAPPER_FILES_IN_USE_TYPE source,
__in BOOTSTRAPPER_FILES_IN_USE_TYPE /* source */,
__inout int* pResult
)
{

View File

@@ -1,6 +1,6 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
#include "precomp.h"
#include "pch.h"
static HINSTANCE vhInstance = NULL;

View File

@@ -176,6 +176,10 @@ Generate-FileComponents -fileListName "ImageResizerAssetsFiles" -wxsFilePath $PS
Generate-FileList -fileDepsJson "" -fileListName LightSwitchFiles -wxsFilePath $PSScriptRoot\LightSwitch.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\LightSwitchService"
Generate-FileComponents -fileListName "LightSwitchFiles" -wxsFilePath $PSScriptRoot\LightSwitch.wxs
#PowerDisplay
Generate-FileList -fileDepsJson "" -fileListName PowerDisplayAssetsFiles -wxsFilePath $PSScriptRoot\PowerDisplay.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\WinUI3Apps\Assets\PowerDisplay"
Generate-FileComponents -fileListName "PowerDisplayAssetsFiles" -wxsFilePath $PSScriptRoot\PowerDisplay.wxs
#New+
Generate-FileList -fileDepsJson "" -fileListName NewPlusAssetsFiles -wxsFilePath $PSScriptRoot\NewPlus.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\WinUI3Apps\Assets\NewPlus"
Generate-FileComponents -fileListName "NewPlusAssetsFiles" -wxsFilePath $PSScriptRoot\NewPlus.wxs

View File

@@ -12,7 +12,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="..\..\deps\expected.props" />
<PropertyGroup>

View File

@@ -5,6 +5,6 @@
As a temporary workaround, create a .NET 8 project and use file links
to include the code that needs testing. -->
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.26100.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@@ -55,26 +55,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>

View File

@@ -12,7 +12,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="..\..\deps\expected.props" />
<PropertyGroup>

View File

@@ -10,7 +10,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View File

@@ -40,7 +40,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>

View File

@@ -3,9 +3,27 @@
#include <iomanip>
#include <iostream>
#include <sstream>
#include <cmath>
#include <limits>
namespace ExprtkCalculator::internal
{
static double factorial(const double n)
{
// Only allow non-negative integers
if (n < 0.0 || std::floor(n) != n)
{
return std::numeric_limits<double>::quiet_NaN();
}
return std::tgamma(n + 1.0);
}
static double sign(const double n)
{
if (n > 0.0) return 1.0;
if (n < 0.0) return -1.0;
return 0.0;
}
std::wstring ToWStringFullPrecision(double value)
{
@@ -25,6 +43,9 @@ namespace ExprtkCalculator::internal
symbol_table.add_constant(name, value);
}
symbol_table.add_function("factorial", factorial);
symbol_table.add_function("sign", sign);
exprtk::expression<double> expression;
expression.register_symbol_table(symbol_table);

View File

@@ -45,6 +45,7 @@ namespace Common.UI
NewPlus,
CmdPal,
ZoomIt,
PowerDisplay,
}
private static string SettingsWindowNameToString(SettingsWindow value)
@@ -115,6 +116,8 @@ namespace Common.UI
return "CmdPal";
case SettingsWindow.ZoomIt:
return "ZoomIt";
case SettingsWindow.PowerDisplay:
return "PowerDisplay";
default:
{
return string.Empty;

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{CABA8DFB-823B-4BF2-93AC-3F31984150D9}</ProjectGuid>
@@ -10,7 +11,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -39,5 +40,18 @@
<ClCompile Include="monitors.cpp" />
<ClCompile Include="dpi_aware.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240111.5" targetFramework="native" />
</packages>

View File

@@ -32,6 +32,10 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredLightSwitchEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredPowerDisplayEnabledValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredPowerDisplayEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredFancyZonesEnabledValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredFancyZonesEnabledValue());

View File

@@ -14,6 +14,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
static GpoRuleConfigured GetConfiguredColorPickerEnabledValue();
static GpoRuleConfigured GetConfiguredCropAndLockEnabledValue();
static GpoRuleConfigured GetConfiguredLightSwitchEnabledValue();
static GpoRuleConfigured GetConfiguredPowerDisplayEnabledValue();
static GpoRuleConfigured GetConfiguredFancyZonesEnabledValue();
static GpoRuleConfigured GetConfiguredFileLocksmithEnabledValue();
static GpoRuleConfigured GetConfiguredSvgPreviewEnabledValue();

View File

@@ -18,6 +18,7 @@ namespace PowerToys
static GpoRuleConfigured GetConfiguredColorPickerEnabledValue();
static GpoRuleConfigured GetConfiguredCropAndLockEnabledValue();
static GpoRuleConfigured GetConfiguredLightSwitchEnabledValue();
static GpoRuleConfigured GetConfiguredPowerDisplayEnabledValue();
static GpoRuleConfigured GetConfiguredFancyZonesEnabledValue();
static GpoRuleConfigured GetConfiguredFileLocksmithEnabledValue();
static GpoRuleConfigured GetConfiguredSvgPreviewEnabledValue();

View File

@@ -19,7 +19,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<GenerateManifest>false</GenerateManifest>
<DesktopCompatible>true</DesktopCompatible>

View File

@@ -30,6 +30,7 @@ namespace ManagedCommon
PowerRename,
PowerLauncher,
PowerAccent,
PowerDisplay,
RegistryPreview,
MeasureTool,
ShortcutGuide,

View File

@@ -12,7 +12,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View File

@@ -11,7 +11,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View File

@@ -11,7 +11,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View File

@@ -16,13 +16,50 @@ DWORD WINAPI _checkTheme(LPVOID lpParam)
void ThemeListener::AddChangedHandler(THEME_HANDLE handle)
{
std::lock_guard<std::mutex> lock(handlesMutex);
handles.push_back(handle);
}
void ThemeListener::DelChangedHandler(THEME_HANDLE handle)
{
std::lock_guard<std::mutex> lock(handlesMutex);
auto it = std::find(handles.begin(), handles.end(), handle);
handles.erase(it);
if (it != handles.end())
{
handles.erase(it);
}
}
void ThemeListener::AddAppThemeChangedHandler(THEME_HANDLE handle)
{
std::lock_guard<std::mutex> lock(handlesMutex);
appThemeHandles.push_back(handle);
}
void ThemeListener::DelAppThemeChangedHandler(THEME_HANDLE handle)
{
std::lock_guard<std::mutex> lock(handlesMutex);
auto it = std::find(appThemeHandles.begin(), appThemeHandles.end(), handle);
if (it != appThemeHandles.end())
{
appThemeHandles.erase(it);
}
}
void ThemeListener::AddSystemThemeChangedHandler(THEME_HANDLE handle)
{
std::lock_guard<std::mutex> lock(handlesMutex);
systemThemeHandles.push_back(handle);
}
void ThemeListener::DelSystemThemeChangedHandler(THEME_HANDLE handle)
{
std::lock_guard<std::mutex> lock(handlesMutex);
auto it = std::find(systemThemeHandles.begin(), systemThemeHandles.end(), handle);
if (it != systemThemeHandles.end())
{
systemThemeHandles.erase(it);
}
}
void ThemeListener::CheckTheme()
@@ -48,13 +85,51 @@ void ThemeListener::CheckTheme()
WaitForSingleObject(hEvent, INFINITE);
auto _theme = ThemeHelpers::GetAppTheme();
if (AppTheme != _theme)
auto _appTheme = ThemeHelpers::GetAppTheme();
auto _systemTheme = ThemeHelpers::GetSystemTheme();
bool appThemeChanged = (AppTheme != _appTheme);
bool systemThemeChanged = (SystemTheme != _systemTheme);
if (appThemeChanged || systemThemeChanged)
{
AppTheme = _theme;
for (int i = 0; i < handles.size(); i++)
AppTheme = _appTheme;
SystemTheme = _systemTheme;
// Copy handlers under lock, then invoke outside lock to avoid deadlock
std::vector<THEME_HANDLE> handlesCopy;
std::vector<THEME_HANDLE> appThemeHandlesCopy;
std::vector<THEME_HANDLE> systemThemeHandlesCopy;
{
handles[i]();
std::lock_guard<std::mutex> lock(handlesMutex);
handlesCopy = handles;
if (appThemeChanged)
{
appThemeHandlesCopy = appThemeHandles;
}
if (systemThemeChanged)
{
systemThemeHandlesCopy = systemThemeHandles;
}
}
// Call generic handlers (backward compatible)
for (const auto& handler : handlesCopy)
{
handler();
}
// Call app theme specific handlers
for (const auto& handler : appThemeHandlesCopy)
{
handler();
}
// Call system theme specific handlers
for (const auto& handler : systemThemeHandlesCopy)
{
handler();
}
}
}

View File

@@ -3,6 +3,7 @@
#include <windows.h>
#include <iostream>
#include <vector>
#include <mutex>
typedef void (*THEME_HANDLE)();
DWORD WINAPI _checkTheme(LPVOID lpParam);
@@ -14,6 +15,7 @@ public:
ThemeListener()
{
AppTheme = ThemeHelpers::GetAppTheme();
SystemTheme = ThemeHelpers::GetSystemTheme();
dwThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)_checkTheme, this, 0, &dwThreadId);
}
~ThemeListener()
@@ -23,12 +25,20 @@ public:
}
Theme AppTheme;
Theme SystemTheme;
void ThemeListener::AddChangedHandler(THEME_HANDLE handle);
void ThemeListener::DelChangedHandler(THEME_HANDLE handle);
void ThemeListener::AddAppThemeChangedHandler(THEME_HANDLE handle);
void ThemeListener::DelAppThemeChangedHandler(THEME_HANDLE handle);
void ThemeListener::AddSystemThemeChangedHandler(THEME_HANDLE handle);
void ThemeListener::DelSystemThemeChangedHandler(THEME_HANDLE handle);
void CheckTheme();
private:
HANDLE dwThreadHandle;
DWORD dwThreadId;
std::vector<THEME_HANDLE> handles;
std::vector<THEME_HANDLE> appThemeHandles;
std::vector<THEME_HANDLE> systemThemeHandles;
mutable std::mutex handlesMutex;
};

View File

@@ -13,7 +13,7 @@
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v143</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\tests\UnitTestsCommonLib\</OutDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

View File

@@ -0,0 +1,120 @@
#include "pch.h"
#include "TestHelpers.h"
#include <appMutex.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(AppMutexTests)
{
public:
TEST_METHOD(CreateAppMutex_ValidName_ReturnsHandle)
{
std::wstring mutexName = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) + L"_1";
auto handle = createAppMutex(mutexName);
Assert::IsNotNull(handle.get());
}
TEST_METHOD(CreateAppMutex_SameName_ReturnsExistingHandle)
{
std::wstring mutexName = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) + L"_2";
auto handle1 = createAppMutex(mutexName);
Assert::IsNotNull(handle1.get());
auto handle2 = createAppMutex(mutexName);
Assert::IsNull(handle2.get());
}
TEST_METHOD(CreateAppMutex_DifferentNames_ReturnsDifferentHandles)
{
std::wstring mutexName1 = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) + L"_A";
std::wstring mutexName2 = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) + L"_B";
auto handle1 = createAppMutex(mutexName1);
auto handle2 = createAppMutex(mutexName2);
Assert::IsNotNull(handle1.get());
Assert::IsNotNull(handle2.get());
Assert::AreNotEqual(handle1.get(), handle2.get());
}
TEST_METHOD(CreateAppMutex_EmptyName_ReturnsHandle)
{
// Empty name creates unnamed mutex
auto handle = createAppMutex(L"");
// CreateMutexW with empty string should still work
Assert::IsTrue(true);
// Test passes regardless - just checking it doesn't crash
Assert::IsTrue(true);
}
TEST_METHOD(CreateAppMutex_LongName_ReturnsHandle)
{
// Create a long mutex name
std::wstring mutexName = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) + L"_";
for (int i = 0; i < 50; ++i)
{
mutexName += L"LongNameSegment";
}
auto handle = createAppMutex(mutexName);
// Long names might fail, but shouldn't crash
Assert::IsTrue(true);
}
TEST_METHOD(CreateAppMutex_SpecialCharacters_ReturnsHandle)
{
std::wstring mutexName = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) + L"_Special!@#$%";
auto handle = createAppMutex(mutexName);
// Some special characters might not be valid in mutex names
Assert::IsTrue(true);
}
TEST_METHOD(CreateAppMutex_GlobalPrefix_ReturnsHandle)
{
// Global prefix for cross-session mutex
std::wstring mutexName = L"Global\\TestMutex_" + std::to_wstring(GetCurrentProcessId());
auto handle = createAppMutex(mutexName);
// Might require elevation, but shouldn't crash
Assert::IsTrue(true);
}
TEST_METHOD(CreateAppMutex_LocalPrefix_ReturnsHandle)
{
std::wstring mutexName = L"Local\\TestMutex_" + std::to_wstring(GetCurrentProcessId());
auto handle = createAppMutex(mutexName);
Assert::IsNotNull(handle.get());
}
TEST_METHOD(CreateAppMutex_MultipleCalls_AllSucceed)
{
std::vector<wil::unique_mutex_nothrow> handles;
for (int i = 0; i < 10; ++i)
{
std::wstring mutexName = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) +
L"_Multi_" + std::to_wstring(i);
auto handle = createAppMutex(mutexName);
Assert::IsNotNull(handle.get());
handles.push_back(std::move(handle));
}
}
TEST_METHOD(CreateAppMutex_ReleaseAndRecreate_Works)
{
std::wstring mutexName = L"TestMutex_" + std::to_wstring(GetCurrentProcessId()) + L"_Recreate";
auto handle1 = createAppMutex(mutexName);
Assert::IsNotNull(handle1.get());
handle1.reset();
// After closing, should be able to create again
auto handle2 = createAppMutex(mutexName);
Assert::IsNotNull(handle2.get());
}
};
}

View File

@@ -0,0 +1,220 @@
#include "pch.h"
#include "TestHelpers.h"
#include <color.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ColorUtilsTests)
{
public:
// checkValidRGB tests
TEST_METHOD(CheckValidRGB_ValidBlack_ReturnsTrue)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#000000", &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(0), r);
Assert::AreEqual(static_cast<uint8_t>(0), g);
Assert::AreEqual(static_cast<uint8_t>(0), b);
}
TEST_METHOD(CheckValidRGB_ValidWhite_ReturnsTrue)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#FFFFFF", &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(255), r);
Assert::AreEqual(static_cast<uint8_t>(255), g);
Assert::AreEqual(static_cast<uint8_t>(255), b);
}
TEST_METHOD(CheckValidRGB_ValidRed_ReturnsTrue)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#FF0000", &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(255), r);
Assert::AreEqual(static_cast<uint8_t>(0), g);
Assert::AreEqual(static_cast<uint8_t>(0), b);
}
TEST_METHOD(CheckValidRGB_ValidGreen_ReturnsTrue)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#00FF00", &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(0), r);
Assert::AreEqual(static_cast<uint8_t>(255), g);
Assert::AreEqual(static_cast<uint8_t>(0), b);
}
TEST_METHOD(CheckValidRGB_ValidBlue_ReturnsTrue)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#0000FF", &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(0), r);
Assert::AreEqual(static_cast<uint8_t>(0), g);
Assert::AreEqual(static_cast<uint8_t>(255), b);
}
TEST_METHOD(CheckValidRGB_ValidMixed_ReturnsTrue)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#AB12CD", &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(0xAB), r);
Assert::AreEqual(static_cast<uint8_t>(0x12), g);
Assert::AreEqual(static_cast<uint8_t>(0xCD), b);
}
TEST_METHOD(CheckValidRGB_MissingHash_ReturnsFalse)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"FFFFFF", &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidRGB_TooShort_ReturnsFalse)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#FFF", &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidRGB_TooLong_ReturnsFalse)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#FFFFFFFF", &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidRGB_InvalidChars_ReturnsFalse)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#GGHHII", &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidRGB_LowercaseInvalid_ReturnsFalse)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#ffffff", &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidRGB_EmptyString_ReturnsFalse)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"", &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidRGB_OnlyHash_ReturnsFalse)
{
uint8_t r, g, b;
bool result = checkValidRGB(L"#", &r, &g, &b);
Assert::IsFalse(result);
}
// checkValidARGB tests
TEST_METHOD(CheckValidARGB_ValidBlackOpaque_ReturnsTrue)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#FF000000", &a, &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(255), a);
Assert::AreEqual(static_cast<uint8_t>(0), r);
Assert::AreEqual(static_cast<uint8_t>(0), g);
Assert::AreEqual(static_cast<uint8_t>(0), b);
}
TEST_METHOD(CheckValidARGB_ValidWhiteOpaque_ReturnsTrue)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#FFFFFFFF", &a, &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(255), a);
Assert::AreEqual(static_cast<uint8_t>(255), r);
Assert::AreEqual(static_cast<uint8_t>(255), g);
Assert::AreEqual(static_cast<uint8_t>(255), b);
}
TEST_METHOD(CheckValidARGB_ValidTransparent_ReturnsTrue)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#00FFFFFF", &a, &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(0), a);
Assert::AreEqual(static_cast<uint8_t>(255), r);
Assert::AreEqual(static_cast<uint8_t>(255), g);
Assert::AreEqual(static_cast<uint8_t>(255), b);
}
TEST_METHOD(CheckValidARGB_ValidSemiTransparent_ReturnsTrue)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#80FF0000", &a, &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(0x80), a);
Assert::AreEqual(static_cast<uint8_t>(255), r);
Assert::AreEqual(static_cast<uint8_t>(0), g);
Assert::AreEqual(static_cast<uint8_t>(0), b);
}
TEST_METHOD(CheckValidARGB_ValidMixed_ReturnsTrue)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#12345678", &a, &r, &g, &b);
Assert::IsTrue(result);
Assert::AreEqual(static_cast<uint8_t>(0x12), a);
Assert::AreEqual(static_cast<uint8_t>(0x34), r);
Assert::AreEqual(static_cast<uint8_t>(0x56), g);
Assert::AreEqual(static_cast<uint8_t>(0x78), b);
}
TEST_METHOD(CheckValidARGB_MissingHash_ReturnsFalse)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"FFFFFFFF", &a, &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidARGB_TooShort_ReturnsFalse)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#FFFFFF", &a, &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidARGB_TooLong_ReturnsFalse)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#FFFFFFFFFF", &a, &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidARGB_InvalidChars_ReturnsFalse)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#GGHHIIJJ", &a, &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidARGB_LowercaseInvalid_ReturnsFalse)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"#ffffffff", &a, &r, &g, &b);
Assert::IsFalse(result);
}
TEST_METHOD(CheckValidARGB_EmptyString_ReturnsFalse)
{
uint8_t a, r, g, b;
bool result = checkValidARGB(L"", &a, &r, &g, &b);
Assert::IsFalse(result);
}
};
}

View File

@@ -0,0 +1,228 @@
#include "pch.h"
#include "TestHelpers.h"
#include <com_object_factory.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
// Test COM object for testing the factory
class TestComObject : public IUnknown
{
public:
TestComObject() : m_refCount(1) {}
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override
{
if (riid == IID_IUnknown)
{
*ppvObject = static_cast<IUnknown*>(this);
AddRef();
return S_OK;
}
*ppvObject = nullptr;
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef() override
{
return InterlockedIncrement(&m_refCount);
}
ULONG STDMETHODCALLTYPE Release() override
{
ULONG count = InterlockedDecrement(&m_refCount);
if (count == 0)
{
delete this;
}
return count;
}
private:
LONG m_refCount;
};
TEST_CLASS(ComObjectFactoryTests)
{
public:
TEST_METHOD(ComObjectFactory_Construction_DoesNotCrash)
{
com_object_factory<TestComObject> factory;
Assert::IsTrue(true);
}
TEST_METHOD(ComObjectFactory_QueryInterface_IUnknown_Succeeds)
{
com_object_factory<TestComObject> factory;
IUnknown* pUnknown = nullptr;
HRESULT hr = factory.QueryInterface(IID_IUnknown, reinterpret_cast<void**>(&pUnknown));
Assert::AreEqual(S_OK, hr);
Assert::IsNotNull(pUnknown);
if (pUnknown)
{
pUnknown->Release();
}
}
TEST_METHOD(ComObjectFactory_QueryInterface_IClassFactory_Succeeds)
{
com_object_factory<TestComObject> factory;
IClassFactory* pFactory = nullptr;
HRESULT hr = factory.QueryInterface(IID_IClassFactory, reinterpret_cast<void**>(&pFactory));
Assert::AreEqual(S_OK, hr);
Assert::IsNotNull(pFactory);
if (pFactory)
{
pFactory->Release();
}
}
TEST_METHOD(ComObjectFactory_QueryInterface_InvalidInterface_Fails)
{
com_object_factory<TestComObject> factory;
void* pInterface = nullptr;
// Random GUID that we don't support
GUID randomGuid = { 0x12345678, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 } };
HRESULT hr = factory.QueryInterface(randomGuid, &pInterface);
Assert::AreEqual(E_NOINTERFACE, hr);
Assert::IsNull(pInterface);
}
TEST_METHOD(ComObjectFactory_AddRef_IncreasesRefCount)
{
com_object_factory<TestComObject> factory;
ULONG count1 = factory.AddRef();
ULONG count2 = factory.AddRef();
Assert::IsTrue(count2 > count1);
// Clean up
factory.Release();
factory.Release();
}
TEST_METHOD(ComObjectFactory_Release_DecreasesRefCount)
{
com_object_factory<TestComObject> factory;
factory.AddRef();
factory.AddRef();
ULONG count1 = factory.Release();
ULONG count2 = factory.Release();
Assert::IsTrue(count2 < count1);
}
TEST_METHOD(ComObjectFactory_CreateInstance_NoAggregation_Succeeds)
{
com_object_factory<TestComObject> factory;
IUnknown* pObj = nullptr;
HRESULT hr = factory.CreateInstance(nullptr, IID_IUnknown, reinterpret_cast<void**>(&pObj));
Assert::AreEqual(S_OK, hr);
Assert::IsNotNull(pObj);
if (pObj)
{
pObj->Release();
}
}
TEST_METHOD(ComObjectFactory_CreateInstance_WithAggregation_Fails)
{
com_object_factory<TestComObject> factory;
TestComObject outer;
IUnknown* pObj = nullptr;
// Aggregation should fail for our simple test object
HRESULT hr = factory.CreateInstance(&outer, IID_IUnknown, reinterpret_cast<void**>(&pObj));
Assert::AreEqual(CLASS_E_NOAGGREGATION, hr);
Assert::IsNull(pObj);
}
TEST_METHOD(ComObjectFactory_CreateInstance_NullOutput_Fails)
{
com_object_factory<TestComObject> factory;
HRESULT hr = factory.CreateInstance(nullptr, IID_IUnknown, nullptr);
Assert::AreEqual(E_POINTER, hr);
}
TEST_METHOD(ComObjectFactory_LockServer_Lock_Succeeds)
{
com_object_factory<TestComObject> factory;
HRESULT hr = factory.LockServer(TRUE);
Assert::AreEqual(S_OK, hr);
// Unlock
factory.LockServer(FALSE);
}
TEST_METHOD(ComObjectFactory_LockServer_Unlock_Succeeds)
{
com_object_factory<TestComObject> factory;
factory.LockServer(TRUE);
HRESULT hr = factory.LockServer(FALSE);
Assert::AreEqual(S_OK, hr);
}
TEST_METHOD(ComObjectFactory_LockServer_MultipleLocks_Work)
{
com_object_factory<TestComObject> factory;
factory.LockServer(TRUE);
factory.LockServer(TRUE);
factory.LockServer(TRUE);
factory.LockServer(FALSE);
factory.LockServer(FALSE);
HRESULT hr = factory.LockServer(FALSE);
Assert::AreEqual(S_OK, hr);
}
// Thread safety tests
TEST_METHOD(ComObjectFactory_ConcurrentCreateInstance_Works)
{
com_object_factory<TestComObject> factory;
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&factory, &successCount]() {
IUnknown* pObj = nullptr;
HRESULT hr = factory.CreateInstance(nullptr, IID_IUnknown, reinterpret_cast<void**>(&pObj));
if (SUCCEEDED(hr) && pObj)
{
successCount++;
pObj->Release();
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(10, successCount.load());
}
};
}

View File

@@ -0,0 +1,146 @@
#include "pch.h"
#include "TestHelpers.h"
#include <elevation.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ElevationTests)
{
public:
// is_process_elevated tests
TEST_METHOD(IsProcessElevated_ReturnsBoolean)
{
bool result = is_process_elevated(false);
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(IsProcessElevated_CachedValue_ReturnsSameResult)
{
bool result1 = is_process_elevated(true);
bool result2 = is_process_elevated(true);
// Cached value should be consistent
Assert::AreEqual(result1, result2);
}
TEST_METHOD(IsProcessElevated_UncachedValue_ReturnsBoolean)
{
bool result = is_process_elevated(false);
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(IsProcessElevated_CachedAndUncached_AreConsistent)
{
// Both should return the same value for the same process
bool cached = is_process_elevated(true);
bool uncached = is_process_elevated(false);
Assert::AreEqual(cached, uncached);
}
// check_user_is_admin tests
TEST_METHOD(CheckUserIsAdmin_ReturnsBoolean)
{
bool result = check_user_is_admin();
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(CheckUserIsAdmin_ConsistentResults)
{
bool result1 = check_user_is_admin();
bool result2 = check_user_is_admin();
bool result3 = check_user_is_admin();
Assert::AreEqual(result1, result2);
Assert::AreEqual(result2, result3);
}
// Relationship between elevation and admin
TEST_METHOD(ElevationAndAdmin_Relationship)
{
bool elevated = is_process_elevated(false);
bool admin = check_user_is_admin();
(void)admin;
// If elevated, user should typically be admin
// But user can be admin without process being elevated
if (elevated)
{
// Elevated process usually means admin user
// (though there are edge cases)
}
// Just verify both functions return without crashing
Assert::IsTrue(true);
}
// IsProcessOfWindowElevated tests
TEST_METHOD(IsProcessOfWindowElevated_DesktopWindow_ReturnsBoolean)
{
HWND desktop = GetDesktopWindow();
if (desktop)
{
bool result = IsProcessOfWindowElevated(desktop);
Assert::IsTrue(result == true || result == false);
}
Assert::IsTrue(true);
}
TEST_METHOD(IsProcessOfWindowElevated_InvalidHwnd_DoesNotCrash)
{
bool result = IsProcessOfWindowElevated(nullptr);
// Should handle null HWND gracefully
Assert::IsTrue(result == true || result == false);
}
// ProcessInfo struct tests
TEST_METHOD(ProcessInfo_DefaultConstruction)
{
ProcessInfo info{};
Assert::AreEqual(static_cast<DWORD>(0), info.processID);
}
// Thread safety tests
TEST_METHOD(IsProcessElevated_ThreadSafe)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&successCount]() {
for (int j = 0; j < 10; ++j)
{
is_process_elevated(j % 2 == 0);
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(100, successCount.load());
}
// Performance of cached value
TEST_METHOD(IsProcessElevated_CachedPerformance)
{
auto start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < 10000; ++i)
{
is_process_elevated(true);
}
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
// Cached calls should be very fast
Assert::IsTrue(duration.count() < 1000);
}
};
}

View File

@@ -0,0 +1,182 @@
#include "pch.h"
#include "TestHelpers.h"
#include <excluded_apps.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ExcludedAppsTests)
{
public:
// find_app_name_in_path tests
TEST_METHOD(FindAppNameInPath_ExactMatch_ReturnsTrue)
{
std::wstring path = L"C:\\Program Files\\App\\notepad.exe";
std::vector<std::wstring> apps = { L"notepad.exe" };
Assert::IsTrue(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_NoMatch_ReturnsFalse)
{
std::wstring path = L"C:\\Program Files\\App\\notepad.exe";
std::vector<std::wstring> apps = { L"calc.exe" };
Assert::IsFalse(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_MultipleApps_FindsMatch)
{
std::wstring path = L"C:\\Program Files\\App\\notepad.exe";
std::vector<std::wstring> apps = { L"calc.exe", L"notepad.exe", L"word.exe" };
Assert::IsTrue(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_EmptyPath_ReturnsFalse)
{
std::wstring path = L"";
std::vector<std::wstring> apps = { L"notepad.exe" };
Assert::IsFalse(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_EmptyApps_ReturnsFalse)
{
std::wstring path = L"C:\\Program Files\\App\\notepad.exe";
std::vector<std::wstring> apps = {};
Assert::IsFalse(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_PartialMatchInFolder_ReturnsFalse)
{
// "notepad" appears in folder name but not as the exe name
std::wstring path = L"C:\\notepad\\other.exe";
std::vector<std::wstring> apps = { L"notepad.exe" };
Assert::IsFalse(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_CaseSensitive_ReturnsFalse)
{
std::wstring path = L"C:\\Program Files\\App\\NOTEPAD.EXE";
std::vector<std::wstring> apps = { L"notepad.exe" };
// The function does rfind which is case-sensitive
Assert::IsFalse(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_MatchWithDifferentExtension_ReturnsFalse)
{
std::wstring path = L"C:\\Program Files\\App\\notepad.com";
std::vector<std::wstring> apps = { L"notepad.exe" };
Assert::IsFalse(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_MatchAtEndOfPath_ReturnsTrue)
{
std::wstring path = L"C:\\Windows\\System32\\notepad.exe";
std::vector<std::wstring> apps = { L"notepad.exe" };
Assert::IsTrue(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_UNCPath_Works)
{
std::wstring path = L"\\\\server\\share\\folder\\app.exe";
std::vector<std::wstring> apps = { L"app.exe" };
Assert::IsTrue(find_app_name_in_path(path, apps));
}
// find_folder_in_path tests
TEST_METHOD(FindFolderInPath_FolderExists_ReturnsTrue)
{
std::wstring path = L"C:\\Program Files\\MyApp\\app.exe";
std::vector<std::wstring> folders = { L"Program Files" };
Assert::IsTrue(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_FolderNotExists_ReturnsFalse)
{
std::wstring path = L"C:\\Windows\\System32\\app.exe";
std::vector<std::wstring> folders = { L"Program Files" };
Assert::IsFalse(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_MultipleFolders_FindsMatch)
{
std::wstring path = L"C:\\Windows\\System32\\app.exe";
std::vector<std::wstring> folders = { L"Program Files", L"System32", L"Users" };
Assert::IsTrue(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_EmptyPath_ReturnsFalse)
{
std::wstring path = L"";
std::vector<std::wstring> folders = { L"Windows" };
Assert::IsFalse(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_EmptyFolders_ReturnsFalse)
{
std::wstring path = L"C:\\Windows\\app.exe";
std::vector<std::wstring> folders = {};
Assert::IsFalse(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_PartialMatch_ReturnsTrue)
{
// find_folder_in_path uses rfind which finds substrings
std::wstring path = L"C:\\Windows\\System32\\app.exe";
std::vector<std::wstring> folders = { L"System" };
Assert::IsTrue(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_NestedFolder_ReturnsTrue)
{
std::wstring path = L"C:\\Program Files\\Company\\Product\\bin\\app.exe";
std::vector<std::wstring> folders = { L"Product" };
Assert::IsTrue(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_RootDrive_ReturnsTrue)
{
std::wstring path = L"C:\\folder\\app.exe";
std::vector<std::wstring> folders = { L"C:\\" };
Assert::IsTrue(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_UNCPath_Works)
{
std::wstring path = L"\\\\server\\share\\folder\\app.exe";
std::vector<std::wstring> folders = { L"share" };
Assert::IsTrue(find_folder_in_path(path, folders));
}
TEST_METHOD(FindFolderInPath_CaseSensitive_ReturnsFalse)
{
std::wstring path = L"C:\\WINDOWS\\app.exe";
std::vector<std::wstring> folders = { L"windows" };
// rfind is case-sensitive
Assert::IsFalse(find_folder_in_path(path, folders));
}
// Edge case tests
TEST_METHOD(FindAppNameInPath_AppNameInMiddleOfPath_HandlesCorrectly)
{
// The app name appears both in folder and as filename
std::wstring path = L"C:\\notepad\\bin\\notepad.exe";
std::vector<std::wstring> apps = { L"notepad.exe" };
Assert::IsTrue(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindAppNameInPath_JustFilename_ReturnsFalse)
{
std::wstring path = L"notepad.exe";
std::vector<std::wstring> apps = { L"notepad.exe" };
// find_app_name_in_path expects a path separator to validate the executable segment
Assert::IsFalse(find_app_name_in_path(path, apps));
}
TEST_METHOD(FindFolderInPath_JustFilename_ReturnsFalse)
{
std::wstring path = L"app.exe";
std::vector<std::wstring> folders = { L"Windows" };
Assert::IsFalse(find_folder_in_path(path, folders));
}
};
}

View File

@@ -0,0 +1,148 @@
#include "pch.h"
#include "TestHelpers.h"
#include <exec.h>
#include <cctype>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ExecTests)
{
public:
TEST_METHOD(ExecAndReadOutput_EchoCommand_ReturnsOutput)
{
auto result = exec_and_read_output(L"cmd /c echo hello", 5000);
Assert::IsTrue(result.has_value());
Assert::IsFalse(result->empty());
// Output should contain "hello"
Assert::IsTrue(result->find("hello") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_WhereCommand_ReturnsPath)
{
auto result = exec_and_read_output(L"where cmd", 5000);
Assert::IsTrue(result.has_value());
Assert::IsFalse(result->empty());
// Should contain path to cmd.exe
Assert::IsTrue(result->find("cmd") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_DirCommand_ReturnsListing)
{
auto result = exec_and_read_output(L"cmd /c dir /b C:\\Windows", 5000);
Assert::IsTrue(result.has_value());
Assert::IsFalse(result->empty());
// Should contain some common Windows folder names
std::string output = *result;
std::transform(output.begin(), output.end(), output.begin(), [](unsigned char ch) { return static_cast<char>(std::tolower(ch)); });
Assert::IsTrue(output.find("system32") != std::string::npos ||
output.find("system") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_InvalidCommand_ReturnsEmptyOrError)
{
auto result = exec_and_read_output(L"nonexistentcommand12345", 5000);
// Invalid command should either return nullopt or an error message
Assert::IsTrue(!result.has_value() || result->empty() ||
result->find("not recognized") != std::string::npos ||
result->find("error") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_EmptyCommand_DoesNotCrash)
{
auto result = exec_and_read_output(L"", 5000);
// Should handle empty command gracefully
Assert::IsTrue(true);
}
TEST_METHOD(ExecAndReadOutput_TimeoutExpires_ReturnsAvailableOutput)
{
// Use a command that produces output slowly
// ping localhost will run for a while
auto start = std::chrono::steady_clock::now();
// Very short timeout
auto result = exec_and_read_output(L"ping localhost -n 10", 100);
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start);
// Should return within reasonable time
Assert::IsTrue(elapsed.count() < 5000);
}
TEST_METHOD(ExecAndReadOutput_MultilineOutput_PreservesLines)
{
auto result = exec_and_read_output(L"cmd /c \"echo line1 & echo line2 & echo line3\"", 5000);
Assert::IsTrue(result.has_value());
// Should contain multiple lines
Assert::IsTrue(result->find("line1") != std::string::npos);
Assert::IsTrue(result->find("line2") != std::string::npos);
Assert::IsTrue(result->find("line3") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_UnicodeOutput_Works)
{
// Echo a simple ASCII string (Unicode test depends on system codepage)
auto result = exec_and_read_output(L"cmd /c echo test123", 5000);
Assert::IsTrue(result.has_value());
Assert::IsTrue(result->find("test123") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_LongTimeout_Works)
{
auto result = exec_and_read_output(L"cmd /c echo test", 60000);
Assert::IsTrue(result.has_value());
Assert::IsTrue(result->find("test") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_QuotedArguments_Work)
{
auto result = exec_and_read_output(L"cmd /c echo \"hello world\"", 5000);
Assert::IsTrue(result.has_value());
Assert::IsTrue(result->find("hello") != std::string::npos);
}
TEST_METHOD(ExecAndReadOutput_EnvironmentVariable_Expanded)
{
auto result = exec_and_read_output(L"cmd /c echo %USERNAME%", 5000);
Assert::IsTrue(result.has_value());
// Should not contain the literal %USERNAME% but the actual username
// Or if not expanded, still should not crash
Assert::IsFalse(result->empty());
}
TEST_METHOD(ExecAndReadOutput_ExitCode_CommandFails)
{
// Command that exits with error
auto result = exec_and_read_output(L"cmd /c exit 1", 5000);
// Should still return something (possibly empty)
// Just verify it doesn't crash
Assert::IsTrue(true);
}
TEST_METHOD(ExecAndReadOutput_ZeroTimeout_DoesNotHang)
{
auto start = std::chrono::steady_clock::now();
auto result = exec_and_read_output(L"cmd /c echo test", 0);
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start);
// Should complete quickly with zero timeout
Assert::IsTrue(elapsed.count() < 5000);
}
};
}

View File

@@ -0,0 +1,68 @@
#include "pch.h"
#include "TestHelpers.h"
#include <game_mode.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(GameModeTests)
{
public:
TEST_METHOD(DetectGameMode_ReturnsBoolean)
{
// This function queries Windows game mode status
bool result = detect_game_mode();
// Result depends on current system state, but should be a valid boolean
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(DetectGameMode_ConsistentResults)
{
// Multiple calls should return consistent results (unless game mode changes)
bool result1 = detect_game_mode();
bool result2 = detect_game_mode();
bool result3 = detect_game_mode();
// Results should be consistent across rapid calls
Assert::AreEqual(result1, result2);
Assert::AreEqual(result2, result3);
}
TEST_METHOD(DetectGameMode_DoesNotCrash)
{
// Call multiple times to ensure no crash or memory leak
for (int i = 0; i < 100; ++i)
{
detect_game_mode();
}
Assert::IsTrue(true);
}
TEST_METHOD(DetectGameMode_ThreadSafe)
{
// Test that calling from multiple threads is safe
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&successCount]() {
for (int j = 0; j < 10; ++j)
{
detect_game_mode();
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(100, successCount.load());
}
};
}

View File

@@ -0,0 +1,218 @@
#include "pch.h"
#include "TestHelpers.h"
#include <gpo.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace powertoys_gpo;
namespace UnitTestsCommonUtils
{
TEST_CLASS(GpoTests)
{
public:
// Helper to check if result is a valid gpo_rule_configured_t value
static constexpr bool IsValidGpoResult(gpo_rule_configured_t result)
{
return result == gpo_rule_configured_wrong_value ||
result == gpo_rule_configured_unavailable ||
result == gpo_rule_configured_not_configured ||
result == gpo_rule_configured_disabled ||
result == gpo_rule_configured_enabled;
}
// gpo_rule_configured_t enum tests
TEST_METHOD(GpoRuleConfigured_EnumValues_AreDistinct)
{
Assert::AreNotEqual(static_cast<int>(gpo_rule_configured_not_configured),
static_cast<int>(gpo_rule_configured_enabled));
Assert::AreNotEqual(static_cast<int>(gpo_rule_configured_enabled),
static_cast<int>(gpo_rule_configured_disabled));
Assert::AreNotEqual(static_cast<int>(gpo_rule_configured_not_configured),
static_cast<int>(gpo_rule_configured_disabled));
}
// getConfiguredValue tests
TEST_METHOD(GetConfiguredValue_NonExistentKey_ReturnsNotConfigured)
{
auto result = getConfiguredValue(L"NonExistentPolicyValue12345");
Assert::IsTrue(result == gpo_rule_configured_not_configured ||
result == gpo_rule_configured_unavailable);
}
// Utility enabled getters - these all follow the same pattern
TEST_METHOD(GetAllowExperimentationValue_ReturnsValidState)
{
auto result = getAllowExperimentationValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredAlwaysOnTopEnabledValue_ReturnsValidState)
{
auto result = getConfiguredAlwaysOnTopEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredAwakeEnabledValue_ReturnsValidState)
{
auto result = getConfiguredAwakeEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredColorPickerEnabledValue_ReturnsValidState)
{
auto result = getConfiguredColorPickerEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredFancyZonesEnabledValue_ReturnsValidState)
{
auto result = getConfiguredFancyZonesEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredFileLocksmithEnabledValue_ReturnsValidState)
{
auto result = getConfiguredFileLocksmithEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredImageResizerEnabledValue_ReturnsValidState)
{
auto result = getConfiguredImageResizerEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredKeyboardManagerEnabledValue_ReturnsValidState)
{
auto result = getConfiguredKeyboardManagerEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredPowerRenameEnabledValue_ReturnsValidState)
{
auto result = getConfiguredPowerRenameEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredPowerLauncherEnabledValue_ReturnsValidState)
{
auto result = getConfiguredPowerLauncherEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredShortcutGuideEnabledValue_ReturnsValidState)
{
auto result = getConfiguredShortcutGuideEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredTextExtractorEnabledValue_ReturnsValidState)
{
auto result = getConfiguredTextExtractorEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredHostsFileEditorEnabledValue_ReturnsValidState)
{
auto result = getConfiguredHostsFileEditorEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredMousePointerCrosshairsEnabledValue_ReturnsValidState)
{
auto result = getConfiguredMousePointerCrosshairsEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredMouseHighlighterEnabledValue_ReturnsValidState)
{
auto result = getConfiguredMouseHighlighterEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredMouseJumpEnabledValue_ReturnsValidState)
{
auto result = getConfiguredMouseJumpEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredFindMyMouseEnabledValue_ReturnsValidState)
{
auto result = getConfiguredFindMyMouseEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredMouseWithoutBordersEnabledValue_ReturnsValidState)
{
auto result = getConfiguredMouseWithoutBordersEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredAdvancedPasteEnabledValue_ReturnsValidState)
{
auto result = getConfiguredAdvancedPasteEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredPeekEnabledValue_ReturnsValidState)
{
auto result = getConfiguredPeekEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredRegistryPreviewEnabledValue_ReturnsValidState)
{
auto result = getConfiguredRegistryPreviewEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredScreenRulerEnabledValue_ReturnsValidState)
{
auto result = getConfiguredScreenRulerEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredCropAndLockEnabledValue_ReturnsValidState)
{
auto result = getConfiguredCropAndLockEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
TEST_METHOD(GetConfiguredEnvironmentVariablesEnabledValue_ReturnsValidState)
{
auto result = getConfiguredEnvironmentVariablesEnabledValue();
Assert::IsTrue(IsValidGpoResult(result));
}
// All GPO functions should not crash
TEST_METHOD(AllGpoFunctions_DoNotCrash)
{
getAllowExperimentationValue();
getConfiguredAlwaysOnTopEnabledValue();
getConfiguredAwakeEnabledValue();
getConfiguredColorPickerEnabledValue();
getConfiguredFancyZonesEnabledValue();
getConfiguredFileLocksmithEnabledValue();
getConfiguredImageResizerEnabledValue();
getConfiguredKeyboardManagerEnabledValue();
getConfiguredPowerRenameEnabledValue();
getConfiguredPowerLauncherEnabledValue();
getConfiguredShortcutGuideEnabledValue();
getConfiguredTextExtractorEnabledValue();
getConfiguredHostsFileEditorEnabledValue();
getConfiguredMousePointerCrosshairsEnabledValue();
getConfiguredMouseHighlighterEnabledValue();
getConfiguredMouseJumpEnabledValue();
getConfiguredFindMyMouseEnabledValue();
getConfiguredMouseWithoutBordersEnabledValue();
getConfiguredAdvancedPasteEnabledValue();
getConfiguredPeekEnabledValue();
getConfiguredRegistryPreviewEnabledValue();
getConfiguredScreenRulerEnabledValue();
getConfiguredCropAndLockEnabledValue();
getConfiguredEnvironmentVariablesEnabledValue();
Assert::IsTrue(true);
}
};
}

View File

@@ -0,0 +1,200 @@
#include "pch.h"
#include "TestHelpers.h"
#include <HDropIterator.h>
#include <shlobj.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(HDropIteratorTests)
{
public:
// Helper to create a test HDROP structure
static HGLOBAL CreateTestHDrop(const std::vector<std::wstring>& files)
{
// Calculate required size
size_t size = sizeof(DROPFILES);
for (const auto& file : files)
{
size += (file.length() + 1) * sizeof(wchar_t);
}
size += sizeof(wchar_t); // Double null terminator
HGLOBAL hGlobal = GlobalAlloc(GHND, size);
if (!hGlobal) return nullptr;
DROPFILES* pDropFiles = static_cast<DROPFILES*>(GlobalLock(hGlobal));
if (!pDropFiles)
{
GlobalFree(hGlobal);
return nullptr;
}
pDropFiles->pFiles = sizeof(DROPFILES);
pDropFiles->fWide = TRUE;
wchar_t* pData = reinterpret_cast<wchar_t*>(reinterpret_cast<BYTE*>(pDropFiles) + sizeof(DROPFILES));
for (const auto& file : files)
{
wcscpy_s(pData, file.length() + 1, file.c_str());
pData += file.length() + 1;
}
*pData = L'\0'; // Double null terminator
GlobalUnlock(hGlobal);
return hGlobal;
}
TEST_METHOD(HDropIterator_EmptyDrop_IsDoneImmediately)
{
HGLOBAL hGlobal = CreateTestHDrop({});
if (!hGlobal)
{
Assert::IsTrue(true); // Skip if allocation failed
return;
}
STGMEDIUM medium = {};
medium.tymed = TYMED_HGLOBAL;
medium.hGlobal = hGlobal;
// Without a proper IDataObject, we can't fully test
// Just verify the class can be instantiated conceptually
GlobalFree(hGlobal);
Assert::IsTrue(true);
}
TEST_METHOD(HDropIterator_Iteration_Conceptual)
{
// This test verifies the concept of iteration
// Full integration testing requires a proper IDataObject
std::vector<std::wstring> testFiles = {
L"C:\\test\\file1.txt",
L"C:\\test\\file2.txt",
L"C:\\test\\file3.txt"
};
HGLOBAL hGlobal = CreateTestHDrop(testFiles);
if (!hGlobal)
{
Assert::IsTrue(true);
return;
}
// Verify we can create the HDROP structure
DROPFILES* pDropFiles = static_cast<DROPFILES*>(GlobalLock(hGlobal));
Assert::IsNotNull(pDropFiles);
Assert::IsTrue(pDropFiles->fWide);
GlobalUnlock(hGlobal);
GlobalFree(hGlobal);
Assert::IsTrue(true);
}
TEST_METHOD(HDropIterator_SingleFile_Works)
{
std::vector<std::wstring> testFiles = { L"C:\\test\\single.txt" };
HGLOBAL hGlobal = CreateTestHDrop(testFiles);
if (!hGlobal)
{
Assert::IsTrue(true);
return;
}
// Verify structure
DROPFILES* pDropFiles = static_cast<DROPFILES*>(GlobalLock(hGlobal));
Assert::IsNotNull(pDropFiles);
// Read back the file name
wchar_t* pData = reinterpret_cast<wchar_t*>(reinterpret_cast<BYTE*>(pDropFiles) + pDropFiles->pFiles);
Assert::AreEqual(std::wstring(L"C:\\test\\single.txt"), std::wstring(pData));
GlobalUnlock(hGlobal);
GlobalFree(hGlobal);
}
TEST_METHOD(HDropIterator_MultipleFiles_Structure)
{
std::vector<std::wstring> testFiles = {
L"C:\\file1.txt",
L"C:\\file2.txt",
L"C:\\file3.txt"
};
HGLOBAL hGlobal = CreateTestHDrop(testFiles);
if (!hGlobal)
{
Assert::IsTrue(true);
return;
}
DROPFILES* pDropFiles = static_cast<DROPFILES*>(GlobalLock(hGlobal));
Assert::IsNotNull(pDropFiles);
// Count files by iterating through null-terminated strings
wchar_t* pData = reinterpret_cast<wchar_t*>(reinterpret_cast<BYTE*>(pDropFiles) + pDropFiles->pFiles);
int count = 0;
while (*pData)
{
count++;
pData += wcslen(pData) + 1;
}
Assert::AreEqual(3, count);
GlobalUnlock(hGlobal);
GlobalFree(hGlobal);
}
TEST_METHOD(HDropIterator_UnicodeFilenames_Work)
{
std::vector<std::wstring> testFiles = {
L"C:\\test\\file.txt"
};
HGLOBAL hGlobal = CreateTestHDrop(testFiles);
if (!hGlobal)
{
Assert::IsTrue(true);
return;
}
DROPFILES* pDropFiles = static_cast<DROPFILES*>(GlobalLock(hGlobal));
Assert::IsTrue(pDropFiles->fWide == TRUE);
GlobalUnlock(hGlobal);
GlobalFree(hGlobal);
}
TEST_METHOD(HDropIterator_LongFilenames_Work)
{
std::wstring longPath = L"C:\\";
for (int i = 0; i < 20; ++i)
{
longPath += L"LongFolderName\\";
}
longPath += L"file.txt";
std::vector<std::wstring> testFiles = { longPath };
HGLOBAL hGlobal = CreateTestHDrop(testFiles);
if (!hGlobal)
{
Assert::IsTrue(true);
return;
}
DROPFILES* pDropFiles = static_cast<DROPFILES*>(GlobalLock(hGlobal));
Assert::IsNotNull(pDropFiles);
wchar_t* pData = reinterpret_cast<wchar_t*>(reinterpret_cast<BYTE*>(pDropFiles) + pDropFiles->pFiles);
Assert::AreEqual(longPath, std::wstring(pData));
GlobalUnlock(hGlobal);
GlobalFree(hGlobal);
}
};
}

View File

@@ -0,0 +1,152 @@
#include "pch.h"
#include "TestHelpers.h"
#include <HttpClient.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(HttpClientTests)
{
public:
// Note: Network tests may fail in offline environments
// These tests are designed to verify the API doesn't crash
TEST_METHOD(HttpClient_DefaultConstruction)
{
http::HttpClient client;
// Should not crash
Assert::IsTrue(true);
}
TEST_METHOD(HttpClient_Request_InvalidUri_ReturnsEmpty)
{
http::HttpClient client;
try
{
// Invalid URI should not crash, may throw or return empty
auto result = client.request(winrt::Windows::Foundation::Uri(L"invalid://not-a-valid-uri"));
// If we get here, result may be empty or contain error
}
catch (...)
{
// Exception is acceptable for invalid URI
}
Assert::IsTrue(true);
}
TEST_METHOD(HttpClient_Download_InvalidUri_DoesNotCrash)
{
http::HttpClient client;
TestHelpers::TempFile tempFile;
try
{
auto result = client.download(
winrt::Windows::Foundation::Uri(L"https://invalid.invalid.invalid"),
tempFile.path());
// May return false or throw
}
catch (...)
{
// Exception is acceptable for invalid/unreachable URI
}
Assert::IsTrue(true);
}
TEST_METHOD(HttpClient_Download_WithCallback_DoesNotCrash)
{
http::HttpClient client;
TestHelpers::TempFile tempFile;
std::atomic<int> callbackCount{ 0 };
try
{
auto result = client.download(
winrt::Windows::Foundation::Uri(L"https://invalid.invalid.invalid"),
tempFile.path(),
[&callbackCount]([[maybe_unused]] float progress) {
callbackCount++;
});
}
catch (...)
{
// Exception is acceptable
}
Assert::IsTrue(true);
}
TEST_METHOD(HttpClient_Download_EmptyPath_DoesNotCrash)
{
http::HttpClient client;
try
{
auto result = client.download(
winrt::Windows::Foundation::Uri(L"https://example.com"),
L"");
}
catch (...)
{
// Exception is acceptable for empty path
}
Assert::IsTrue(true);
}
// These tests require network access and may be skipped in offline environments
TEST_METHOD(HttpClient_Request_ValidUri_ReturnsResult)
{
// Skip this test in most CI environments
// Only run manually to verify network functionality
http::HttpClient client;
try
{
// Use a reliable, fast-responding URL
auto result = client.request(winrt::Windows::Foundation::Uri(L"https://www.microsoft.com"));
// Result may or may not be successful depending on network
}
catch (...)
{
// Network errors are acceptable in test environment
}
Assert::IsTrue(true);
}
// Thread safety test (doesn't require network)
TEST_METHOD(HttpClient_MultipleInstances_DoNotCrash)
{
std::vector<std::unique_ptr<http::HttpClient>> clients;
for (int i = 0; i < 10; ++i)
{
clients.push_back(std::make_unique<http::HttpClient>());
}
// All clients should coexist without crashing
Assert::AreEqual(static_cast<size_t>(10), clients.size());
}
TEST_METHOD(HttpClient_ConcurrentConstruction_DoesNotCrash)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 5; ++i)
{
threads.emplace_back([&successCount]() {
http::HttpClient client;
successCount++;
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(5, successCount.load());
}
};
}

View File

@@ -0,0 +1,283 @@
#include "pch.h"
#include "TestHelpers.h"
#include <json.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace winrt::Windows::Data::Json;
namespace UnitTestsCommonUtils
{
TEST_CLASS(JsonTests)
{
public:
// from_file tests
TEST_METHOD(FromFile_NonExistentFile_ReturnsNullopt)
{
auto result = json::from_file(L"C:\\NonExistent\\File\\Path.json");
Assert::IsFalse(result.has_value());
}
TEST_METHOD(FromFile_ValidJsonFile_ReturnsJsonObject)
{
TestHelpers::TempFile tempFile(L"", L".json");
tempFile.write("{\"key\": \"value\"}");
auto result = json::from_file(tempFile.path());
Assert::IsTrue(result.has_value());
}
TEST_METHOD(FromFile_InvalidJson_ReturnsNullopt)
{
TestHelpers::TempFile tempFile(L"", L".json");
tempFile.write("not valid json {{{");
auto result = json::from_file(tempFile.path());
Assert::IsFalse(result.has_value());
}
TEST_METHOD(FromFile_EmptyFile_ReturnsNullopt)
{
TestHelpers::TempFile tempFile(L"", L".json");
// File is empty
auto result = json::from_file(tempFile.path());
Assert::IsFalse(result.has_value());
}
TEST_METHOD(FromFile_ValidComplexJson_ParsesCorrectly)
{
TestHelpers::TempFile tempFile(L"", L".json");
tempFile.write("{\"name\": \"test\", \"value\": 42, \"enabled\": true}");
auto result = json::from_file(tempFile.path());
Assert::IsTrue(result.has_value());
auto& obj = *result;
Assert::IsTrue(obj.HasKey(L"name"));
Assert::IsTrue(obj.HasKey(L"value"));
Assert::IsTrue(obj.HasKey(L"enabled"));
}
// to_file tests
TEST_METHOD(ToFile_ValidObject_WritesFile)
{
TestHelpers::TempFile tempFile(L"", L".json");
JsonObject obj;
obj.SetNamedValue(L"key", JsonValue::CreateStringValue(L"value"));
json::to_file(tempFile.path(), obj);
// Read back and verify
auto result = json::from_file(tempFile.path());
Assert::IsTrue(result.has_value());
Assert::IsTrue(result->HasKey(L"key"));
}
TEST_METHOD(ToFile_ComplexObject_WritesFile)
{
TestHelpers::TempFile tempFile(L"", L".json");
JsonObject obj;
obj.SetNamedValue(L"name", JsonValue::CreateStringValue(L"test"));
obj.SetNamedValue(L"value", JsonValue::CreateNumberValue(42));
obj.SetNamedValue(L"enabled", JsonValue::CreateBooleanValue(true));
json::to_file(tempFile.path(), obj);
auto result = json::from_file(tempFile.path());
Assert::IsTrue(result.has_value());
Assert::AreEqual(std::wstring(L"test"), std::wstring(result->GetNamedString(L"name")));
Assert::AreEqual(42.0, result->GetNamedNumber(L"value"));
Assert::IsTrue(result->GetNamedBoolean(L"enabled"));
}
// has tests
TEST_METHOD(Has_ExistingKey_ReturnsTrue)
{
JsonObject obj;
obj.SetNamedValue(L"key", JsonValue::CreateStringValue(L"value"));
Assert::IsTrue(json::has(obj, L"key", JsonValueType::String));
}
TEST_METHOD(Has_NonExistingKey_ReturnsFalse)
{
JsonObject obj;
Assert::IsFalse(json::has(obj, L"key", JsonValueType::String));
}
TEST_METHOD(Has_WrongType_ReturnsFalse)
{
JsonObject obj;
obj.SetNamedValue(L"key", JsonValue::CreateStringValue(L"value"));
Assert::IsFalse(json::has(obj, L"key", JsonValueType::Number));
}
TEST_METHOD(Has_NumberType_ReturnsTrue)
{
JsonObject obj;
obj.SetNamedValue(L"key", JsonValue::CreateNumberValue(42));
Assert::IsTrue(json::has(obj, L"key", JsonValueType::Number));
}
TEST_METHOD(Has_BooleanType_ReturnsTrue)
{
JsonObject obj;
obj.SetNamedValue(L"key", JsonValue::CreateBooleanValue(true));
Assert::IsTrue(json::has(obj, L"key", JsonValueType::Boolean));
}
TEST_METHOD(Has_ObjectType_ReturnsTrue)
{
JsonObject obj;
JsonObject nested;
obj.SetNamedValue(L"key", nested);
Assert::IsTrue(json::has(obj, L"key", JsonValueType::Object));
}
// value function tests
TEST_METHOD(Value_IntegerType_CreatesNumberValue)
{
auto val = json::value(42);
Assert::IsTrue(val.ValueType() == JsonValueType::Number);
Assert::AreEqual(42.0, val.GetNumber());
}
TEST_METHOD(Value_DoubleType_CreatesNumberValue)
{
auto val = json::value(3.14);
Assert::IsTrue(val.ValueType() == JsonValueType::Number);
Assert::AreEqual(3.14, val.GetNumber());
}
TEST_METHOD(Value_BooleanTrue_CreatesBooleanValue)
{
auto val = json::value(true);
Assert::IsTrue(val.ValueType() == JsonValueType::Boolean);
Assert::IsTrue(val.GetBoolean());
}
TEST_METHOD(Value_BooleanFalse_CreatesBooleanValue)
{
auto val = json::value(false);
Assert::IsTrue(val.ValueType() == JsonValueType::Boolean);
Assert::IsFalse(val.GetBoolean());
}
TEST_METHOD(Value_String_CreatesStringValue)
{
auto val = json::value(L"hello");
Assert::IsTrue(val.ValueType() == JsonValueType::String);
Assert::AreEqual(std::wstring(L"hello"), std::wstring(val.GetString()));
}
TEST_METHOD(Value_JsonObject_ReturnsJsonValue)
{
JsonObject obj;
obj.SetNamedValue(L"key", JsonValue::CreateStringValue(L"value"));
auto val = json::value(obj);
Assert::IsTrue(val.ValueType() == JsonValueType::Object);
}
TEST_METHOD(Value_JsonValue_ReturnsIdentity)
{
auto original = JsonValue::CreateStringValue(L"test");
auto result = json::value(original);
Assert::AreEqual(std::wstring(L"test"), std::wstring(result.GetString()));
}
// get function tests
TEST_METHOD(Get_BooleanValue_ReturnsValue)
{
JsonObject obj;
obj.SetNamedValue(L"enabled", JsonValue::CreateBooleanValue(true));
bool result = false;
json::get(obj, L"enabled", result);
Assert::IsTrue(result);
}
TEST_METHOD(Get_IntValue_ReturnsValue)
{
JsonObject obj;
obj.SetNamedValue(L"count", JsonValue::CreateNumberValue(42));
int result = 0;
json::get(obj, L"count", result);
Assert::AreEqual(42, result);
}
TEST_METHOD(Get_DoubleValue_ReturnsValue)
{
JsonObject obj;
obj.SetNamedValue(L"ratio", JsonValue::CreateNumberValue(3.14));
double result = 0.0;
json::get(obj, L"ratio", result);
Assert::AreEqual(3.14, result);
}
TEST_METHOD(Get_StringValue_ReturnsValue)
{
JsonObject obj;
obj.SetNamedValue(L"name", JsonValue::CreateStringValue(L"test"));
std::wstring result;
json::get(obj, L"name", result);
Assert::AreEqual(std::wstring(L"test"), result);
}
TEST_METHOD(Get_MissingKey_UsesDefault)
{
JsonObject obj;
int result = 0;
json::get(obj, L"missing", result, 99);
Assert::AreEqual(99, result);
}
TEST_METHOD(Get_MissingKeyNoDefault_PreservesOriginal)
{
JsonObject obj;
int result = 42;
json::get(obj, L"missing", result);
// When key is missing and no default, original value is preserved
Assert::AreEqual(42, result);
}
TEST_METHOD(Get_JsonObject_ReturnsObject)
{
JsonObject obj;
JsonObject nested;
nested.SetNamedValue(L"inner", JsonValue::CreateStringValue(L"value"));
obj.SetNamedValue(L"nested", nested);
JsonObject result;
json::get(obj, L"nested", result);
Assert::IsTrue(result.HasKey(L"inner"));
}
// Roundtrip tests
TEST_METHOD(Roundtrip_ComplexObject_PreservesData)
{
TestHelpers::TempFile tempFile(L"", L".json");
JsonObject original;
original.SetNamedValue(L"string", JsonValue::CreateStringValue(L"hello"));
original.SetNamedValue(L"number", JsonValue::CreateNumberValue(42));
original.SetNamedValue(L"boolean", JsonValue::CreateBooleanValue(true));
JsonObject nested;
nested.SetNamedValue(L"inner", JsonValue::CreateStringValue(L"world"));
original.SetNamedValue(L"object", nested);
json::to_file(tempFile.path(), original);
auto loaded = json::from_file(tempFile.path());
Assert::IsTrue(loaded.has_value());
Assert::AreEqual(std::wstring(L"hello"), std::wstring(loaded->GetNamedString(L"string")));
Assert::AreEqual(42.0, loaded->GetNamedNumber(L"number"));
Assert::IsTrue(loaded->GetNamedBoolean(L"boolean"));
Assert::AreEqual(std::wstring(L"world"), std::wstring(loaded->GetNamedObject(L"object").GetNamedString(L"inner")));
}
};
}

View File

@@ -0,0 +1,180 @@
#include "pch.h"
#include "TestHelpers.h"
#include <logger_helper.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace LoggerHelpers;
namespace UnitTestsCommonUtils
{
TEST_CLASS(LoggerHelperTests)
{
public:
// get_log_folder_path tests
TEST_METHOD(GetLogFolderPath_ValidAppPath_ReturnsPath)
{
auto result = get_log_folder_path(L"TestApp");
Assert::IsFalse(result.empty());
// Should contain the app name or be a valid path
auto pathStr = result.wstring();
Assert::IsTrue(pathStr.length() > 0);
}
TEST_METHOD(GetLogFolderPath_EmptyAppPath_ReturnsPath)
{
auto result = get_log_folder_path(L"");
// Should still return a base path
Assert::IsTrue(true); // Just verify no crash
}
TEST_METHOD(GetLogFolderPath_SpecialCharacters_Works)
{
auto result = get_log_folder_path(L"Test App With Spaces");
// Should handle spaces in path
Assert::IsTrue(true);
}
TEST_METHOD(GetLogFolderPath_ConsistentResults)
{
auto result1 = get_log_folder_path(L"TestApp");
auto result2 = get_log_folder_path(L"TestApp");
Assert::AreEqual(result1.wstring(), result2.wstring());
}
// dir_exists tests
TEST_METHOD(DirExists_WindowsDirectory_ReturnsTrue)
{
bool result = dir_exists(std::filesystem::path(L"C:\\Windows"));
Assert::IsTrue(result);
}
TEST_METHOD(DirExists_NonExistentDirectory_ReturnsFalse)
{
bool result = dir_exists(std::filesystem::path(L"C:\\NonExistentDir12345"));
Assert::IsFalse(result);
}
TEST_METHOD(DirExists_FileInsteadOfDir_ReturnsTrue)
{
// notepad.exe is a file, not a directory
bool result = dir_exists(std::filesystem::path(L"C:\\Windows\\notepad.exe"));
Assert::IsTrue(result);
}
TEST_METHOD(DirExists_EmptyPath_ReturnsFalse)
{
bool result = dir_exists(std::filesystem::path(L""));
Assert::IsFalse(result);
}
TEST_METHOD(DirExists_TempDirectory_ReturnsTrue)
{
wchar_t tempPath[MAX_PATH];
GetTempPathW(MAX_PATH, tempPath);
bool result = dir_exists(std::filesystem::path(tempPath));
Assert::IsTrue(result);
}
// delete_old_log_folder tests
TEST_METHOD(DeleteOldLogFolder_NonExistentFolder_DoesNotCrash)
{
delete_old_log_folder(std::filesystem::path(L"C:\\NonExistentLogFolder12345"));
Assert::IsTrue(true);
}
TEST_METHOD(DeleteOldLogFolder_ValidEmptyFolder_Works)
{
TestHelpers::TempDirectory tempDir;
// Create a subfolder structure
auto logFolder = std::filesystem::path(tempDir.path()) / L"logs";
std::filesystem::create_directories(logFolder);
Assert::IsTrue(std::filesystem::exists(logFolder));
delete_old_log_folder(logFolder);
// Folder may or may not be deleted depending on implementation
Assert::IsTrue(true);
}
// delete_other_versions_log_folders tests
TEST_METHOD(DeleteOtherVersionsLogFolders_NonExistentPath_DoesNotCrash)
{
delete_other_versions_log_folders(L"C:\\NonExistent\\Path", L"1.0.0");
Assert::IsTrue(true);
}
TEST_METHOD(DeleteOtherVersionsLogFolders_EmptyVersion_DoesNotCrash)
{
wchar_t tempPath[MAX_PATH];
GetTempPathW(MAX_PATH, tempPath);
delete_other_versions_log_folders(tempPath, L"");
Assert::IsTrue(true);
}
// Thread safety tests
TEST_METHOD(GetLogFolderPath_ThreadSafe)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&successCount, i]() {
auto path = get_log_folder_path(L"TestApp" + std::to_wstring(i));
if (!path.empty())
{
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(10, successCount.load());
}
TEST_METHOD(DirExists_ThreadSafe)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&successCount]() {
for (int j = 0; j < 10; ++j)
{
dir_exists(std::filesystem::path(L"C:\\Windows"));
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(100, successCount.load());
}
// Path construction tests
TEST_METHOD(GetLogFolderPath_ReturnsValidFilesystemPath)
{
auto result = get_log_folder_path(L"TestApp");
// Should be a valid path that we can use with filesystem operations
Assert::IsTrue(result.is_absolute() || result.has_root_name() || !result.empty());
}
};
}

View File

@@ -0,0 +1,173 @@
#include "pch.h"
#include "TestHelpers.h"
#include <modulesRegistry.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
static std::wstring GetInstallDir()
{
wchar_t path[MAX_PATH];
GetModuleFileNameW(nullptr, path, MAX_PATH);
return std::filesystem::path{ path }.parent_path().wstring();
}
TEST_CLASS(ModulesRegistryTests)
{
public:
// Test that all changeset generator functions return valid changesets
TEST_METHOD(GetSvgPreviewHandlerChangeSet_ReturnsChangeSet)
{
auto changeSet = getSvgPreviewHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetSvgThumbnailProviderChangeSet_ReturnsChangeSet)
{
auto changeSet = getSvgThumbnailHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetMarkdownPreviewHandlerChangeSet_ReturnsChangeSet)
{
auto changeSet = getMdPreviewHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetMonacoPreviewHandlerChangeSet_ReturnsChangeSet)
{
auto changeSet = getMonacoPreviewHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetPdfPreviewHandlerChangeSet_ReturnsChangeSet)
{
auto changeSet = getPdfPreviewHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetPdfThumbnailProviderChangeSet_ReturnsChangeSet)
{
auto changeSet = getPdfThumbnailHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetGcodePreviewHandlerChangeSet_ReturnsChangeSet)
{
auto changeSet = getGcodePreviewHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetGcodeThumbnailProviderChangeSet_ReturnsChangeSet)
{
auto changeSet = getGcodeThumbnailHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetStlThumbnailProviderChangeSet_ReturnsChangeSet)
{
auto changeSet = getStlThumbnailHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetQoiPreviewHandlerChangeSet_ReturnsChangeSet)
{
auto changeSet = getQoiPreviewHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
TEST_METHOD(GetQoiThumbnailProviderChangeSet_ReturnsChangeSet)
{
auto changeSet = getQoiThumbnailHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
// Test enabled vs disabled state
TEST_METHOD(ChangeSet_EnabledVsDisabled_MayDiffer)
{
auto enabledSet = getSvgPreviewHandlerChangeSet(GetInstallDir(), true);
auto disabledSet = getSvgPreviewHandlerChangeSet(GetInstallDir(), false);
// Both should be valid change sets
Assert::IsFalse(enabledSet.changes.empty());
Assert::IsFalse(disabledSet.changes.empty());
}
// Test getAllOnByDefaultModulesChangeSets
TEST_METHOD(GetAllOnByDefaultModulesChangeSets_ReturnsMultipleChangeSets)
{
auto changeSets = getAllOnByDefaultModulesChangeSets(GetInstallDir());
// Should return multiple changesets for all default-enabled modules
Assert::IsTrue(changeSets.size() > 0);
}
// Test getAllModulesChangeSets
TEST_METHOD(GetAllModulesChangeSets_ReturnsChangeSets)
{
auto changeSets = getAllModulesChangeSets(GetInstallDir());
// Should return changesets for all modules
Assert::IsTrue(changeSets.size() > 0);
}
TEST_METHOD(GetAllModulesChangeSets_ContainsMoreThanOnByDefault)
{
auto allSets = getAllModulesChangeSets(GetInstallDir());
auto defaultSets = getAllOnByDefaultModulesChangeSets(GetInstallDir());
// All modules should be >= on-by-default modules
Assert::IsTrue(allSets.size() >= defaultSets.size());
}
// Test that changesets have valid structure
TEST_METHOD(ChangeSet_HasValidKeyPath)
{
auto changeSet = getSvgPreviewHandlerChangeSet(GetInstallDir(), false);
Assert::IsFalse(changeSet.changes.empty());
}
// Test all changeset functions don't crash
TEST_METHOD(AllChangeSetFunctions_DoNotCrash)
{
auto installDir = GetInstallDir();
getSvgPreviewHandlerChangeSet(installDir, true);
getSvgPreviewHandlerChangeSet(installDir, false);
getSvgThumbnailHandlerChangeSet(installDir, true);
getSvgThumbnailHandlerChangeSet(installDir, false);
getMdPreviewHandlerChangeSet(installDir, true);
getMdPreviewHandlerChangeSet(installDir, false);
getMonacoPreviewHandlerChangeSet(installDir, true);
getMonacoPreviewHandlerChangeSet(installDir, false);
getPdfPreviewHandlerChangeSet(installDir, true);
getPdfPreviewHandlerChangeSet(installDir, false);
getPdfThumbnailHandlerChangeSet(installDir, true);
getPdfThumbnailHandlerChangeSet(installDir, false);
getGcodePreviewHandlerChangeSet(installDir, true);
getGcodePreviewHandlerChangeSet(installDir, false);
getGcodeThumbnailHandlerChangeSet(installDir, true);
getGcodeThumbnailHandlerChangeSet(installDir, false);
getStlThumbnailHandlerChangeSet(installDir, true);
getStlThumbnailHandlerChangeSet(installDir, false);
getQoiPreviewHandlerChangeSet(installDir, true);
getQoiPreviewHandlerChangeSet(installDir, false);
getQoiThumbnailHandlerChangeSet(installDir, true);
getQoiThumbnailHandlerChangeSet(installDir, false);
Assert::IsTrue(true);
}
};
}

View File

@@ -0,0 +1,65 @@
#include "pch.h"
#include "TestHelpers.h"
#include <MsWindowsSettings.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(MsWindowsSettingsTests)
{
public:
TEST_METHOD(GetAnimationsEnabled_ReturnsBoolean)
{
bool result = GetAnimationsEnabled();
// Should return a valid boolean
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(GetAnimationsEnabled_ConsistentResults)
{
// Multiple calls should return consistent results
bool result1 = GetAnimationsEnabled();
bool result2 = GetAnimationsEnabled();
bool result3 = GetAnimationsEnabled();
Assert::AreEqual(result1, result2);
Assert::AreEqual(result2, result3);
}
TEST_METHOD(GetAnimationsEnabled_DoesNotCrash)
{
// Call multiple times to ensure stability
for (int i = 0; i < 100; ++i)
{
GetAnimationsEnabled();
}
Assert::IsTrue(true);
}
TEST_METHOD(GetAnimationsEnabled_ThreadSafe)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&successCount]() {
for (int j = 0; j < 10; ++j)
{
GetAnimationsEnabled();
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(100, successCount.load());
}
};
}

View File

@@ -0,0 +1,146 @@
#include "pch.h"
#include "TestHelpers.h"
#include <MsiUtils.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(MsiUtilsTests)
{
public:
// GetMsiPackageInstalledPath tests
TEST_METHOD(GetMsiPackageInstalledPath_PerUser_DoesNotCrash)
{
auto result = GetMsiPackageInstalledPath(true);
// Result depends on installation state, but should not crash
Assert::IsTrue(true);
}
TEST_METHOD(GetMsiPackageInstalledPath_PerMachine_DoesNotCrash)
{
auto result = GetMsiPackageInstalledPath(false);
// Result depends on installation state, but should not crash
Assert::IsTrue(true);
}
TEST_METHOD(GetMsiPackageInstalledPath_ConsistentResults)
{
auto result1 = GetMsiPackageInstalledPath(true);
auto result2 = GetMsiPackageInstalledPath(true);
// Results should be consistent
Assert::AreEqual(result1.has_value(), result2.has_value());
if (result1.has_value() && result2.has_value())
{
Assert::AreEqual(*result1, *result2);
}
}
TEST_METHOD(GetMsiPackageInstalledPath_PerUserVsPerMachine_MayDiffer)
{
auto perUser = GetMsiPackageInstalledPath(true);
auto perMachine = GetMsiPackageInstalledPath(false);
// These may or may not be equal depending on installation
// Just verify they don't crash
Assert::IsTrue(true);
}
// GetMsiPackagePath tests
TEST_METHOD(GetMsiPackagePath_DoesNotCrash)
{
auto result = GetMsiPackagePath();
// Result depends on installation state, but should not crash
Assert::IsTrue(true);
}
TEST_METHOD(GetMsiPackagePath_ConsistentResults)
{
auto result1 = GetMsiPackagePath();
auto result2 = GetMsiPackagePath();
// Results should be consistent
Assert::AreEqual(result1, result2);
}
// Thread safety tests
TEST_METHOD(GetMsiPackageInstalledPath_ThreadSafe)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 5; ++i)
{
threads.emplace_back([&successCount]() {
for (int j = 0; j < 5; ++j)
{
GetMsiPackageInstalledPath(j % 2 == 0);
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(25, successCount.load());
}
TEST_METHOD(GetMsiPackagePath_ThreadSafe)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 5; ++i)
{
threads.emplace_back([&successCount]() {
for (int j = 0; j < 5; ++j)
{
GetMsiPackagePath();
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(25, successCount.load());
}
// Return value format tests
TEST_METHOD(GetMsiPackageInstalledPath_ReturnsValidPathOrEmpty)
{
auto path = GetMsiPackageInstalledPath(true);
if (path.has_value() && !path->empty())
{
// If a path is returned, it should contain backslash or be a valid path format
Assert::IsTrue(path->find(L'\\') != std::wstring::npos ||
path->find(L'/') != std::wstring::npos ||
path->length() >= 2); // At minimum drive letter + colon
}
// No value or empty is also valid (not installed)
Assert::IsTrue(true);
}
TEST_METHOD(GetMsiPackagePath_ReturnsValidPathOrEmpty)
{
auto path = GetMsiPackagePath();
if (!path.empty())
{
// If a path is returned, it should be a valid path format
Assert::IsTrue(path.find(L'\\') != std::wstring::npos ||
path.find(L'/') != std::wstring::npos ||
path.length() >= 2);
}
Assert::IsTrue(true);
}
};
}

View File

@@ -0,0 +1,107 @@
#include "pch.h"
#include "TestHelpers.h"
#include <os-detect.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(OsDetectTests)
{
public:
// IsAPIContractVxAvailable tests
TEST_METHOD(IsAPIContractV8Available_ReturnsBoolean)
{
// This test verifies the function runs without crashing
// The actual result depends on the OS version
bool result = IsAPIContractV8Available();
// Result is either true or false, both are valid
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(IsAPIContractVxAvailable_V1_ReturnsTrue)
{
// API contract v1 should be available on any modern Windows
bool result = IsAPIContractVxAvailable<1>();
Assert::IsTrue(result);
}
TEST_METHOD(IsAPIContractVxAvailable_V5_ReturnsBooleanConsistently)
{
// Call multiple times to verify caching works correctly
bool result1 = IsAPIContractVxAvailable<5>();
bool result2 = IsAPIContractVxAvailable<5>();
bool result3 = IsAPIContractVxAvailable<5>();
Assert::AreEqual(result1, result2);
Assert::AreEqual(result2, result3);
}
TEST_METHOD(IsAPIContractVxAvailable_V10_ReturnsBoolean)
{
bool result = IsAPIContractVxAvailable<10>();
// Result depends on Windows version, but should not crash
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(IsAPIContractVxAvailable_V15_ReturnsBoolean)
{
bool result = IsAPIContractVxAvailable<15>();
// Higher API versions, may or may not be available
Assert::IsTrue(result == true || result == false);
}
// Is19H1OrHigher tests
TEST_METHOD(Is19H1OrHigher_ReturnsBoolean)
{
bool result = Is19H1OrHigher();
// Result depends on OS version, but should not crash
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(Is19H1OrHigher_ReturnsSameAsV8Contract)
{
// Is19H1OrHigher is implemented as IsAPIContractV8Available
bool is19H1 = Is19H1OrHigher();
bool isV8 = IsAPIContractV8Available();
Assert::AreEqual(is19H1, isV8);
}
TEST_METHOD(Is19H1OrHigher_ConsistentAcrossMultipleCalls)
{
bool result1 = Is19H1OrHigher();
bool result2 = Is19H1OrHigher();
bool result3 = Is19H1OrHigher();
Assert::AreEqual(result1, result2);
Assert::AreEqual(result2, result3);
}
// Static caching behavior tests
TEST_METHOD(StaticCaching_DifferentContractVersions_IndependentResults)
{
// Each template instantiation has its own static variable
bool v1 = IsAPIContractVxAvailable<1>();
(void)v1; // Suppress unused variable warning
// v1 should be true on any modern Windows
Assert::IsTrue(v1);
}
// Performance test (optional - verifies caching)
TEST_METHOD(Performance_MultipleCallsAreFast)
{
// The static caching should make subsequent calls very fast
auto start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < 10000; ++i)
{
Is19H1OrHigher();
}
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
// 10000 calls should complete in well under 1 second due to caching
Assert::IsTrue(duration.count() < 1000);
}
};
}

View File

@@ -0,0 +1,180 @@
#include "pch.h"
#include "TestHelpers.h"
#include <package.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace package;
namespace UnitTestsCommonUtils
{
TEST_CLASS(PackageTests)
{
public:
// IsWin11OrGreater tests
TEST_METHOD(IsWin11OrGreater_ReturnsBoolean)
{
bool result = IsWin11OrGreater();
Assert::IsTrue(result == true || result == false);
}
TEST_METHOD(IsWin11OrGreater_ConsistentResults)
{
bool result1 = IsWin11OrGreater();
bool result2 = IsWin11OrGreater();
bool result3 = IsWin11OrGreater();
Assert::AreEqual(result1, result2);
Assert::AreEqual(result2, result3);
}
// PACKAGE_VERSION struct tests
TEST_METHOD(PackageVersion_DefaultConstruction)
{
PACKAGE_VERSION version{};
Assert::AreEqual(static_cast<UINT16>(0), version.Major);
Assert::AreEqual(static_cast<UINT16>(0), version.Minor);
Assert::AreEqual(static_cast<UINT16>(0), version.Build);
Assert::AreEqual(static_cast<UINT16>(0), version.Revision);
}
TEST_METHOD(PackageVersion_Assignment)
{
PACKAGE_VERSION version{};
version.Major = 1;
version.Minor = 2;
version.Build = 3;
version.Revision = 4;
Assert::AreEqual(static_cast<UINT16>(1), version.Major);
Assert::AreEqual(static_cast<UINT16>(2), version.Minor);
Assert::AreEqual(static_cast<UINT16>(3), version.Build);
Assert::AreEqual(static_cast<UINT16>(4), version.Revision);
}
// ComInitializer tests
TEST_METHOD(ComInitializer_InitializesAndUninitializesCom)
{
{
ComInitializer comInit;
// COM should be initialized within this scope
}
// COM should be uninitialized after scope
// Verify we can initialize again
{
ComInitializer comInit2;
}
Assert::IsTrue(true);
}
TEST_METHOD(ComInitializer_MultipleInstances)
{
ComInitializer init1;
ComInitializer init2;
ComInitializer init3;
// Multiple initializations should work (COM uses reference counting)
Assert::IsTrue(true);
}
// GetRegisteredPackage tests
TEST_METHOD(GetRegisteredPackage_NonExistentPackage_ReturnsEmpty)
{
auto result = GetRegisteredPackage(L"NonExistentPackage12345", false);
// Should return empty for non-existent package
Assert::IsFalse(result.has_value());
}
TEST_METHOD(GetRegisteredPackage_EmptyName_DoesNotCrash)
{
auto result = GetRegisteredPackage(L"", false);
// Behavior may vary based on package enumeration; just ensure it doesn't crash.
Assert::IsTrue(true);
}
// IsPackageRegisteredWithPowerToysVersion tests
TEST_METHOD(IsPackageRegisteredWithPowerToysVersion_NonExistentPackage_ReturnsFalse)
{
bool result = IsPackageRegisteredWithPowerToysVersion(L"NonExistentPackage12345");
Assert::IsFalse(result);
}
TEST_METHOD(IsPackageRegisteredWithPowerToysVersion_EmptyName_ReturnsFalse)
{
bool result = IsPackageRegisteredWithPowerToysVersion(L"");
Assert::IsFalse(result);
}
// FindMsixFile tests
TEST_METHOD(FindMsixFile_NonExistentDirectory_ReturnsEmpty)
{
auto result = FindMsixFile(L"C:\\NonExistentDirectory12345", false);
Assert::IsTrue(result.empty());
}
TEST_METHOD(FindMsixFile_SystemDirectory_DoesNotCrash)
{
// System32 probably doesn't have MSIX files, but shouldn't crash
auto result = FindMsixFile(L"C:\\Windows\\System32", false);
// May or may not find files, but should not crash
Assert::IsTrue(true);
}
TEST_METHOD(FindMsixFile_RecursiveSearch_DoesNotCrash)
{
// Use temp directory which should exist
wchar_t tempPath[MAX_PATH];
GetTempPathW(MAX_PATH, tempPath);
auto result = FindMsixFile(tempPath, true);
// May or may not find files, but should not crash
Assert::IsTrue(true);
}
// GetPackageNameAndVersionFromAppx tests
TEST_METHOD(GetPackageNameAndVersionFromAppx_NonExistentFile_ReturnsFalse)
{
std::wstring name;
PACKAGE_VERSION version{};
bool result = GetPackageNameAndVersionFromAppx(L"C:\\NonExistent\\file.msix", name, version);
Assert::IsFalse(result);
}
TEST_METHOD(GetPackageNameAndVersionFromAppx_EmptyPath_ReturnsFalse)
{
std::wstring name;
PACKAGE_VERSION version{};
bool result = GetPackageNameAndVersionFromAppx(L"", name, version);
Assert::IsFalse(result);
}
// Thread safety
TEST_METHOD(IsWin11OrGreater_ThreadSafe)
{
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&successCount]() {
for (int j = 0; j < 10; ++j)
{
IsWin11OrGreater();
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(100, successCount.load());
}
};
}

View File

@@ -0,0 +1,136 @@
#include "pch.h"
#include "TestHelpers.h"
#include <processApi.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ProcessApiTests)
{
public:
TEST_METHOD(GetProcessHandlesByName_CurrentProcess_ReturnsHandles)
{
// Get current process executable name
wchar_t path[MAX_PATH];
GetModuleFileNameW(nullptr, path, MAX_PATH);
// Extract just the filename
std::wstring fullPath(path);
auto lastSlash = fullPath.rfind(L'\\');
std::wstring exeName = (lastSlash != std::wstring::npos) ?
fullPath.substr(lastSlash + 1) : fullPath;
auto handles = getProcessHandlesByName(exeName, PROCESS_QUERY_LIMITED_INFORMATION);
// Should find at least our own process
Assert::IsFalse(handles.empty());
// Handles are RAII-managed
}
TEST_METHOD(GetProcessHandlesByName_NonExistentProcess_ReturnsEmpty)
{
auto handles = getProcessHandlesByName(L"NonExistentProcess12345.exe", PROCESS_QUERY_LIMITED_INFORMATION);
Assert::IsTrue(handles.empty());
}
TEST_METHOD(GetProcessHandlesByName_EmptyName_ReturnsEmpty)
{
auto handles = getProcessHandlesByName(L"", PROCESS_QUERY_LIMITED_INFORMATION);
Assert::IsTrue(handles.empty());
}
TEST_METHOD(GetProcessHandlesByName_Explorer_ReturnsHandles)
{
// Explorer.exe should typically be running
auto handles = getProcessHandlesByName(L"explorer.exe", PROCESS_QUERY_LIMITED_INFORMATION);
// Handles are RAII-managed
// May or may not find explorer depending on system state
// Just verify it doesn't crash
Assert::IsTrue(true);
}
TEST_METHOD(GetProcessHandlesByName_CaseInsensitive_Works)
{
// Get current process name in uppercase
wchar_t path[MAX_PATH];
GetModuleFileNameW(nullptr, path, MAX_PATH);
std::wstring fullPath(path);
auto lastSlash = fullPath.rfind(L'\\');
std::wstring exeName = (lastSlash != std::wstring::npos) ?
fullPath.substr(lastSlash + 1) : fullPath;
// Convert to uppercase
std::wstring upperName = exeName;
std::transform(upperName.begin(), upperName.end(), upperName.begin(), ::towupper);
auto handles = getProcessHandlesByName(upperName, PROCESS_QUERY_LIMITED_INFORMATION);
// Handles are RAII-managed
// The function may or may not be case insensitive - just don't crash
Assert::IsTrue(true);
}
TEST_METHOD(GetProcessHandlesByName_DifferentAccessRights_Works)
{
wchar_t path[MAX_PATH];
GetModuleFileNameW(nullptr, path, MAX_PATH);
std::wstring fullPath(path);
auto lastSlash = fullPath.rfind(L'\\');
std::wstring exeName = (lastSlash != std::wstring::npos) ?
fullPath.substr(lastSlash + 1) : fullPath;
// Try with different access rights
auto handles1 = getProcessHandlesByName(exeName, PROCESS_QUERY_INFORMATION);
auto handles2 = getProcessHandlesByName(exeName, PROCESS_VM_READ);
// Handles are RAII-managed
// Just verify no crashes
Assert::IsTrue(true);
}
TEST_METHOD(GetProcessHandlesByName_SystemProcess_MayRequireElevation)
{
// System processes might require elevation
auto handles = getProcessHandlesByName(L"System", PROCESS_QUERY_LIMITED_INFORMATION);
// Handles are RAII-managed
// Just verify no crashes
Assert::IsTrue(true);
}
TEST_METHOD(GetProcessHandlesByName_ValidHandles_AreUsable)
{
wchar_t path[MAX_PATH];
GetModuleFileNameW(nullptr, path, MAX_PATH);
std::wstring fullPath(path);
auto lastSlash = fullPath.rfind(L'\\');
std::wstring exeName = (lastSlash != std::wstring::npos) ?
fullPath.substr(lastSlash + 1) : fullPath;
auto handles = getProcessHandlesByName(exeName, PROCESS_QUERY_LIMITED_INFORMATION);
bool foundValidHandle = false;
for (auto& handle : handles)
{
// Try to use the handle
DWORD exitCode;
if (GetExitCodeProcess(handle.get(), &exitCode))
{
foundValidHandle = true;
}
}
Assert::IsTrue(foundValidHandle || handles.empty());
}
};
}

View File

@@ -0,0 +1,153 @@
#include "pch.h"
#include "TestHelpers.h"
#include <process_path.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ProcessPathTests)
{
public:
// get_process_path (by PID) tests
TEST_METHOD(GetProcessPath_CurrentProcess_ReturnsPath)
{
DWORD pid = GetCurrentProcessId();
auto path = get_process_path(pid);
Assert::IsFalse(path.empty());
Assert::IsTrue(path.find(L".exe") != std::wstring::npos ||
path.find(L".dll") != std::wstring::npos);
}
TEST_METHOD(GetProcessPath_InvalidPid_ReturnsEmpty)
{
DWORD invalidPid = 0xFFFFFFFF;
auto path = get_process_path(invalidPid);
// Should return empty for invalid PID
Assert::IsTrue(path.empty());
}
TEST_METHOD(GetProcessPath_ZeroPid_ReturnsEmpty)
{
auto path = get_process_path(static_cast<DWORD>(0));
// PID 0 is the System Idle Process, might return empty or a path
// Just verify it doesn't crash
Assert::IsTrue(true);
}
TEST_METHOD(GetProcessPath_SystemPid_DoesNotCrash)
{
// PID 4 is typically the System process
auto path = get_process_path(static_cast<DWORD>(4));
// May return empty due to access rights, but shouldn't crash
Assert::IsTrue(true);
}
// get_module_filename tests
TEST_METHOD(GetModuleFilename_NullModule_ReturnsExePath)
{
auto path = get_module_filename(nullptr);
Assert::IsFalse(path.empty());
Assert::IsTrue(path.find(L".exe") != std::wstring::npos ||
path.find(L".dll") != std::wstring::npos);
}
TEST_METHOD(GetModuleFilename_Kernel32_ReturnsPath)
{
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
Assert::IsNotNull(kernel32);
auto path = get_module_filename(kernel32);
Assert::IsFalse(path.empty());
// Should contain kernel32 (case insensitive check)
std::wstring lowerPath = path;
std::transform(lowerPath.begin(), lowerPath.end(), lowerPath.begin(), ::towlower);
Assert::IsTrue(lowerPath.find(L"kernel32") != std::wstring::npos);
}
TEST_METHOD(GetModuleFilename_InvalidModule_ReturnsEmpty)
{
auto path = get_module_filename(reinterpret_cast<HMODULE>(0x12345678));
// Invalid module should return empty
Assert::IsTrue(path.empty());
}
// get_module_folderpath tests
TEST_METHOD(GetModuleFolderpath_NullModule_ReturnsFolder)
{
auto folder = get_module_folderpath(nullptr, true);
Assert::IsFalse(folder.empty());
// Should not end with .exe when removeFilename is true
Assert::IsTrue(folder.find(L".exe") == std::wstring::npos);
// Should end with backslash or be a valid folder path
Assert::IsTrue(folder.back() == L'\\' || folder.find(L"\\") != std::wstring::npos);
}
TEST_METHOD(GetModuleFolderpath_KeepFilename_ReturnsFullPath)
{
auto fullPath = get_module_folderpath(nullptr, false);
Assert::IsFalse(fullPath.empty());
// Should contain .exe or .dll when not removing filename
Assert::IsTrue(fullPath.find(L".exe") != std::wstring::npos ||
fullPath.find(L".dll") != std::wstring::npos);
}
TEST_METHOD(GetModuleFolderpath_Kernel32_ReturnsSystem32)
{
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
Assert::IsNotNull(kernel32);
auto folder = get_module_folderpath(kernel32, true);
Assert::IsFalse(folder.empty());
// Should be in system32 folder
std::wstring lowerPath = folder;
std::transform(lowerPath.begin(), lowerPath.end(), lowerPath.begin(), ::towlower);
Assert::IsTrue(lowerPath.find(L"system32") != std::wstring::npos ||
lowerPath.find(L"syswow64") != std::wstring::npos);
}
// get_process_path (by HWND) tests
TEST_METHOD(GetProcessPath_DesktopWindow_ReturnsPath)
{
HWND desktop = GetDesktopWindow();
Assert::IsNotNull(desktop);
auto path = get_process_path(desktop);
// Desktop window should return a path
// (could be explorer.exe or empty depending on system)
Assert::IsTrue(true); // Just verify it doesn't crash
}
TEST_METHOD(GetProcessPath_InvalidHwnd_ReturnsEmpty)
{
auto path = get_process_path(reinterpret_cast<HWND>(0x12345678));
Assert::IsTrue(path.empty());
}
TEST_METHOD(GetProcessPath_NullHwnd_ReturnsEmpty)
{
auto path = get_process_path(static_cast<HWND>(nullptr));
Assert::IsTrue(path.empty());
}
// Consistency tests
TEST_METHOD(Consistency_ModuleFilenameAndFolderpath_AreRelated)
{
auto fullPath = get_module_filename(nullptr);
auto folder = get_module_folderpath(nullptr, true);
Assert::IsFalse(fullPath.empty());
Assert::IsFalse(folder.empty());
// Full path should start with the folder
Assert::IsTrue(fullPath.find(folder) == 0 || folder.find(fullPath.substr(0, folder.length())) == 0);
}
};
}

View File

@@ -0,0 +1,127 @@
#include "pch.h"
#include "TestHelpers.h"
#include <ProcessWaiter.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace ProcessWaiter;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ProcessWaiterTests)
{
public:
TEST_METHOD(OnProcessTerminate_InvalidPid_DoesNotCrash)
{
std::atomic<bool> called{ false };
// Use a very unlikely PID (negative value as string will fail conversion)
OnProcessTerminate(L"invalid", [&called](DWORD) {
called = true;
});
// Wait briefly
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// Should not crash, callback may or may not be called depending on implementation
Assert::IsTrue(true);
}
TEST_METHOD(OnProcessTerminate_NonExistentPid_DoesNotCrash)
{
std::atomic<bool> called{ false };
// Use a PID that likely doesn't exist
OnProcessTerminate(L"999999999", [&called](DWORD) {
called = true;
});
// Wait briefly
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// Should not crash
Assert::IsTrue(true);
}
TEST_METHOD(OnProcessTerminate_ZeroPid_DoesNotCrash)
{
std::atomic<bool> called{ false };
OnProcessTerminate(L"0", [&called](DWORD) {
called = true;
});
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Assert::IsTrue(true);
}
TEST_METHOD(OnProcessTerminate_CurrentProcessPid_DoesNotTerminate)
{
std::atomic<bool> called{ false };
// Use current process PID - it shouldn't terminate during test
std::wstring pid = std::to_wstring(GetCurrentProcessId());
OnProcessTerminate(pid, [&called](DWORD) {
called = true;
});
// Wait briefly - current process should not terminate
std::this_thread::sleep_for(std::chrono::milliseconds(200));
// Callback should not have been called since process is still running
Assert::IsFalse(called);
}
TEST_METHOD(OnProcessTerminate_EmptyCallback_DoesNotCrash)
{
// Test with an empty function
OnProcessTerminate(L"999999999", std::function<void(DWORD)>());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Assert::IsTrue(true);
}
TEST_METHOD(OnProcessTerminate_MultipleCallsForSamePid_DoesNotCrash)
{
std::atomic<int> counter{ 0 };
std::wstring pid = std::to_wstring(GetCurrentProcessId());
// Multiple waits on same (running) process
for (int i = 0; i < 5; ++i)
{
OnProcessTerminate(pid, [&counter](DWORD) {
counter++;
});
}
std::this_thread::sleep_for(std::chrono::milliseconds(200));
// None should have been called since process is running
Assert::AreEqual(0, counter.load());
}
TEST_METHOD(OnProcessTerminate_NegativeNumberString_DoesNotCrash)
{
std::atomic<bool> called{ false };
OnProcessTerminate(L"-1", [&called](DWORD) {
called = true;
});
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Assert::IsTrue(true);
}
TEST_METHOD(OnProcessTerminate_LargeNumber_DoesNotCrash)
{
std::atomic<bool> called{ false };
OnProcessTerminate(L"18446744073709551615", [&called](DWORD) {
called = true;
});
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Assert::IsTrue(true);
}
};
}

View File

@@ -0,0 +1,61 @@
#include "pch.h"
#include "TestHelpers.h"
#include <registry.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(RegistryTests)
{
public:
// Note: These tests use HKCU which doesn't require elevation
TEST_METHOD(InstallScope_Registry_CanReadAndWrite)
{
TestHelpers::TestRegistryKey testKey(L"RegistryTest");
Assert::IsTrue(testKey.isValid());
// Write a test value
Assert::IsTrue(testKey.setStringValue(L"TestValue", L"TestData"));
Assert::IsTrue(testKey.setDwordValue(L"TestDword", 42));
}
TEST_METHOD(Registry_ValueChange_StringValue)
{
registry::ValueChange change{ HKEY_CURRENT_USER, L"Software\\PowerToys\\Test", L"TestValue", std::wstring{ L"TestData" } };
Assert::AreEqual(std::wstring(L"Software\\PowerToys\\Test"), change.path);
Assert::IsTrue(change.name.has_value());
Assert::AreEqual(std::wstring(L"TestValue"), *change.name);
Assert::AreEqual(std::wstring(L"TestData"), std::get<std::wstring>(change.value));
}
TEST_METHOD(Registry_ValueChange_DwordValue)
{
registry::ValueChange change{ HKEY_CURRENT_USER, L"Software\\PowerToys\\Test", L"TestDword", static_cast<DWORD>(42) };
Assert::AreEqual(std::wstring(L"Software\\PowerToys\\Test"), change.path);
Assert::IsTrue(change.name.has_value());
Assert::AreEqual(std::wstring(L"TestDword"), *change.name);
Assert::AreEqual(static_cast<DWORD>(42), std::get<DWORD>(change.value));
}
TEST_METHOD(Registry_ChangeSet_AddChanges)
{
registry::ChangeSet changeSet;
changeSet.changes.push_back({ HKEY_CURRENT_USER, L"Software\\PowerToys\\Test", L"Value1", std::wstring{ L"Data1" } });
changeSet.changes.push_back({ HKEY_CURRENT_USER, L"Software\\PowerToys\\Test", L"Value2", static_cast<DWORD>(123) });
Assert::AreEqual(static_cast<size_t>(2), changeSet.changes.size());
}
TEST_METHOD(InstallScope_GetCurrentInstallScope_ReturnsValidValue)
{
auto scope = registry::install_scope::get_current_install_scope();
Assert::IsTrue(scope == registry::install_scope::InstallScope::PerMachine ||
scope == registry::install_scope::InstallScope::PerUser);
}
};
}

View File

@@ -0,0 +1,144 @@
#include "pch.h"
#include "TestHelpers.h"
#include <resources.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(ResourcesTests)
{
public:
// get_resource_string tests with current module
TEST_METHOD(GetResourceString_NonExistentId_ReturnsFallback)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
auto result = get_resource_string(99999, instance, L"fallback");
Assert::AreEqual(std::wstring(L"fallback"), result);
}
TEST_METHOD(GetResourceString_NullInstance_UsesFallback)
{
auto result = get_resource_string(99999, nullptr, L"fallback");
// Should return fallback or empty string
Assert::IsTrue(result == L"fallback" || result.empty());
}
TEST_METHOD(GetResourceString_EmptyFallback_ReturnsEmpty)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
auto result = get_resource_string(99999, instance, L"");
Assert::IsTrue(result.empty());
}
// get_english_fallback_string tests
TEST_METHOD(GetEnglishFallbackString_NonExistentId_ReturnsEmpty)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
auto result = get_english_fallback_string(99999, instance);
// Should return empty or the resource if it exists
Assert::IsTrue(true); // Just verify no crash
}
TEST_METHOD(GetEnglishFallbackString_NullInstance_DoesNotCrash)
{
auto result = get_english_fallback_string(99999, nullptr);
Assert::IsTrue(true); // Just verify no crash
}
// get_resource_string_language_override tests
TEST_METHOD(GetResourceStringLanguageOverride_NonExistentId_ReturnsEmpty)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
auto result = get_resource_string_language_override(99999, instance);
// Should return empty for non-existent resource
Assert::IsTrue(result.empty() || !result.empty()); // Valid either way
}
TEST_METHOD(GetResourceStringLanguageOverride_NullInstance_DoesNotCrash)
{
auto result = get_resource_string_language_override(99999, nullptr);
Assert::IsTrue(true);
}
// Thread safety tests
TEST_METHOD(GetResourceString_ThreadSafe)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
std::vector<std::thread> threads;
std::atomic<int> successCount{ 0 };
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&successCount, instance]() {
for (int j = 0; j < 10; ++j)
{
get_resource_string(99999, instance, L"fallback");
successCount++;
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(100, successCount.load());
}
// Kernel32 resource tests (has known resources)
TEST_METHOD(GetResourceString_Kernel32_DoesNotCrash)
{
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
if (kernel32)
{
// Kernel32 has resources, but we don't know exact IDs
// Just verify it doesn't crash
get_resource_string(1, kernel32, L"fallback");
get_resource_string(100, kernel32, L"fallback");
get_resource_string(1000, kernel32, L"fallback");
}
Assert::IsTrue(true);
}
// Performance test
TEST_METHOD(GetResourceString_Performance_Acceptable)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
auto start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < 1000; ++i)
{
get_resource_string(99999, instance, L"fallback");
}
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
// 1000 lookups should complete in under 1 second
Assert::IsTrue(duration.count() < 1000);
}
// Edge case tests
TEST_METHOD(GetResourceString_ZeroId_DoesNotCrash)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
auto result = get_resource_string(0, instance, L"fallback");
Assert::IsTrue(true);
}
TEST_METHOD(GetResourceString_MaxUintId_DoesNotCrash)
{
HINSTANCE instance = GetModuleHandleW(nullptr);
auto result = get_resource_string(UINT_MAX, instance, L"fallback");
Assert::IsTrue(true);
}
};
}

View File

@@ -0,0 +1,286 @@
#include "pch.h"
#include "TestHelpers.h"
#include <serialized.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(SerializedTests)
{
public:
// Basic Read tests
TEST_METHOD(Read_DefaultState_ReturnsDefaultValue)
{
Serialized<int> s;
int value = -1;
s.Read([&value](const int& v) {
value = v;
});
Assert::AreEqual(0, value); // Default constructed int is 0
}
TEST_METHOD(Read_StringType_ReturnsEmpty)
{
Serialized<std::string> s;
std::string value = "initial";
s.Read([&value](const std::string& v) {
value = v;
});
Assert::AreEqual(std::string(""), value);
}
// Basic Access tests
TEST_METHOD(Access_ModifyValue_ValueIsModified)
{
Serialized<int> s;
s.Access([](int& v) {
v = 42;
});
int value = 0;
s.Read([&value](const int& v) {
value = v;
});
Assert::AreEqual(42, value);
}
TEST_METHOD(Access_ModifyString_StringIsModified)
{
Serialized<std::string> s;
s.Access([](std::string& v) {
v = "hello";
});
std::string value;
s.Read([&value](const std::string& v) {
value = v;
});
Assert::AreEqual(std::string("hello"), value);
}
TEST_METHOD(Access_MultipleModifications_LastValuePersists)
{
Serialized<int> s;
s.Access([](int& v) { v = 1; });
s.Access([](int& v) { v = 2; });
s.Access([](int& v) { v = 3; });
int value = 0;
s.Read([&value](const int& v) {
value = v;
});
Assert::AreEqual(3, value);
}
// Reset tests
TEST_METHOD(Reset_AfterModification_ReturnsDefault)
{
Serialized<int> s;
s.Access([](int& v) { v = 42; });
s.Reset();
int value = -1;
s.Read([&value](const int& v) {
value = v;
});
Assert::AreEqual(0, value);
}
TEST_METHOD(Reset_String_ReturnsEmpty)
{
Serialized<std::string> s;
s.Access([](std::string& v) { v = "hello"; });
s.Reset();
std::string value = "initial";
s.Read([&value](const std::string& v) {
value = v;
});
Assert::AreEqual(std::string(""), value);
}
// Complex type tests
TEST_METHOD(Serialized_VectorType_Works)
{
Serialized<std::vector<int>> s;
s.Access([](std::vector<int>& v) {
v.push_back(1);
v.push_back(2);
v.push_back(3);
});
size_t size = 0;
int sum = 0;
s.Read([&size, &sum](const std::vector<int>& v) {
size = v.size();
for (int i : v) sum += i;
});
Assert::AreEqual(static_cast<size_t>(3), size);
Assert::AreEqual(6, sum);
}
TEST_METHOD(Serialized_MapType_Works)
{
Serialized<std::map<std::string, int>> s;
s.Access([](std::map<std::string, int>& v) {
v["one"] = 1;
v["two"] = 2;
});
int value = 0;
s.Read([&value](const std::map<std::string, int>& v) {
auto it = v.find("two");
if (it != v.end()) {
value = it->second;
}
});
Assert::AreEqual(2, value);
}
// Thread safety tests
TEST_METHOD(ThreadSafety_ConcurrentReads_NoDataRace)
{
Serialized<int> s;
s.Access([](int& v) { v = 42; });
std::atomic<int> readCount{ 0 };
std::vector<std::thread> threads;
for (int i = 0; i < 10; ++i)
{
threads.emplace_back([&s, &readCount]() {
for (int j = 0; j < 100; ++j)
{
s.Read([&readCount](const int& v) {
if (v == 42) {
readCount++;
}
});
}
});
}
for (auto& t : threads)
{
t.join();
}
Assert::AreEqual(1000, readCount.load());
}
TEST_METHOD(ThreadSafety_ConcurrentAccessAndRead_NoDataRace)
{
Serialized<int> s;
std::atomic<bool> done{ false };
std::atomic<int> accessCount{ 0 };
std::atomic<int> readersReady{ 0 };
std::atomic<bool> start{ false };
// Writer thread
std::thread writer([&s, &done, &accessCount, &readersReady, &start]() {
while (readersReady.load() < 5)
{
std::this_thread::yield();
}
start = true;
for (int i = 0; i < 100; ++i)
{
s.Access([i](int& v) {
v = i;
});
accessCount++;
}
done = true;
});
// Reader threads
std::vector<std::thread> readers;
std::atomic<int> readAttempts{ 0 };
for (int i = 0; i < 5; ++i)
{
readers.emplace_back([&s, &done, &readAttempts, &readersReady, &start]() {
readersReady++;
while (!start)
{
std::this_thread::yield();
}
while (!done)
{
s.Read([](const int& v) {
// Just read the value
(void)v;
});
readAttempts++;
}
});
}
writer.join();
for (auto& t : readers)
{
t.join();
}
// Verify all access calls completed
Assert::AreEqual(100, accessCount.load());
// Verify reads happened
Assert::IsTrue(readAttempts > 0);
}
// Struct type test
TEST_METHOD(Serialized_StructType_Works)
{
struct TestStruct
{
int x = 0;
std::string name;
};
Serialized<TestStruct> s;
s.Access([](TestStruct& v) {
v.x = 10;
v.name = "test";
});
int x = 0;
std::string name;
s.Read([&x, &name](const TestStruct& v) {
x = v.x;
name = v.name;
});
Assert::AreEqual(10, x);
Assert::AreEqual(std::string("test"), name);
}
TEST_METHOD(Reset_StructType_ResetsToDefault)
{
struct TestStruct
{
int x = 0;
std::string name;
};
Serialized<TestStruct> s;
s.Access([](TestStruct& v) {
v.x = 10;
v.name = "test";
});
s.Reset();
int x = -1;
std::string name = "not empty";
s.Read([&x, &name](const TestStruct& v) {
x = v.x;
name = v.name;
});
Assert::AreEqual(0, x);
Assert::AreEqual(std::string(""), name);
}
};
}

View File

@@ -0,0 +1,283 @@
#include "pch.h"
#include "TestHelpers.h"
#include <string_utils.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(StringUtilsTests)
{
public:
// left_trim tests
TEST_METHOD(LeftTrim_EmptyString_ReturnsEmpty)
{
std::string_view input = "";
auto result = left_trim(input);
Assert::AreEqual(std::string_view(""), result);
}
TEST_METHOD(LeftTrim_NoWhitespace_ReturnsOriginal)
{
std::string_view input = "hello";
auto result = left_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(LeftTrim_LeadingSpaces_TrimsSpaces)
{
std::string_view input = " hello";
auto result = left_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(LeftTrim_LeadingTabs_TrimsTabs)
{
std::string_view input = "\t\thello";
auto result = left_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(LeftTrim_LeadingNewlines_TrimsNewlines)
{
std::string_view input = "\r\n\nhello";
auto result = left_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(LeftTrim_MixedWhitespace_TrimsAll)
{
std::string_view input = " \t\r\nhello";
auto result = left_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(LeftTrim_TrailingWhitespace_PreservesTrailing)
{
std::string_view input = " hello ";
auto result = left_trim(input);
Assert::AreEqual(std::string_view("hello "), result);
}
TEST_METHOD(LeftTrim_OnlyWhitespace_ReturnsEmpty)
{
std::string_view input = " \t\r\n";
auto result = left_trim(input);
Assert::AreEqual(std::string_view(""), result);
}
TEST_METHOD(LeftTrim_CustomChars_TrimsSpecified)
{
std::string_view input = "xxxhello";
auto result = left_trim(input, std::string_view("x"));
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(LeftTrim_WideString_Works)
{
std::wstring_view input = L" hello";
auto result = left_trim(input);
Assert::AreEqual(std::wstring_view(L"hello"), result);
}
// right_trim tests
TEST_METHOD(RightTrim_EmptyString_ReturnsEmpty)
{
std::string_view input = "";
auto result = right_trim(input);
Assert::AreEqual(std::string_view(""), result);
}
TEST_METHOD(RightTrim_NoWhitespace_ReturnsOriginal)
{
std::string_view input = "hello";
auto result = right_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(RightTrim_TrailingSpaces_TrimsSpaces)
{
std::string_view input = "hello ";
auto result = right_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(RightTrim_TrailingTabs_TrimsTabs)
{
std::string_view input = "hello\t\t";
auto result = right_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(RightTrim_TrailingNewlines_TrimsNewlines)
{
std::string_view input = "hello\r\n\n";
auto result = right_trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(RightTrim_LeadingWhitespace_PreservesLeading)
{
std::string_view input = " hello ";
auto result = right_trim(input);
Assert::AreEqual(std::string_view(" hello"), result);
}
TEST_METHOD(RightTrim_OnlyWhitespace_ReturnsEmpty)
{
std::string_view input = " \t\r\n";
auto result = right_trim(input);
Assert::AreEqual(std::string_view(""), result);
}
TEST_METHOD(RightTrim_CustomChars_TrimsSpecified)
{
std::string_view input = "helloxxx";
auto result = right_trim(input, std::string_view("x"));
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(RightTrim_WideString_Works)
{
std::wstring_view input = L"hello ";
auto result = right_trim(input);
Assert::AreEqual(std::wstring_view(L"hello"), result);
}
// trim tests
TEST_METHOD(Trim_EmptyString_ReturnsEmpty)
{
std::string_view input = "";
auto result = trim(input);
Assert::AreEqual(std::string_view(""), result);
}
TEST_METHOD(Trim_NoWhitespace_ReturnsOriginal)
{
std::string_view input = "hello";
auto result = trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(Trim_BothSides_TrimsBoth)
{
std::string_view input = " hello ";
auto result = trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(Trim_MixedWhitespace_TrimsAll)
{
std::string_view input = " \t\r\nhello \t\r\n";
auto result = trim(input);
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(Trim_InternalWhitespace_Preserved)
{
std::string_view input = " hello world ";
auto result = trim(input);
Assert::AreEqual(std::string_view("hello world"), result);
}
TEST_METHOD(Trim_OnlyWhitespace_ReturnsEmpty)
{
std::string_view input = " \t\r\n ";
auto result = trim(input);
Assert::AreEqual(std::string_view(""), result);
}
TEST_METHOD(Trim_CustomChars_TrimsSpecified)
{
std::string_view input = "xxxhelloxxx";
auto result = trim(input, std::string_view("x"));
Assert::AreEqual(std::string_view("hello"), result);
}
TEST_METHOD(Trim_WideString_Works)
{
std::wstring_view input = L" hello ";
auto result = trim(input);
Assert::AreEqual(std::wstring_view(L"hello"), result);
}
// replace_chars tests
TEST_METHOD(ReplaceChars_EmptyString_NoChange)
{
std::string s = "";
replace_chars(s, std::string_view("abc"), 'x');
Assert::AreEqual(std::string(""), s);
}
TEST_METHOD(ReplaceChars_NoMatchingChars_NoChange)
{
std::string s = "hello";
replace_chars(s, std::string_view("xyz"), '_');
Assert::AreEqual(std::string("hello"), s);
}
TEST_METHOD(ReplaceChars_SingleChar_Replaces)
{
std::string s = "hello";
replace_chars(s, std::string_view("l"), '_');
Assert::AreEqual(std::string("he__o"), s);
}
TEST_METHOD(ReplaceChars_MultipleChars_ReplacesAll)
{
std::string s = "hello world";
replace_chars(s, std::string_view("lo"), '_');
Assert::AreEqual(std::string("he___ w_r_d"), s);
}
TEST_METHOD(ReplaceChars_WideString_Works)
{
std::wstring s = L"hello";
replace_chars(s, std::wstring_view(L"l"), L'_');
Assert::AreEqual(std::wstring(L"he__o"), s);
}
// unwide tests
TEST_METHOD(Unwide_EmptyString_ReturnsEmpty)
{
std::wstring input = L"";
auto result = unwide(input);
Assert::AreEqual(std::string(""), result);
}
TEST_METHOD(Unwide_AsciiString_Converts)
{
std::wstring input = L"hello";
auto result = unwide(input);
Assert::AreEqual(std::string("hello"), result);
}
TEST_METHOD(Unwide_WithNumbers_Converts)
{
std::wstring input = L"test123";
auto result = unwide(input);
Assert::AreEqual(std::string("test123"), result);
}
TEST_METHOD(Unwide_WithSpecialChars_Converts)
{
std::wstring input = L"test!@#$%";
auto result = unwide(input);
Assert::AreEqual(std::string("test!@#$%"), result);
}
TEST_METHOD(Unwide_MixedCase_PreservesCase)
{
std::wstring input = L"HeLLo WoRLd";
auto result = unwide(input);
Assert::AreEqual(std::string("HeLLo WoRLd"), result);
}
TEST_METHOD(Unwide_LongString_Works)
{
std::wstring input = L"This is a longer string with multiple words and punctuation!";
auto result = unwide(input);
Assert::AreEqual(std::string("This is a longer string with multiple words and punctuation!"), result);
}
};
}

View File

@@ -0,0 +1,192 @@
#pragma once
#include "pch.h"
#include <string>
#include <filesystem>
#include <fstream>
#include <random>
namespace TestHelpers
{
// RAII helper for creating and cleaning up temporary files
class TempFile
{
public:
TempFile(const std::wstring& content = L"", const std::wstring& extension = L".txt")
{
wchar_t tempPath[MAX_PATH];
GetTempPathW(MAX_PATH, tempPath);
// Generate a unique filename
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(10000, 99999);
m_path = std::wstring(tempPath) + L"test_" + std::to_wstring(dis(gen)) + extension;
if (!content.empty())
{
std::wofstream file(m_path);
file << content;
}
}
~TempFile()
{
if (std::filesystem::exists(m_path))
{
std::filesystem::remove(m_path);
}
}
TempFile(const TempFile&) = delete;
TempFile& operator=(const TempFile&) = delete;
const std::wstring& path() const { return m_path; }
void write(const std::string& content)
{
std::ofstream file(m_path, std::ios::binary);
file << content;
}
void write(const std::wstring& content)
{
std::wofstream file(m_path);
file << content;
}
std::wstring read()
{
std::wifstream file(m_path);
return std::wstring((std::istreambuf_iterator<wchar_t>(file)),
std::istreambuf_iterator<wchar_t>());
}
private:
std::wstring m_path;
};
// RAII helper for creating and cleaning up temporary directories
class TempDirectory
{
public:
TempDirectory()
{
wchar_t tempPath[MAX_PATH];
GetTempPathW(MAX_PATH, tempPath);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(10000, 99999);
m_path = std::wstring(tempPath) + L"testdir_" + std::to_wstring(dis(gen));
std::filesystem::create_directories(m_path);
}
~TempDirectory()
{
if (std::filesystem::exists(m_path))
{
std::filesystem::remove_all(m_path);
}
}
TempDirectory(const TempDirectory&) = delete;
TempDirectory& operator=(const TempDirectory&) = delete;
const std::wstring& path() const { return m_path; }
private:
std::wstring m_path;
};
// Registry test key path - use HKCU for non-elevated tests
inline const std::wstring TestRegistryPath = L"Software\\PowerToys\\UnitTests";
// RAII helper for registry key creation/cleanup
class TestRegistryKey
{
public:
TestRegistryKey(const std::wstring& subKey = L"")
{
m_path = TestRegistryPath;
if (!subKey.empty())
{
m_path += L"\\" + subKey;
}
HKEY key;
if (RegCreateKeyExW(HKEY_CURRENT_USER, m_path.c_str(), 0, nullptr,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
&key, nullptr) == ERROR_SUCCESS)
{
RegCloseKey(key);
m_created = true;
}
}
~TestRegistryKey()
{
if (m_created)
{
RegDeleteTreeW(HKEY_CURRENT_USER, m_path.c_str());
}
}
TestRegistryKey(const TestRegistryKey&) = delete;
TestRegistryKey& operator=(const TestRegistryKey&) = delete;
bool isValid() const { return m_created; }
const std::wstring& path() const { return m_path; }
bool setStringValue(const std::wstring& name, const std::wstring& value)
{
HKEY key;
if (RegOpenKeyExW(HKEY_CURRENT_USER, m_path.c_str(), 0, KEY_SET_VALUE, &key) != ERROR_SUCCESS)
{
return false;
}
auto result = RegSetValueExW(key, name.c_str(), 0, REG_SZ,
reinterpret_cast<const BYTE*>(value.c_str()),
static_cast<DWORD>((value.length() + 1) * sizeof(wchar_t)));
RegCloseKey(key);
return result == ERROR_SUCCESS;
}
bool setDwordValue(const std::wstring& name, DWORD value)
{
HKEY key;
if (RegOpenKeyExW(HKEY_CURRENT_USER, m_path.c_str(), 0, KEY_SET_VALUE, &key) != ERROR_SUCCESS)
{
return false;
}
auto result = RegSetValueExW(key, name.c_str(), 0, REG_DWORD,
reinterpret_cast<const BYTE*>(&value), sizeof(DWORD));
RegCloseKey(key);
return result == ERROR_SUCCESS;
}
private:
std::wstring m_path;
bool m_created = false;
};
// Helper to wait for a condition with timeout
template<typename Predicate>
bool WaitFor(Predicate pred, std::chrono::milliseconds timeout = std::chrono::milliseconds(5000))
{
auto start = std::chrono::steady_clock::now();
while (!pred())
{
if (std::chrono::steady_clock::now() - start > timeout)
{
return false;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
return true;
}
}

View File

@@ -0,0 +1,14 @@
#include "pch.h"
#include <common/logger/logger.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <spdlog/sinks/null_sink.h>
std::shared_ptr<spdlog::logger> Logger::logger = spdlog::null_logger_mt("Common.Utils.UnitTests");
namespace PTSettingsHelper
{
std::wstring get_root_save_folder_location()
{
return L"";
}
}

View File

@@ -0,0 +1,336 @@
#include "pch.h"
#include "TestHelpers.h"
#include <OnThreadExecutor.h>
#include <EventWaiter.h>
#include <EventLocker.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommonUtils
{
TEST_CLASS(OnThreadExecutorTests)
{
public:
TEST_METHOD(Constructor_CreatesInstance)
{
OnThreadExecutor executor;
// Should not crash
Assert::IsTrue(true);
}
TEST_METHOD(Submit_SingleTask_Executes)
{
OnThreadExecutor executor;
std::atomic<bool> executed{ false };
auto future = executor.submit(OnThreadExecutor::task_t([&executed]() {
executed = true;
}));
future.wait();
Assert::IsTrue(executed);
}
TEST_METHOD(Submit_MultipleTasks_ExecutesAll)
{
OnThreadExecutor executor;
std::atomic<int> counter{ 0 };
std::vector<std::future<void>> futures;
for (int i = 0; i < 10; ++i)
{
futures.push_back(executor.submit(OnThreadExecutor::task_t([&counter]() {
counter++;
})));
}
for (auto& f : futures)
{
f.wait();
}
Assert::AreEqual(10, counter.load());
}
TEST_METHOD(Submit_TasksExecuteInOrder)
{
OnThreadExecutor executor;
std::vector<int> order;
std::mutex orderMutex;
std::vector<std::future<void>> futures;
for (int i = 0; i < 5; ++i)
{
futures.push_back(executor.submit(OnThreadExecutor::task_t([&order, &orderMutex, i]() {
std::lock_guard lock(orderMutex);
order.push_back(i);
})));
}
for (auto& f : futures)
{
f.wait();
}
Assert::AreEqual(static_cast<size_t>(5), order.size());
for (int i = 0; i < 5; ++i)
{
Assert::AreEqual(i, order[i]);
}
}
TEST_METHOD(Submit_TaskReturnsResult)
{
OnThreadExecutor executor;
std::atomic<int> result{ 0 };
auto future = executor.submit(OnThreadExecutor::task_t([&result]() {
result = 42;
}));
future.wait();
Assert::AreEqual(42, result.load());
}
TEST_METHOD(Cancel_ClearsPendingTasks)
{
OnThreadExecutor executor;
std::atomic<int> counter{ 0 };
// Submit a slow task first
executor.submit(OnThreadExecutor::task_t([&counter]() {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
counter++;
}));
// Submit more tasks
for (int i = 0; i < 5; ++i)
{
executor.submit(OnThreadExecutor::task_t([&counter]() {
counter++;
}));
}
// Cancel pending tasks
executor.cancel();
// Wait a bit for any running task to complete
std::this_thread::sleep_for(std::chrono::milliseconds(200));
// Not all tasks should have executed
Assert::IsTrue(counter < 6);
}
TEST_METHOD(Destructor_WaitsForCompletion)
{
std::atomic<bool> completed{ false };
std::future<void> future;
{
OnThreadExecutor executor;
future = executor.submit(OnThreadExecutor::task_t([&completed]() {
std::this_thread::sleep_for(std::chrono::milliseconds(50));
completed = true;
}));
future.wait();
} // Destructor no longer required to wait for completion
Assert::IsTrue(completed);
}
TEST_METHOD(Submit_AfterCancel_StillWorks)
{
OnThreadExecutor executor;
std::atomic<int> counter{ 0 };
executor.submit(OnThreadExecutor::task_t([&counter]() {
counter++;
}));
executor.cancel();
auto future = executor.submit(OnThreadExecutor::task_t([&counter]() {
counter = 42;
}));
future.wait();
Assert::AreEqual(42, counter.load());
}
};
TEST_CLASS(EventWaiterTests)
{
public:
TEST_METHOD(Constructor_CreatesInstance)
{
EventWaiter waiter;
Assert::IsFalse(waiter.is_listening());
}
TEST_METHOD(Start_ValidEvent_ReturnsTrue)
{
EventWaiter waiter;
bool result = waiter.start(L"TestEvent_Start", [](DWORD) {});
Assert::IsTrue(result);
Assert::IsTrue(waiter.is_listening());
waiter.stop();
}
TEST_METHOD(Start_AlreadyListening_ReturnsFalse)
{
EventWaiter waiter;
waiter.start(L"TestEvent_Double1", [](DWORD) {});
bool result = waiter.start(L"TestEvent_Double2", [](DWORD) {});
Assert::IsFalse(result);
waiter.stop();
}
TEST_METHOD(Stop_WhileListening_StopsListening)
{
EventWaiter waiter;
waiter.start(L"TestEvent_Stop", [](DWORD) {});
Assert::IsTrue(waiter.is_listening());
waiter.stop();
Assert::IsFalse(waiter.is_listening());
}
TEST_METHOD(Stop_WhenNotListening_DoesNotCrash)
{
EventWaiter waiter;
waiter.stop(); // Should not crash
Assert::IsFalse(waiter.is_listening());
}
TEST_METHOD(Stop_CalledMultipleTimes_DoesNotCrash)
{
EventWaiter waiter;
waiter.start(L"TestEvent_MultiStop", [](DWORD) {});
waiter.stop();
waiter.stop();
waiter.stop();
Assert::IsFalse(waiter.is_listening());
}
TEST_METHOD(Callback_EventSignaled_CallsCallback)
{
EventWaiter waiter;
std::atomic<bool> called{ false };
std::atomic<DWORD> errorCode{ 0xFFFFFFFF };
// Create a named event we can signal
std::wstring eventName = L"TestEvent_Callback_" + std::to_wstring(GetCurrentProcessId());
HANDLE signalEvent = CreateEventW(nullptr, FALSE, FALSE, eventName.c_str());
Assert::IsNotNull(signalEvent);
waiter.start(eventName, [&called, &errorCode](DWORD err) {
errorCode = err;
called = true;
});
// Signal the event
SetEvent(signalEvent);
// Wait for callback
bool waitResult = TestHelpers::WaitFor([&called]() { return called.load(); }, std::chrono::milliseconds(1000));
waiter.stop();
CloseHandle(signalEvent);
Assert::IsTrue(waitResult);
Assert::AreEqual(static_cast<DWORD>(ERROR_SUCCESS), errorCode.load());
}
TEST_METHOD(Destructor_StopsListening)
{
std::atomic<bool> isListening{ false };
{
EventWaiter waiter;
waiter.start(L"TestEvent_Destructor", [](DWORD) {});
isListening = waiter.is_listening();
}
// After destruction, the waiter should have stopped
Assert::IsTrue(isListening);
}
TEST_METHOD(IsListening_InitialState_ReturnsFalse)
{
EventWaiter waiter;
Assert::IsFalse(waiter.is_listening());
}
TEST_METHOD(IsListening_AfterStart_ReturnsTrue)
{
EventWaiter waiter;
waiter.start(L"TestEvent_IsListening", [](DWORD) {});
Assert::IsTrue(waiter.is_listening());
waiter.stop();
}
TEST_METHOD(IsListening_AfterStop_ReturnsFalse)
{
EventWaiter waiter;
waiter.start(L"TestEvent_AfterStop", [](DWORD) {});
waiter.stop();
Assert::IsFalse(waiter.is_listening());
}
};
TEST_CLASS(EventLockerTests)
{
public:
TEST_METHOD(Get_ValidEventName_ReturnsLocker)
{
std::wstring eventName = L"TestEventLocker_" + std::to_wstring(GetCurrentProcessId());
auto locker = EventLocker::Get(eventName);
Assert::IsTrue(locker.has_value());
}
TEST_METHOD(Get_UniqueNames_CreatesSeparateLockers)
{
auto locker1 = EventLocker::Get(L"TestEventLocker1_" + std::to_wstring(GetCurrentProcessId()));
auto locker2 = EventLocker::Get(L"TestEventLocker2_" + std::to_wstring(GetCurrentProcessId()));
Assert::IsTrue(locker1.has_value());
Assert::IsTrue(locker2.has_value());
}
TEST_METHOD(Destructor_CleansUpHandle)
{
std::wstring eventName = L"TestEventLockerCleanup_" + std::to_wstring(GetCurrentProcessId());
{
auto locker = EventLocker::Get(eventName);
Assert::IsTrue(locker.has_value());
}
// After destruction, the event should be cleaned up
// Creating a new one should succeed
auto newLocker = EventLocker::Get(eventName);
Assert::IsTrue(newLocker.has_value());
}
TEST_METHOD(MoveConstructor_TransfersOwnership)
{
std::wstring eventName = L"TestEventLockerMove_" + std::to_wstring(GetCurrentProcessId());
auto locker1 = EventLocker::Get(eventName);
Assert::IsTrue(locker1.has_value());
EventLocker locker2 = std::move(*locker1);
// Move should transfer ownership without crash
Assert::IsTrue(true);
}
TEST_METHOD(MoveAssignment_TransfersOwnership)
{
std::wstring eventName1 = L"TestEventLockerMoveAssign1_" + std::to_wstring(GetCurrentProcessId());
std::wstring eventName2 = L"TestEventLockerMoveAssign2_" + std::to_wstring(GetCurrentProcessId());
auto locker1 = EventLocker::Get(eventName1);
auto locker2 = EventLocker::Get(eventName2);
Assert::IsTrue(locker1.has_value());
Assert::IsTrue(locker2.has_value());
*locker1 = std::move(*locker2);
// Should not crash
Assert::IsTrue(true);
}
};
}

Some files were not shown because too many files have changed in this diff Show More