From 39de67698ea1cfb99aa6763337b34fd3c1a230d1 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 23 Mar 2026 21:36:36 +1100 Subject: [PATCH 1/2] fix concurrency issue in RepositoryReader --- .gitignore | 1 + TestResults/Tests-windows-net10.0-report.html | 1647 ----------------- src/PackageUpdate/RepositoryReader.cs | 2 +- src/Tests/UpdaterTests.cs | 19 + 4 files changed, 21 insertions(+), 1648 deletions(-) delete mode 100644 TestResults/Tests-windows-net10.0-report.html diff --git a/.gitignore b/.gitignore index 542da96..dbbc20c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ obj/ *.received.* nugets/ .claude/settings.local.json +/TestResults diff --git a/TestResults/Tests-windows-net10.0-report.html b/TestResults/Tests-windows-net10.0-report.html deleted file mode 100644 index b2a6e6d..0000000 --- a/TestResults/Tests-windows-net10.0-report.html +++ /dev/null @@ -1,1647 +0,0 @@ - - - - - - -Test Report — Tests - - - - - - -
-
-
- -
-

Tests

-Test Report -
-
-
-23 Mar 2026, 10:29:07 UTC -MACBOOK16 -Microsoft Windows 10.0.19045 -.NET 10.0.4 -TUnit 1.21.6.0 -
- -
-
-
-
- - - - - -
96%pass rate
-
-
-
-68Total
-
-65Passed
-
-3Failed
-
-0Skipped
-
-0Cancelled
-
-
-3.20s -duration -
-
-
-
- -
- - - - - -
-
- - - -Group: -
- - - -
- -Sort: -
- - - -
-
- -
-
-
-
-
-
- - -
- - diff --git a/src/PackageUpdate/RepositoryReader.cs b/src/PackageUpdate/RepositoryReader.cs index 09aa419..762b0b7 100644 --- a/src/PackageUpdate/RepositoryReader.cs +++ b/src/PackageUpdate/RepositoryReader.cs @@ -1,6 +1,6 @@ public static class RepositoryReader { - static Dictionary cache = []; + static ConcurrentDictionary cache = []; static Repository.RepositoryFactory factory = Repository.Factory; public static async Task<(SourceRepository repository, PackageMetadataResource metadataResource)> Read(PackageSource source) diff --git a/src/Tests/UpdaterTests.cs b/src/Tests/UpdaterTests.cs index 15710a9..21baf68 100644 --- a/src/Tests/UpdaterTests.cs +++ b/src/Tests/UpdaterTests.cs @@ -1255,4 +1255,23 @@ public async Task NoMigrationDoesNotUpdateCsprojFiles() // Csproj should be unchanged when no migration occurs await Assert.That(csprojResult).IsEqualTo(originalCsproj); } + + [Test] + public async Task ConcurrentRepositoryReaderAccessDoesNotThrow() + { + var source = new PackageSource("https://api.nuget.org/v3/index.json"); + + var tasks = Enumerable.Range(0, 20) + .Select(_ => RepositoryReader.Read(source)); + + var results = await Task.WhenAll(tasks); + + await Assert.That(results).Count().IsEqualTo(20); + + foreach (var (repository, metadataResource) in results) + { + await Assert.That(repository).IsNotNull(); + await Assert.That(metadataResource).IsNotNull(); + } + } } \ No newline at end of file From d68bac9c6ce1c81754dd301fc77702f284b81147 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 23 Mar 2026 21:36:49 +1100 Subject: [PATCH 2/2] Update Directory.Build.props --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a1b7b86..910e45f 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 4.1.4 + 4.1.5 preview NU1608 1.0.0