Skip to content

Only fail Dependencies.props CodeCheck for non-Maestro dependency changes - #68097

Merged
wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/codecheck-dependencies-maestro
Jul 30, 2026
Merged

wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/codecheck-dependencies-maestro

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

The CodeCheck.ps1 check added in #68012 requires eng/tools/DependabotDiscovery/DependabotDiscovery.csproj to be updated whenever eng/Dependencies.props changes at all. This is too broad: it also fires when a package that's already managed by Maestro is renamed (as in #68014), even though DependabotDiscovery.csproj never referenced that package in the first place (Maestro-managed dependencies are explicitly excluded from it, per its README.md).

A rename shows up as one <LatestPackageReference Include="..." /> removed and one added, which the old check couldn't distinguish from a genuinely new/removed third-party dependency.

Change

The check now:

  1. Diffs the set of <LatestPackageReference Include="..." /> names in eng/Dependencies.props between the target branch and the current tree to find only the packages that were actually added or removed.
  2. For each such package, derives its expected version property name (matching the %(Identity) -> $(...Version) convention already used in eng/Dependencies.props) and checks whether that property is defined in eng/Version.Details.props (checking both the target-branch and current versions, so renames into/out of a Maestro-managed name are recognized either way).
  3. Only errors if DependabotDiscovery.csproj wasn't updated and at least one of the added/removed packages isn't Maestro-managed.

Verified against #68014's actual diff (rename of Microsoft.CodeAnalysis.ExternalAccess.AspNetCore to Microsoft.CodeAnalysis.Features.ExternalAccess, both Maestro-managed): the check now passes without touching DependabotDiscovery.csproj. Also verified it still fails when a genuinely new, non-Maestro package is added without a matching DependabotDiscovery.csproj update.

Co-authored-by: Copilot [email protected]

…ency changes

The CodeCheck added in dotnet#68012 flagged any add/remove in eng/Dependencies.props
as requiring a matching update to eng/tools/DependabotDiscovery/DependabotDiscovery.csproj.
This incorrectly fires when a Maestro-managed package is renamed (as in dotnet#68014),
since that shows up as one add + one remove even though DependabotDiscovery.csproj
never referenced it (Maestro-managed packages are excluded, see the project's README).

Now the check compares the set of <LatestPackageReference Include="..." /> names
before/after and only requires a DependabotDiscovery.csproj update when an added or
removed package has no matching version property in eng/Version.Details.props
(i.e. isn't managed by Maestro).

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 29, 2026 21:19
@wtgodbe
wtgodbe requested a review from a team as a code owner July 29, 2026 21:19

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

Updates eng/scripts/CodeCheck.ps1 so the “Dependabot discovery project must be updated when eng/Dependencies.props changes” rule only fails when the change adds/removes dependencies that aren’t Maestro-managed (as identified via version properties in eng/Version.Details.props). This reduces false failures for Maestro-only renames.

Changes:

  • Compute the set of added/removed <LatestPackageReference Include="..."> entries by diffing target-branch vs working tree.
  • Determine whether changed packages are Maestro-managed by checking for corresponding $(...Version) properties in eng/Version.Details.props (unioning both old and new versions).
  • Only error when DependabotDiscovery.csproj wasn’t updated and at least one changed package is non-Maestro-managed.
Comments suppressed due to low confidence (1)

eng/scripts/CodeCheck.ps1:257

  • Get-MaestroManagedVersionProperties has the same return , $properties issue as above (it returns an array containing the HashSet). Additionally, the regex only matches tags of the form and will miss properties if they ever gain attributes (e.g. ). Returning a non-enumerated HashSet and using a '\b' boundary makes the extraction more robust.
        function Get-MaestroManagedVersionProperties([string[]]$fileContent) {
            $properties = [System.Collections.Generic.HashSet[string]]::new()
            foreach ($line in $fileContent) {
                if ($line -match '<(\w+Version)>') {
                    [void]$properties.Add($matches[1])
                }
            }
            return , $properties
        }

Comment thread eng/scripts/CodeCheck.ps1 Resolved
…tern, cover all DependabotDiscovery exclusion categories

Copilot's automated review on dotnet#68097 caught two real bugs:
- The Include="..." regex only matched self-closing tags with no other
  attributes, silently missing entries like
  <LatestPackageReference Include="xunit.v3" Version="$(XunitV3Version)" />.
  Fixed with a regex that tolerates any attributes/tag layout, and now joins
  file content into one string so a tag split across lines is still matched.
- 'return , $x' combined with inconsistent @(...) wrapping at call sites
  caused double array-wrapping in some paths, silently shrinking the
  Maestro-managed-properties set from ~440 entries to 1-2. Removed the
  comma-trick entirely; every call site now consistently wraps in @(...).

Additionally, two independent review agents pointed out that
eng/tools/DependabotDiscovery/README.md documents more exclusion categories
than just Maestro: packages pinned via the shared $(IdentityModelVersion)
property, packages mapped to an in-repo project via ProjectReferenceProvider
(eng/ProjectReferences.props), and two hard-coded packages
(NETStandard.Library, Microsoft.CodeAnalysis.PublicApiAnalyzers). The check
now recognizes all of these, matching the original error message's intent
('isn't managed by Maestro or the shared $(IdentityModelVersion) property').

Verified end-to-end in isolated worktrees against the real repo history:
- PR dotnet#68014's actual rename (Maestro-managed) - passes
- A synthetic new, non-excluded package addition - still fails as expected
- A full IdentityModel-managed rename (Dependencies.props + Versions.props) - passes
- A ProjectReferenceProvider-mapped name - passes
- The hard-coded NETStandard.Library exclusion - passes

Co-authored-by: Copilot <[email protected]>

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.

Comments suppressed due to low confidence (1)

eng/scripts/CodeCheck.ps1:260

  • Get-LatestPackageReferenceNames currently treats any Include attribute value as a package name, but eng/Dependencies.props contains a non-package item transform Include="@(_LatestRuntimePackageReference->Distinct())". If that expression ever changes, it will be treated as an added/removed "package" and will likely trigger an incorrect DependabotDiscovery sync failure (and it also can't be mapped to a *Version property name reliably). Filter out item transforms (values starting with '@(') so this helper only returns concrete package IDs.
        function Get-LatestPackageReferenceNames([string[]]$fileContent) {
            $text = $fileContent -join "`n"
            return [regex]::Matches($text, '<LatestPackageReference\b[^<>]*?\bInclude="([^"]+)"') |
                ForEach-Object { $_.Groups[1].Value } |
                Sort-Object -Unique

@wtgodbe
wtgodbe merged commit 9c53fc0 into dotnet:main Jul 30, 2026
26 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 31, 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.

3 participants