Skip to content

Add contains(), union(), length(), and empty() Array functions #1005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 5, 2025

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jul 24, 2025

@SteveL-MSFT SteveL-MSFT requested a review from tgauth July 24, 2025 21:43
@SteveL-MSFT SteveL-MSFT marked this pull request as draft July 25, 2025 05:47
@SteveL-MSFT
Copy link
Member Author

Looks like length() and empty() are also Array functions, so will add those to this PR

@SteveL-MSFT SteveL-MSFT marked this pull request as ready for review July 25, 2025 17:30
@SteveL-MSFT SteveL-MSFT changed the title Add contains() and union() Array functions Add contains(), union(), length(), and empty() Array functions Jul 25, 2025
@SteveL-MSFT SteveL-MSFT requested a review from Copilot July 25, 2025 19:04
Copy link
Contributor

@Copilot 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 adds four new array functions to the DSC library: contains(), union(), length(), and empty(), which check for element existence, combine arrays/objects, return sizes, and check for emptiness respectively.

  • Implementation of four new DSC array functions with comprehensive test coverage
  • Registration of functions in the function dispatcher
  • Addition of localized strings for error messages and descriptions

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
dsc_lib/src/functions/union.rs Implements union function for merging arrays and objects
dsc_lib/src/functions/length.rs Implements length function for arrays, objects, and strings
dsc_lib/src/functions/empty.rs Implements empty function to check if collections are empty
dsc_lib/src/functions/contains.rs Implements contains function for searching in collections
dsc_lib/src/functions/mod.rs Registers the new functions in the function dispatcher
dsc_lib/locales/en-us.toml Adds localized strings for the new functions
dsc/tests/dsc_functions.tests.ps1 Adds comprehensive test cases for all new functions
Comments suppressed due to low confidence (3)

dsc_lib/src/functions/contains.rs:98

  • Use Value::Bool(true) instead of true for consistent type comparison in tests, matching the actual return type of the function.
        assert_eq!(result, true);

dsc_lib/src/functions/contains.rs:105

  • Use Value::Bool(false) instead of false for consistent type comparison in tests, matching the actual return type of the function.
        assert_eq!(result, false);

dsc_lib/src/functions/contains.rs:112

  • Use Value::Bool(true) instead of true for consistent type comparison in tests, matching the actual return type of the function.
        assert_eq!(result, true);

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Aug 5, 2025
Merged via the queue into PowerShell:main with commit 751b908 Aug 5, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the array-functions branch August 5, 2025 20:45
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.

2 participants