-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor nuget loader to ensure common Doki dependencies satisfy currently installed Doki.CommandLine version * use ASCII logger in NuGet loader * cleanup * test version safe nuget loader
- Loading branch information
1 parent
f07aa75
commit 5010f7b
Showing
8 changed files
with
216 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using Microsoft.Extensions.Logging; | ||
using NuGet.Common; | ||
using ILogger = NuGet.Common.ILogger; | ||
using LogLevel = NuGet.Common.LogLevel; | ||
|
||
namespace Doki.CommandLine.NuGet; | ||
|
||
internal class NuGetLogger(Microsoft.Extensions.Logging.ILogger logger) : ILogger | ||
{ | ||
public void LogDebug(string data) | ||
{ | ||
logger.LogDebug(data); | ||
} | ||
|
||
public void LogVerbose(string data) | ||
{ | ||
logger.LogTrace(data); | ||
} | ||
|
||
public void LogInformation(string data) | ||
{ | ||
logger.LogInformation(data); | ||
} | ||
|
||
public void LogMinimal(string data) | ||
{ | ||
logger.LogInformation(data); | ||
} | ||
|
||
public void LogWarning(string data) | ||
{ | ||
logger.LogWarning(data); | ||
} | ||
|
||
public void LogError(string data) | ||
{ | ||
logger.LogError(data); | ||
} | ||
|
||
public void LogInformationSummary(string data) | ||
{ | ||
logger.LogInformation(data); | ||
} | ||
|
||
public void Log(LogLevel level, string data) | ||
{ | ||
switch (level) | ||
{ | ||
case LogLevel.Debug: | ||
LogDebug(data); | ||
break; | ||
case LogLevel.Verbose: | ||
LogVerbose(data); | ||
break; | ||
case LogLevel.Information: | ||
LogInformation(data); | ||
break; | ||
case LogLevel.Minimal: | ||
LogMinimal(data); | ||
break; | ||
case LogLevel.Warning: | ||
LogWarning(data); | ||
break; | ||
case LogLevel.Error: | ||
LogError(data); | ||
break; | ||
} | ||
} | ||
|
||
public Task LogAsync(LogLevel level, string data) | ||
{ | ||
Log(level, data); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public void Log(ILogMessage message) | ||
{ | ||
Log(message.Level, message.Message); | ||
} | ||
|
||
public Task LogAsync(ILogMessage message) | ||
{ | ||
return LogAsync(message.Level, message.Message); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/Doki.CommandLine.Tests/Doki.CommandLine.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/> | ||
<PackageReference Include="xunit" Version="2.4.2"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Doki.CommandLine\Doki.CommandLine.csproj" /> | ||
<ProjectReference Include="..\Doki.Tests.Common\Doki.Tests.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Doki.CommandLine.NuGet; | ||
using Doki.Tests.Common; | ||
using Xunit.Abstractions; | ||
|
||
namespace Doki.CommandLine.Tests; | ||
|
||
public class NuGetTests(ITestOutputHelper testOutputHelper) | ||
{ | ||
[Fact] | ||
public async Task NuGetLoader_TestAsync() | ||
{ | ||
const string packageId = "Doki.Output.Json"; | ||
var tmpDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
|
||
var logger = new TestOutputLogger(testOutputHelper); | ||
|
||
using var loader = new NuGetLoader(logger); | ||
|
||
await loader.LoadPackageAsync(packageId, tmpDirectory); | ||
|
||
Assert.False(logger.HadError); | ||
|
||
var dllPath = Path.Combine(tmpDirectory, $"{packageId}.1.0.0", "lib", "net8.0", $"{packageId}.dll"); | ||
|
||
Assert.True(File.Exists(dllPath)); | ||
} | ||
} |