Fix allow copy resources to have same name#1300
Merged
SteveL-MSFT merged 2 commits intoPowerShell:mainfrom Dec 2, 2025
Merged
Conversation
70b4499 to
6a4b087
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors how copy loops are unrolled in DSC configurations to allow resources in a copy loop to share the same symbolic name. Previously, copy loops were unrolled before determining resource invocation order, requiring each instance to have a unique name. Now, unrolling happens during invocation order determination, allowing copy instances to use a single symbolic name.
Key changes:
- Moved copy loop unrolling from preprocessing into the dependency resolution phase
- Converted
invoke_property_expressionsfrom a private instance method to a public standalone function - Modified
get_resource_invocation_orderto accept a mutable Context parameter
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/dsc-lib/src/configure/mod.rs | Removed unroll_copy_loops() method, made invoke_property_expressions public and standalone, removed calls to unroll_copy_loops from invoke methods, updated signature of get_resource_invocation_order to pass mutable context |
| lib/dsc-lib/src/configure/depends_on.rs | Added unroll_and_push() helper function to unroll copy loops during invocation order determination, changed context parameter to mutable in get_resource_invocation_order(), updated all test cases to pass mutable context |
| dsc/tests/dsc_copy.tests.ps1 | Added test case "Symbolic name loop works" validating that copy resources can share the same name across all instances |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tgauth
approved these changes
Dec 2, 2025
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
Unroll loops while resource invocation order is being determined. This means that resources still need to have a unique name+type combination, however, a copy loop is treated as a collection of same resource (meaning same name) which is allowed. So you can't explicitly have more than one resource with same name+type, but a copy resource is allowed to have a single name for every instance in the copy.
This also required making a previous private function public.
PR Context
Fix #1270