Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deadlock on IsNuGetPublished #152

Merged
merged 2 commits into from
Oct 11, 2023
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
12 changes: 12 additions & 0 deletions source/Cake.ExtendedNuGet.Tests/ExtendedNuGetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ public void IsNuGetPublishedAltSrcShouldBeFalse ()
Assert.False (p);
}

[Fact]
public void IsNugetPublishedInvalidSourceShouldBeFalse ()
{
var p = context.CakeContext.IsNuGetPublished (
"Xamarin.Android.Support.v4",
"23.1.1.0",
"https://api.nuget.org/v3/wrong.json"
);

Assert.False (p);
}

[Fact]
public void NuGetPackageIdFromFile ()
{
Expand Down
18 changes: 12 additions & 6 deletions source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;

using LogLevel = Cake.Core.Diagnostics.LogLevel;
using Verbosity = Cake.Core.Diagnostics.Verbosity;

namespace Cake.ExtendedNuGet
{
/// <summary>
Expand Down Expand Up @@ -112,18 +115,21 @@

Task.Run(async () =>
{
var nuSource = Repository.Factory.GetCoreV3(nugetSource);
using var nuCache = new SourceCacheContext();
var nuLogger = NullLogger.Instance;
var pkgRes = await nuSource.GetResourceAsync<FindPackageByIdResource>();

try
{
var nuSource = Repository.Factory.GetCoreV3(nugetSource);
using var nuCache = new SourceCacheContext();
var nuLogger = NullLogger.Instance;

var pkgRes = await nuSource.GetResourceAsync<FindPackageByIdResource>();
var pkgInfo = await pkgRes.GetDependencyInfoAsync(packageId, new NuGetVersion(version.ToString()), nuCache, nuLogger, default);
tcsPublished.TrySetResult(pkgInfo?.PackageIdentity?.Id?.Equals(packageId, StringComparison.OrdinalIgnoreCase) ?? false);
}
catch
catch(Exception ex)

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (macos-12)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (macos-12)

The keyword 'catch' should be followed by a space.

Check warning on line 128 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (macos-12)

The keyword 'catch' should be followed by a space.
{
context.Log.Write(Verbosity.Diagnostic, LogLevel.Error,
$"Failed to read nuget source repository information: {ex.Message}");

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (macos-12)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (macos-12)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

Check warning on line 131 in source/Cake.ExtendedNuGet/ExtendedNuGetAliases.cs

View workflow job for this annotation

GitHub Actions / build (macos-12)

The parameters should all be placed on the same line or each parameter should be placed on its own line.

tcsPublished.TrySetResult(false);
}
});
Expand Down
Loading