Add stateChanged() and restartRequired() functions - #1608
Merged
Mikey Lombardi (He/Him) (michaeltlombardi) merged 5 commits intoJul 7, 2026
Merged
Conversation
Steve Lee (SteveL-MSFT)
requested review from
Copilot and
Mikey Lombardi (He/Him) (michaeltlombardi)
July 6, 2026 20:53
Steve Lee (SteveL-MSFT)
force-pushed
the
restart-required-function
branch
from
July 6, 2026 20:54
6f0400a to
2519e6c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two new DSC expression functions—stateChanged() and restartRequired()—and wires the configuration execution context to track whether each resource’s set operation actually changed state, enabling simpler conditional logic (e.g., for upcoming Actions/conditions support).
Changes:
- Added
restartRequired(<process|service|system>, [name])andstateChanged(<resourceId>)functions to the dsc-lib function dispatcher with localized help text. - Tracked per-resource state-change status during
config setexecution (based onchangedProperties) and exposed it viastateChanged(). - Added a new
Test/Settest resource and expanded Pester coverage to validate both new functions.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/dsctest/src/set.rs | Adds a new dsctest resource implementation used to exercise changedProperties/state-change behavior. |
| tools/dsctest/src/main.rs | Wires the new set module into dsctest CLI command handling and schema export. |
| tools/dsctest/src/args.rs | Adds a set subcommand and schema enum entry for dsctest. |
| tools/dsctest/dsctest.dsc.manifests.json | Registers the new Test/Set resource manifest for dsctest. |
| lib/dsc-lib/src/functions/state_changed.rs | Implements the stateChanged() expression function using execution context data. |
| lib/dsc-lib/src/functions/restart_required.rs | Implements the restartRequired() expression function using execution context data. |
| lib/dsc-lib/src/functions/mod.rs | Registers both new functions in the dispatcher and module list. |
| lib/dsc-lib/src/dscresources/invoke_result.rs | Adds SetResult::is_changed() helper to determine state-change from changedProperties. |
| lib/dsc-lib/src/configure/mod.rs | Records state-change results per executed resource into the shared Context. |
| lib/dsc-lib/src/configure/context.rs | Extends Context to store state_changed values by resourceId. |
| lib/dsc-lib/locales/en-us.toml | Adds localized strings for the new functions (description/syntax/errors). |
| dsc/tests/dsc_restartRequired.tests.ps1 | Adds output-based coverage validating restartRequired() behavior. |
| dsc/tests/dsc_functions.tests.ps1 | Adds coverage validating stateChanged() behavior with changed/unchanged states and missing info. |
| Cargo.lock | Updates lockfile entries (registry crates version bump). |
Steve Lee (SteveL-MSFT)
force-pushed
the
restart-required-function
branch
from
July 6, 2026 23:31
8369088 to
a72c8dd
Compare
Mikey Lombardi (He/Him) (michaeltlombardi)
approved these changes
Jul 7, 2026
Mikey Lombardi (He/Him) (michaeltlombardi)
left a comment
Collaborator
There was a problem hiding this comment.
The handling for state changed seems pretty elegant to me, these functions definitely make lookup much more ergonomic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
stateChanged(<resourceId>)function returns a bool whether the specified resource has executed and incurred a state change (determined by changedProperties)restartRequired(<type>,[name])function returns if there is a restart required indicated for the named process, named service, or the system. You could already get this information fromcontext(), but it's a bit cumbersome so this makes it much easierPR Context
Preparation for adding Actions as these would be used for
conditions