Skip to content

C#: preserve declared dependency version ranges on ResolvedPackage - #8735

Merged
macsux merged 3 commits into
mainfrom
macsux/dependencyvulnerabilitycheck
Sep 9, 2026
Merged

macsux merged 3 commits into
mainfrom
macsux/dependencyvulnerabilitycheck

Conversation

@macsux

@macsux macsux commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The NuGet lock file records both a resolved version and the version range each package declared for its children, but only the resolved version was carried into the MSBuildProject marker — so consumers could not tell what range a dependency was originally declared with (needed for dependency vulnerability analysis).

This adds a dependencyRanges map (child package id → normalized version range) to ResolvedPackage on both the Java and C# sides, populates it from the lock file dependencies section in MSBuildProjectHelper, and serializes it over RPC as parallel key/value lists. Tests were added on both sides covering a package with declared ranges and one without.

:rewrite-csharp:test --tests "*MSBuildProjectTest*" and :rewrite-csharp:csharpTest (2363 tests) both pass locally.

The lock file records both a resolved version and the version range each
package declared for its children. Only the resolved version was carried
into the MSBuildProject marker, so consumers could not tell what range a
dependency was originally declared with. Add a `dependencyRanges` map to
`ResolvedPackage` on both the Java and C# sides, populate it from the
NuGet lock file `dependencies` section, and send it over RPC as parallel
key/value lists.
…nstances

The RPC layer materializes 'before' skeletons without running the
constructor, so dependencyRanges is null despite its default. The list
fields already tolerate this via receiveList; the new map codec
dereferenced the map directly and NPE'd on every marker round-trip
(CSharpRecipeTest/CSharpParseProjectTest in integTest). Guard both the
send and receive paths on both the Java and C# sides.
@macsux
macsux merged commit 6427ded into main Sep 9, 2026
1 check passed
@macsux
macsux deleted the macsux/dependencyvulnerabilitycheck branch September 9, 2026 17:25
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant