-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
17 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
11 changes: 8 additions & 3 deletions
11
src/Microsoft.ComponentDetection.Detectors/nuget/NuGetLockfileShape.cs
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 |
---|---|---|
@@ -1,17 +1,22 @@ | ||
namespace Microsoft.ComponentDetection.Detectors.NuGet; | ||
|
||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
internal class NugetLockfileShape | ||
internal record NuGetLockfileShape | ||
{ | ||
[JsonPropertyName("version")] | ||
public int Version { get; set; } | ||
|
||
public Dictionary<string, Dictionary<string, PackageShape>> Dependencies { get; set; } | ||
[JsonPropertyName("dependencies")] | ||
public Dictionary<string, Dictionary<string, PackageShape>> Dependencies { get; set; } = new(); | ||
|
||
public class PackageShape | ||
public record PackageShape | ||
{ | ||
[JsonPropertyName("type")] | ||
public string Type { get; set; } | ||
|
||
[JsonPropertyName("resolved")] | ||
public string Resolved { get; set; } | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
test/Microsoft.ComponentDetection.Detectors.Tests/Utilities/TestLogger.cs
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,26 @@ | ||
namespace Microsoft.ComponentDetection.Detectors.Tests.Utilities; | ||
|
||
using System; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
internal class TestLogger<T> : ILogger<T>, IDisposable | ||
{ | ||
private readonly TestContext context; | ||
|
||
public TestLogger(TestContext context) | ||
=> this.context = context; | ||
|
||
public IDisposable BeginScope<TState>(TState state) | ||
where TState : notnull | ||
=> this; | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
|
||
public bool IsEnabled(LogLevel logLevel) => true; | ||
|
||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) | ||
=> this.context.WriteLine($"{logLevel} ({eventId}): {formatter(state, exception)}"); | ||
} |
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