Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions ILSpy.ReadyToRun/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,49 @@
"System.Xml.XDocument": "4.3.0"
}
},
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.3",
"contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ=="
},
"NuGet.Common": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "uyXLqkbbZmkMvdHOR23l1EHW2hRmULtzoG3Ocj84VpGptnNfkODVboHGJfDfcn9Gi9oUNDs8/VjL4FZcST6zVg==",
"dependencies": {
"NuGet.Frameworks": "7.6.0"
}
},
"NuGet.Configuration": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "+bNj+YneC5CNg1vR+WZjLAakscJlsi0KhADZUgIJPn4pwh8/jeCUMC5ik5cpET/i+QOplDy7aJVTGkpdfrlPww==",
"dependencies": {
"NuGet.Common": "7.6.0",
"System.Security.Cryptography.ProtectedData": "8.0.0"
}
},
"NuGet.Frameworks": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "rJ7QtKN45XzLXCrMATve6eFLiUyUGEkA1rFSb6U6Fw6laM4hEAcKOrcdbgWlcFUlCK2158qP1LF00hg/ivF3nw=="
},
"NuGet.Packaging": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "TDp+qHzRBy1zjwiJGCbfpdO0jMG5hH/bk7p1EABLKv9p5SIykDPGnbuYXm2iZO0QJ/H+hOI/vo5LfqM17Q+G0w==",
"dependencies": {
"Newtonsoft.Json": "13.0.3",
"NuGet.Configuration": "7.6.0",
"NuGet.Versioning": "7.6.0",
"System.Security.Cryptography.Pkcs": "8.0.1"
}
},
"NuGet.Versioning": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "TpZxfOoQBQk/0r/2uc1A1qNYIKHkJGgOrWP+ax3nsNAUN/1BOQMDrgmGADogSA4hOXH1ZJiyeYg4Ca+vUW0sEg=="
},
"Onigwrap": {
"type": "Transitive",
"resolved": "1.0.10",
Expand Down Expand Up @@ -1089,6 +1132,11 @@
"System.Threading.Tasks": "4.3.0"
}
},
"System.Security.Cryptography.ProtectedData": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "+TUFINV2q2ifyXauQXRwy4CiBhqvDEDZeVJU7qfxya4aRYOKzVBpN+4acx25VcPB9ywUN6C0n8drWl110PhZEg=="
},
"System.Security.Cryptography.X509Certificates": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -1355,6 +1403,7 @@
"Microsoft.DiaSymReader.Converter.Xml": "[1.1.0-beta2-22171-02, )",
"Microsoft.DiaSymReader.Native": "[17.0.0-beta1.21524.1, )",
"Microsoft.Extensions.DependencyInjection.Abstractions": "[10.0.9, )",
"NuGet.Protocol": "[7.6.0, )",
"ProDataGrid": "[12.0.0, )",
"Svg.Controls.Skia.Avalonia": "[12.0.0.11, )",
"System.Composition.AttributedModel": "[10.0.9, )",
Expand Down Expand Up @@ -1524,6 +1573,15 @@
"resolved": "0.11.6",
"contentHash": "f33RkDtZO8VlGXCtmQIviOtxgnUdym9xx/b1p9h91CRGOsJFxCFOFK1FDbVt1OCf1aWwYejUFa2MOQyFWTFjbA=="
},
"NuGet.Protocol": {
"type": "CentralTransitive",
"requested": "[7.6.0, )",
"resolved": "7.6.0",
"contentHash": "Ccb9dJG9hW0FdHFjXoHmhJBBJRYSCeSJArLdZjyZj6/FEAIKezLn75KFQNrTPE5UiAp4HVrjBizufZ/0IXhfKQ==",
"dependencies": {
"NuGet.Packaging": "7.6.0"
}
},
"ProDataGrid": {
"type": "CentralTransitive",
"requested": "[12.0.0, )",
Expand Down Expand Up @@ -1623,6 +1681,12 @@
"runtime.native.System.Security.Cryptography.OpenSsl": "4.3.2"
}
},
"System.Security.Cryptography.Pkcs": {
"type": "CentralTransitive",
"requested": "[10.0.9, )",
"resolved": "10.0.9",
"contentHash": "aud6Ox9eSPayMBNu6qL+Zk7yDB6ShrRxg1aMJ1uPqFTGAFVisrjFeKj6RE9SimjNKcbl+chwmiYIK4b3hvc61A=="
},
"System.Text.RegularExpressions": {
"type": "CentralTransitive",
"requested": "[4.3.1, )",
Expand Down Expand Up @@ -2567,6 +2631,12 @@
"Microsoft.NETCore.Targets": "1.1.3",
"runtime.unix.System.Private.Uri": "4.3.0"
}
},
"System.Security.Cryptography.Pkcs": {
"type": "CentralTransitive",
"requested": "[10.0.9, )",
"resolved": "10.0.9",
"contentHash": "aud6Ox9eSPayMBNu6qL+Zk7yDB6ShrRxg1aMJ1uPqFTGAFVisrjFeKj6RE9SimjNKcbl+chwmiYIK4b3hvc61A=="
}
},
"net10.0/osx-arm64": {
Expand Down Expand Up @@ -3487,6 +3557,12 @@
"Microsoft.NETCore.Targets": "1.1.3",
"runtime.unix.System.Private.Uri": "4.3.0"
}
},
"System.Security.Cryptography.Pkcs": {
"type": "CentralTransitive",
"requested": "[10.0.9, )",
"resolved": "10.0.9",
"contentHash": "aud6Ox9eSPayMBNu6qL+Zk7yDB6ShrRxg1aMJ1uPqFTGAFVisrjFeKj6RE9SimjNKcbl+chwmiYIK4b3hvc61A=="
}
},
"net10.0/win-arm64": {
Expand Down Expand Up @@ -4390,6 +4466,12 @@
"Microsoft.NETCore.Platforms": "1.1.1",
"Microsoft.NETCore.Targets": "1.1.3"
}
},
"System.Security.Cryptography.Pkcs": {
"type": "CentralTransitive",
"requested": "[10.0.9, )",
"resolved": "10.0.9",
"contentHash": "aud6Ox9eSPayMBNu6qL+Zk7yDB6ShrRxg1aMJ1uPqFTGAFVisrjFeKj6RE9SimjNKcbl+chwmiYIK4b3hvc61A=="
}
},
"net10.0/win-x64": {
Expand Down Expand Up @@ -5293,6 +5375,12 @@
"Microsoft.NETCore.Platforms": "1.1.1",
"Microsoft.NETCore.Targets": "1.1.3"
}
},
"System.Security.Cryptography.Pkcs": {
"type": "CentralTransitive",
"requested": "[10.0.9, )",
"resolved": "10.0.9",
"contentHash": "aud6Ox9eSPayMBNu6qL+Zk7yDB6ShrRxg1aMJ1uPqFTGAFVisrjFeKj6RE9SimjNKcbl+chwmiYIK4b3hvc61A=="
}
}
}
Expand Down
64 changes: 64 additions & 0 deletions ILSpy.Tests.Windows/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,49 @@
"System.Xml.XDocument": "4.3.0"
}
},
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.3",
"contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ=="
},
"NuGet.Common": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "uyXLqkbbZmkMvdHOR23l1EHW2hRmULtzoG3Ocj84VpGptnNfkODVboHGJfDfcn9Gi9oUNDs8/VjL4FZcST6zVg==",
"dependencies": {
"NuGet.Frameworks": "7.6.0"
}
},
"NuGet.Configuration": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "+bNj+YneC5CNg1vR+WZjLAakscJlsi0KhADZUgIJPn4pwh8/jeCUMC5ik5cpET/i+QOplDy7aJVTGkpdfrlPww==",
"dependencies": {
"NuGet.Common": "7.6.0",
"System.Security.Cryptography.ProtectedData": "8.0.0"
}
},
"NuGet.Frameworks": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "rJ7QtKN45XzLXCrMATve6eFLiUyUGEkA1rFSb6U6Fw6laM4hEAcKOrcdbgWlcFUlCK2158qP1LF00hg/ivF3nw=="
},
"NuGet.Packaging": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "TDp+qHzRBy1zjwiJGCbfpdO0jMG5hH/bk7p1EABLKv9p5SIykDPGnbuYXm2iZO0QJ/H+hOI/vo5LfqM17Q+G0w==",
"dependencies": {
"Newtonsoft.Json": "13.0.3",
"NuGet.Configuration": "7.6.0",
"NuGet.Versioning": "7.6.0",
"System.Security.Cryptography.Pkcs": "8.0.1"
}
},
"NuGet.Versioning": {
"type": "Transitive",
"resolved": "7.6.0",
"contentHash": "TpZxfOoQBQk/0r/2uc1A1qNYIKHkJGgOrWP+ax3nsNAUN/1BOQMDrgmGADogSA4hOXH1ZJiyeYg4Ca+vUW0sEg=="
},
"Onigwrap": {
"type": "Transitive",
"resolved": "1.0.10",
Expand Down Expand Up @@ -1309,6 +1352,11 @@
"System.Threading.Tasks": "4.3.0"
}
},
"System.Security.Cryptography.ProtectedData": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "+TUFINV2q2ifyXauQXRwy4CiBhqvDEDZeVJU7qfxya4aRYOKzVBpN+4acx25VcPB9ywUN6C0n8drWl110PhZEg=="
},
"System.Security.Cryptography.X509Certificates": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -1575,6 +1623,7 @@
"Microsoft.DiaSymReader.Converter.Xml": "[1.1.0-beta2-22171-02, )",
"Microsoft.DiaSymReader.Native": "[17.0.0-beta1.21524.1, )",
"Microsoft.Extensions.DependencyInjection.Abstractions": "[10.0.9, )",
"NuGet.Protocol": "[7.6.0, )",
"ProDataGrid": "[12.0.0, )",
"Svg.Controls.Skia.Avalonia": "[12.0.0.11, )",
"System.Composition.AttributedModel": "[10.0.9, )",
Expand Down Expand Up @@ -1751,6 +1800,15 @@
"resolved": "0.11.6",
"contentHash": "f33RkDtZO8VlGXCtmQIviOtxgnUdym9xx/b1p9h91CRGOsJFxCFOFK1FDbVt1OCf1aWwYejUFa2MOQyFWTFjbA=="
},
"NuGet.Protocol": {
"type": "CentralTransitive",
"requested": "[7.6.0, )",
"resolved": "7.6.0",
"contentHash": "Ccb9dJG9hW0FdHFjXoHmhJBBJRYSCeSJArLdZjyZj6/FEAIKezLn75KFQNrTPE5UiAp4HVrjBizufZ/0IXhfKQ==",
"dependencies": {
"NuGet.Packaging": "7.6.0"
}
},
"ProDataGrid": {
"type": "CentralTransitive",
"requested": "[12.0.0, )",
Expand Down Expand Up @@ -1862,6 +1920,12 @@
"resolved": "6.1.2",
"contentHash": "2hBr6zdbIBTDE3EhK7NSVNdX58uTK6iHW/P/Axmm9sl1xoGSLqDvMtpecn226TNwHByFokYwJmt/aQQNlO5CRw=="
},
"System.Security.Cryptography.Pkcs": {
"type": "CentralTransitive",
"requested": "[10.0.9, )",
"resolved": "10.0.9",
"contentHash": "aud6Ox9eSPayMBNu6qL+Zk7yDB6ShrRxg1aMJ1uPqFTGAFVisrjFeKj6RE9SimjNKcbl+chwmiYIK4b3hvc61A=="
},
"System.Text.RegularExpressions": {
"type": "CentralTransitive",
"requested": "[4.3.1, )",
Expand Down
115 changes: 115 additions & 0 deletions ILSpy.Tests/NuGetFeeds/FakeNuGetFeedClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using ILSpy.NuGetFeeds;

namespace ICSharpCode.ILSpy.Tests.NuGetFeeds;

/// <summary>
/// Scriptable in-memory <see cref="INuGetFeedClient"/>: records every call, returns
/// configurable results, throws configurable exceptions, and can hold a download open
/// on a <see cref="TaskCompletionSource"/> so cancellation paths become testable.
/// </summary>
public sealed class FakeNuGetFeedClient : INuGetFeedClient
{
public sealed record SearchCall(string FeedUrl, string SearchText, bool IncludePrerelease, int Skip, int Take);
public sealed record VersionsCall(string FeedUrl, string PackageId, bool IncludePrerelease, int MaxCount);
public sealed record DownloadCall(string FeedUrl, string PackageId, string Version);

public List<SearchCall> SearchCalls { get; } = new();
public List<VersionsCall> VersionsCalls { get; } = new();
public List<DownloadCall> DownloadCalls { get; } = new();

/// <summary>Computes search results per call; defaults to one well-known package.</summary>
public Func<SearchCall, IReadOnlyList<NuGetPackageInfo>> SearchHandler { get; set; }
= call => new[] { MakePackage("Newtonsoft.Json") };

public Exception? SearchException { get; set; }

public IReadOnlyList<string> VersionsToReturn { get; set; } = new[] { "13.0.3", "13.0.2", "12.0.1" };

public Exception? VersionsException { get; set; }

public string DownloadResultPath { get; set; }
= @"C:\nuget-cache\newtonsoft.json\13.0.3\newtonsoft.json.13.0.3.nupkg";

public Exception? DownloadException { get; set; }

/// <summary>
/// When set, downloads do not complete until this source is resolved (or the call's
/// cancellation token fires), letting tests cancel a download mid-flight.
/// </summary>
public TaskCompletionSource<string>? PendingDownload { get; set; }

public static NuGetPackageInfo MakePackage(string id, string version = "1.0.0") => new(
Id: id,
LatestVersion: version,
Description: $"Description of {id}",
Authors: "Test Author",
IconUrl: null,
LicenseUrl: "https://licenses.example/MIT",
ProjectUrl: $"https://github.example/{id}",
Tags: "test fake",
DownloadCount: 42,
Published: new DateTimeOffset(2024, 1, 2, 0, 0, 0, TimeSpan.Zero));

public static IReadOnlyList<NuGetPackageInfo> MakePage(int count, int offset = 0)
=> Enumerable.Range(offset, count).Select(i => MakePackage($"Package{i:D3}")).ToArray();

public Task<IReadOnlyList<NuGetPackageInfo>> SearchAsync(
string feedUrl, string searchText, bool includePrerelease,
int skip, int take, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var call = new SearchCall(feedUrl, searchText, includePrerelease, skip, take);
SearchCalls.Add(call);
if (SearchException != null)
return Task.FromException<IReadOnlyList<NuGetPackageInfo>>(SearchException);
return Task.FromResult(SearchHandler(call));
}

public Task<IReadOnlyList<string>> GetVersionsAsync(
string feedUrl, string packageId, bool includePrerelease,
int maxCount, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
VersionsCalls.Add(new VersionsCall(feedUrl, packageId, includePrerelease, maxCount));
if (VersionsException != null)
return Task.FromException<IReadOnlyList<string>>(VersionsException);
return Task.FromResult(VersionsToReturn);
}

public async Task<string> DownloadToGlobalPackagesFolderAsync(
string feedUrl, string packageId, string version,
CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
DownloadCalls.Add(new DownloadCall(feedUrl, packageId, version));
if (DownloadException != null)
throw DownloadException;
if (PendingDownload != null)
return await PendingDownload.Task.WaitAsync(cancellationToken);
return DownloadResultPath;
}
}
Loading
Loading