Skip to content

Disallow duplicate assets when merging manifests#2763

Merged
mmitche merged 7 commits intodotnet:mainfrom
mmitche:disallow-dupes-when-merging
Aug 2, 2023
Merged

Disallow duplicate assets when merging manifests#2763
mmitche merged 7 commits intodotnet:mainfrom
mmitche:disallow-dupes-when-merging

Conversation

@mmitche
Copy link
Member

@mmitche mmitche commented Jul 19, 2023

When merging manifests, we were distincting the assets and erroring if there are dupes. This should have been done using an equality comparer that compares based on Id alone. Fix this, and add appropriate testing.

Resolves: #2762

When merging manifests, we were distincting the assets and erroring if there are dupes. This should have been done using an equality comparer that compares based on Id alone. Fix this, and add appropriate testing.

Resolves: dotnet#2762

// Error out for any duplicated packages based on the top level properties of the package.
var distinctPackages = manifest.Packages.Distinct();
var distinctPackages = manifest.Packages.Distinct(new PackageIdComparer());
Copy link
Member

@dkurepa dkurepa Jul 20, 2023

Choose a reason for hiding this comment

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

We could also use DistinctBy(package => package.Id, StringComparison.OrdinalIgnoreCase) if we don't need the Hash part later

Copy link
Member Author

Choose a reason for hiding this comment

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

I knew there was a predicate version, but I couldn't remember what it was called. I'll change that.

@mmitche
Copy link
Member Author

mmitche commented Aug 1, 2023

@dkurepa I fixed the tests, including an additional issue. The merged manifest tests were only passing by coincidence. There were some tests that were adding packages/blobs to the manifest1/manifest3 objects in the class. NUnit does not re-initialize a new TestFixture class object per test, so if tests ran in a different, you could get different results.

@mmitche mmitche enabled auto-merge (squash) August 1, 2023 20:51
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.

Manifest merging should disallow duplicate assets

3 participants