Skip to content

Conversation

@Gijsreyn
Copy link
Contributor

@Gijsreyn Gijsreyn commented Nov 25, 2025

PR Summary

Fixed copy loops to work with reference() function by preserving copy context during property evaluation. Modified copyIndex() and reference() to accept copy context outside Copy mode, and stored loop indices in resource tags during unrolling then restored them before evaluating properties. Tests added

PR Context

Fix #1286

@Gijsreyn Gijsreyn force-pushed the gh-1286/main/fix-reference-copy branch from 5d7597c to 5566b37 Compare December 2, 2025 01:26
@SteveL-MSFT
Copy link
Member

@Gijsreyn can you fix the merge conflicts?

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Dec 3, 2025

@SteveL-MSFT - I'll pick it up when I'm back.

@Gijsreyn
Copy link
Contributor Author

@SteveL-MSFT - I tried resolving the merge conflicts, but it looks like after the SSH merge, it started failing: https://github.com/PowerShell/DSC/actions/runs/20111826751

@SteveL-MSFT
Copy link
Member

@Gijsreyn I understand the problem and working on a fix

@SteveL-MSFT
Copy link
Member

@Gijsreyn build issue resolved, but you still have some test failures

@Gijsreyn
Copy link
Contributor Author

@SteveL-MSFT - oops, I think I removed too much when fixing the merge conflict. Should be good to go!


// Find the dependency in config.resources - it might be a copy loop template
// We need to find by type since the name is the template expression
if let Some(dependency_resource) = config.resources.iter().find(|r| r.resource_type == resource_type) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to handle the ase where the dependency doesn't exist?

new_resource.properties = invoke_property_expressions(parser, context, Some(properties))?;
}
// Store copy loop context in resource tags for later use by reference()
let mut tags = new_resource.tags.clone().unwrap_or_default();
Copy link
Member

Choose a reason for hiding this comment

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

If you need to keep some context information I would prefer to put it under metadata/Microsoft.DSC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use reference() in copy() loop throws not implemented

2 participants