Skip to content

feat: implement export filter functionality for resource exports - #1621

Merged
Steve Lee (SteveL-MSFT) merged 34 commits into
PowerShell:mainfrom
Gijsreyn:gh-1486/main/add-postfilter-export
Aug 7, 2026
Merged

feat: implement export filter functionality for resource exports#1621
Steve Lee (SteveL-MSFT) merged 34 commits into
PowerShell:mainfrom
Gijsreyn:gh-1486/main/add-postfilter-export

Conversation

@Gijsreyn

Copy link
Copy Markdown
Collaborator

PR Summary

Adds engine-side post-filtering for export via a new exportFilter resource directive.

PR Context

Fixes #1486.

Copilot AI review requested due to automatic review settings July 11, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements engine-side post-filtering for dsc config export results via a new exportFilter resource directive, enabling consistent wildcard/equality filtering even for resources that don’t implement native export filtering.

Changes:

  • Adds exportFilter to the configuration resource directives schema and applies it in the export pipeline after resource.export(...).
  • Introduces configure::export_filter matching logic (case-insensitive * wildcard for strings; OR across filter objects, AND within each object) plus unit tests.
  • Adds Pester coverage for exportFilter behavior and updates the dsctest export resource to emit a name property for filtering.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/dsctest/src/main.rs Emits per-instance name values to enable filter-driven tests.
tools/dsctest/src/export.rs Extends the test export payload schema with optional name.
lib/dsc-lib/src/dscresources/command_resource.rs Adjusts when “export filtering not supported” is raised (only for non-empty input).
lib/dsc-lib/src/configure/mod.rs Wires exportFilter from directives into the export pipeline.
lib/dsc-lib/src/configure/export_filter.rs Adds the engine-side filtering implementation + Rust unit tests.
lib/dsc-lib/src/configure/config_doc.rs Adds export_filter directive field to the config document model/schema.
lib/dsc-lib/locales/en-us.toml Adds localized message for filter reduction logging.
dsc/tests/dsc_export.tests.ps1 Adds integration tests validating exportFilter behavior across scenarios.
dsc/src/resource_command.rs Updates call site for the changed export helper function signature.

Comment thread lib/dsc-lib/src/configure/mod.rs Outdated
Comment thread lib/dsc-lib/src/configure/export_filter.rs Outdated
Comment thread lib/dsc-lib/src/configure/export_filter.rs Outdated

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes look fine, but can you remove the wildcard filtering support in the service, firewall, and dism resources? I would expect all the tests to still pass (assuming they don't call the resource exe directly, if so, they would need to be udpated to go through dsc).

@Gijsreyn

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) - good catch, but it had some caveats. I've replaced them with tests that append * to a known valid identifier. Exact-match and existing AND/OR filtering coverage remained in place.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Comment thread resources/windows_service/src/service.rs Outdated
Comment thread lib/dsc-lib/src/configure/mod.rs Outdated
Comment thread resources/dism_dsc/src/feature_on_demand/export.rs
@SteveL-MSFT

Copy link
Copy Markdown
Member

Gijs Reijn (@Gijsreyn) you have a test failure and can you see if you can improve the code coverage?

@Gijsreyn

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) - I'm a bit surprised by the coverage report. The previous run was 41%, and after adding more tests, it dropped to 21% in the latest one.

@SteveL-MSFT

Copy link
Copy Markdown
Member

Gijs Reijn (@Gijsreyn) let me look into the CC report, I think the problem is that deleted lines is being calculated wrong as not covered

Files without LCOV data (e.g., platform-specific code behind #[cfg(windows)]
when only Linux coverage is collected) were incorrectly counting ALL added
lines as uncovered, including non-executable lines like comments and blanks.
This caused coverage to drop significantly when Windows-only files were
modified in a PR.

Fix: skip files without LCOV data since coverage cannot be determined for
uninstrumented code. Also handle the '\ No newline at end of file' diff
marker which could cause off-by-one line number errors after deleted lines.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 00:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Comment thread lib/dsc-lib/src/configure/export_filter.rs
@SteveL-MSFT

Copy link
Copy Markdown
Member

WG discussed this:

  • remove the exportFilter directive
  • emit INFO message when engine filter is applied
  • the INFO message should indicate this feature as Experimental

@SteveL-MSFT Steve Lee (SteveL-MSFT) moved this from Todo PRs to Reviewed in DSC Working Group Jul 23, 2026
@Gijsreyn

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) - made the adjustments. Let me know if this is solid.

Comment thread lib/dsc-lib/src/configure/export_filter.rs
Comment thread lib/dsc-lib/src/configure/export_filter.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

resources/dism_dsc/optionalfeature.dsc.resource.json:104

  • The schema text for description says it is "Returned by the get operation", but optional_feature::handle_export() now exports full feature info (via get_feature_info()), which likely includes description. The schema should reflect what export actually returns.
                            "description": {
                                "type": "string",
                                "title": "Description",
                                "description": "The description of the optional feature. Returned by the get operation."
                            },

Comment thread resources/dism_dsc/optionalfeature.dsc.resource.json
Comment thread lib/dsc-lib/src/configure/mod.rs
Comment thread dsc/tests/dsc_export.tests.ps1 Outdated
Comment thread resources/dism_dsc/src/optional_feature/export.rs
Comment thread resources/dism_dsc/src/windows_feature/export.rs Outdated
@SteveL-MSFT Steve Lee (SteveL-MSFT) added this to the 3.3-Approved milestone Aug 5, 2026

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, just occurred to me looking over the latest change that the dism resource manifests need to declare they explicitly support filtering. Although for backwards compat it doesn't need to, we want those resource manifests to represent best practice.

@Gijsreyn

Copy link
Copy Markdown
Collaborator Author

Sorry, just occurred to me looking over the latest change that the dism resource manifests need to declare they explicitly support filtering. Although for backwards compat it doesn't need to, we want those resource manifests to represent best practice.

Done! And also bumped up the version number for good measure.

@SteveL-MSFT
Steve Lee (SteveL-MSFT) added this pull request to the merge queue Aug 7, 2026
Merged via the queue into PowerShell:main with commit 6be9f83 Aug 7, 2026
56 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Reviewed

Development

Successfully merging this pull request may close these issues.

Allow post-filtering for export

3 participants