Fix allowing copy count to accept an expression#1179
Merged
SteveL-MSFT merged 3 commits intoPowerShell:mainfrom Oct 21, 2025
Merged
Fix allowing copy count to accept an expression#1179SteveL-MSFT merged 3 commits intoPowerShell:mainfrom
copy count to accept an expression#1179SteveL-MSFT merged 3 commits intoPowerShell:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables the copy.count property to accept expressions in addition to integer literals, addressing part of issue #1177. The implementation introduces an IntOrExpression enum type that can parse and evaluate expressions at runtime, and adds validation to ensure parameters() function results match their declared types.
Key changes:
- Introduced
IntOrExpressionenum to support both literal integers and string expressions forcopy.countandcopy.batch_size - Enhanced
parameters()function with type validation for all data types (String, Int, Bool, Object, Array) - Added expression evaluation logic in the copy loop to resolve dynamic count values
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/dsc-lib/src/configure/config_doc.rs | Defines new IntOrExpression enum and updates Copy struct to use it for count and batch_size fields |
| lib/dsc-lib/src/configure/mod.rs | Implements expression parsing and evaluation for copy count, converting expressions to i64 at runtime |
| lib/dsc-lib/src/functions/parameters.rs | Adds explicit type checking for all parameter types to validate results match declared types |
| lib/dsc-lib/locales/en-us.toml | Adds localized error messages for type validation failures |
| dsc/tests/dsc_copy.tests.ps1 | Adds test case verifying copy count can accept expressions like parameters('serverCount') |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
a9e6b14 to
7e0fa18
Compare
tgauth
approved these changes
Oct 21, 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
For
copy, thecountproperty was explicitly set in the schema as anintso you can't use an expression. This change adds a new numIntOrExpressionand duringcopywe parse and execute the expression.Additionally, for
parameters()we explicitly check the result matches the defined parameter type rather than having it get validated and fail later.PR Context
Part of #1177