Skip to content

Stop the discovery manager factory from shadowing discoveryCriteria - #16391

Merged
Jakub Jareš (nohwnd) merged 2 commits into
microsoft:mainfrom
nohwnd:nohwnd-rename-shadowed-lambda-param-in-getdisco
Aug 25, 2026
Merged

Jakub Jareš (nohwnd) merged 2 commits into
microsoft:mainfrom
nohwnd:nohwnd-rename-shadowed-lambda-param-in-getdisco

Conversation

@nohwnd

Copy link
Copy Markdown
Member

The factory lambda in TestEngine.GetDiscoveryManager named its parameter discoveryCriteria, the same name as the method parameter, but the two hold different data. The method receives the full criteria with every source. The lambda receives the per-workload piece that ParallelProxyDiscoveryManager.SplitToWorkloads produces, normally a single source. Rename the lambda parameter to workloadCriteria and add a comment saying which of the two arrives there.

GetExecutionManager in the same file already does this — its lambda parameter is runCriteria and a comment explains the split.

No behaviour change. The lambda still reads sources from the criteria it is handed.

Related: #16386. The repeated enumeration that issue reports does not exist — Sources is read once in the method and once per workload inside the lambda, on two different objects. The fix it proposes, hoisting the outer Sources into a shared local, would pass every source to GetTestHostManagerByRunConfiguration for every parallel slot instead of that slot's own source. The shadowing is what made that look correct, and this change removes it. It does not fix the issue, because there is nothing there to fix.

Verified: build.cmd -c Release compiles clean, Microsoft.TestPlatform.CrossPlatEngine.UnitTests passes on net11.0 and net481.

🤖

The factory lambda in TestEngine.GetDiscoveryManager named its parameter
discoveryCriteria, the same as the method parameter, but the two hold
different data. The method receives the full criteria; the lambda receives
the per-workload piece that ParallelProxyDiscoveryManager.SplitToWorkloads
produces, normally a single source. Rename the lambda parameter to
workloadCriteria and say in a comment which one arrives there.

GetExecutionManager in the same file already names its lambda parameter
runCriteria and documents the split.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 19, 2026 16:22

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

This PR clarifies TestEngine.GetDiscoveryManager’s workload-creation lambda by avoiding parameter shadowing of discoveryCriteria, aligning it with the existing pattern used in GetExecutionManager. The goal is to make it explicit that the lambda receives the per-workload DiscoveryCriteria produced by ParallelProxyDiscoveryManager.SplitToWorkloads, without changing behavior.

Changes:

  • Renamed the discovery-manager factory lambda parameter from discoveryCriteria to workloadCriteria.
  • Updated the lambda to read sources from workloadCriteria (the per-workload criteria), eliminating shadowing confusion.
  • Added an explanatory comment describing the split criteria flow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The comment read `is not the discoveryCriteria this method received`, which
scans as if the object of `received` went missing. Spell out the comparison.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 20, 2026 09:34

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 1 out of 1 changed files in this pull request and generated no new comments.

@nohwnd
Jakub Jareš (nohwnd) merged commit 65a2830 into microsoft:main Aug 25, 2026
20 checks passed
This was referenced Nov 12, 2026
ptr727-codegen Bot pushed a commit to ptr727/Utilities that referenced this pull request Nov 12, 2026
Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest)
from 18.11.1 to 18.12.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.NET.Test.Sdk's
releases](https://github.com/microsoft/vstest/releases)._

## 18.12.0

## Security fix

This release includes the fix for CVE-2026-105544, an elevation of
privilege vulnerability in the VSTest artifact post-processor. The
post-processor could consume a forged `executionComplete.json` written
by another local user, and then run attacker-controlled output handling.

Affected: `Microsoft.TestPlatform.CLI` 18.11.0 and earlier. Every
version from 18.11.1 on is fixed, including 18.12.0.

`Microsoft.TestPlatform.CLI` is the VSTest build that we ship into the
.NET SDK. The recommended way to get this fix is to update your .NET SDK
to the latest patched version, see the advisory for the SDK versions.

The fix is also released in the `Microsoft.TestPlatform.CLI` package,
for completeness. That package is rarely used directly. It is not a
dependency of `Microsoft.NET.Test.Sdk` or `Microsoft.TestPlatform`, so
those packages do not bring it in.

Details: https://github.com/microsoft/vstest/issues/16654 and
https://github.com/dotnet/announcements/issues/517

Using custom Docker images or Nano Server? See
https://github.com/microsoft/vstest/issues/16652

## What's Changed
* Fix TestCaseStart/Stop events dropped for data-driven tests with
shared TestCase.Id by @​nohwnd in
https://github.com/microsoft/vstest/pull/16033
* Stop the discovery manager factory from shadowing discoveryCriteria by
@​nohwnd in https://github.com/microsoft/vstest/pull/16391
* Gate the HTTP link checker on a fingerprint of the broken links by
@​nohwnd in https://github.com/microsoft/vstest/pull/16413
* Quote boolean conditions in shipped Microsoft.TestPlatform.targets by
@​nohwnd in https://github.com/microsoft/vstest/pull/16404
* Obsolete API hygiene: the compatibility-safe changes by @​azat-msft in
https://github.com/microsoft/vstest/pull/16420
* Add xxHash128 test ids, available but not default by @​azat-msft in
https://github.com/microsoft/vstest/pull/16378
* Isolate attachment manager test temporary files by @​mmitche in
https://github.com/microsoft/vstest/pull/16463
* Test ids report logger by @​azat-msft in
https://github.com/microsoft/vstest/pull/16443
* Isolate code coverage files in published output by @​azat-msft in
https://github.com/microsoft/vstest/pull/16483
* Preserve OutputType for Android test projects by @​jonathanpeppers in
https://github.com/microsoft/vstest/pull/16496
* Fix dotnet host resolution under proot (ARM64/Termux) by @​azat-msft
in https://github.com/microsoft/vstest/pull/16462
* Mark the xxHash128 test id API as experimental by @​azat-msft in
https://github.com/microsoft/vstest/pull/16465
* Ship Microsoft.Diagnostics.NETCore.Client in Microsoft.TestPlatform
and Portable packages by @​nohwnd in
https://github.com/microsoft/vstest/pull/16633
* Fix localized resource paths in CLI source-build/non-Windows packages
by @​nohwnd in https://github.com/microsoft/vstest/pull/16644


**Full Changelog**:
https://github.com/microsoft/vstest/compare/v18.11.0...v18.12.0



Commits viewable in [compare
view](https://github.com/microsoft/vstest/compare/v18.11.1...v18.12.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.NET.Test.Sdk&package-manager=nuget&previous-version=18.11.1&new-version=18.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Dec 3, 2026
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.

2 participants