Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR 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_expressions from a private instance method to a public standalone function
  • Modified get_resource_invocation_order to 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.

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Dec 2, 2025
Merged via the queue into PowerShell:main with commit 7c6105c Dec 2, 2025
19 checks passed
@SteveL-MSFT SteveL-MSFT deleted the loop-name branch December 2, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encountering an error using loops in bicep config files

2 participants