Skip to content

Commit

Permalink
Merge pull request #16 from danielklecha/master
Browse files Browse the repository at this point in the history
display number of unique files in summary
  • Loading branch information
danielklecha authored Mar 15, 2024
2 parents 6f2746d + 692baeb commit f95ca4a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/DotnetThirdPartyNotices/Commands/ScanCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ private async Task GenerateOutputFileAsync(string? outputFilePath)
{
if (outputFilePath == null)
return;
logger.LogInformation("Resolved {LicenseContentsCount} licenses for {Sum}/{ResolvedFilesCount} files", _licenseContents.Count, _licenseContents.Values.Sum(v => v.Count), _licenseContents.Values.Sum(v => v.Count) + _unresolvedFiles.Count);
var uniqueResolvedFilesCount = _licenseContents.Values.Sum(v => v.GroupBy(x => x.SourcePath).Count());
var uniqueUnresolvedFilesCount = _unresolvedFiles.GroupBy(x => x.SourcePath).Count();
logger.LogInformation("Resolved {LicenseContentsCount} licenses for {Sum}/{ResolvedFilesCount} files", _licenseContents.Count, uniqueResolvedFilesCount, uniqueResolvedFilesCount + uniqueUnresolvedFilesCount);
logger.LogInformation("Unresolved files: {UnresolvedFilesCount}", _unresolvedFiles.Count);
var stopWatch = new Stopwatch();
stopWatch.Start();
var stringBuilder = new StringBuilder();
foreach (var (licenseContent, resolvedFileInfos) in _licenseContents)
{
var longestNameLen = 0;
foreach (var resolvedFileInfo in resolvedFileInfos)
foreach (var resolvedFileInfo in resolvedFileInfos.GroupBy(x => x.SourcePath).Select(x => x.First()))
{
var strLen = resolvedFileInfo.RelativeOutputPath?.Length ?? 0;
if (strLen > longestNameLen)
Expand Down
2 changes: 1 addition & 1 deletion src/DotnetThirdPartyNotices/DotnetThirdPartyNotices.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ToolCommandName>dotnet-thirdpartynotices</ToolCommandName>
<PackageId>DotnetThirdPartyNotices</PackageId>
<Description>A .NET tool to generate file with third party legal notices</Description>
<PackageVersion>0.3.1</PackageVersion>
<PackageVersion>0.3.2</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/bugproof/DotnetThirdPartyNotices</RepositoryUrl>
Expand Down
4 changes: 2 additions & 2 deletions src/DotnetThirdPartyNotices/Models/ResolvedFileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace DotnetThirdPartyNotices.Models;

internal class ResolvedFileInfo
internal class ResolvedFileInfo(string sourcePath)
{
public string? SourcePath { get; init; }
public string SourcePath { get; } = sourcePath;
public string? RelativeOutputPath { get; init; }
public FileVersionInfo? VersionInfo { get; init; }
public NuSpec? NuSpec { get; init; }
Expand Down
6 changes: 2 additions & 4 deletions src/DotnetThirdPartyNotices/Services/ProjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ private IEnumerable<ResolvedFileInfo> ResolveFilesUsingResolveAssemblyReferences
var assemblyPath = item.EvaluatedInclude;
var versionInfo = FileVersionInfo.GetVersionInfo(assemblyPath);
var packagePath = localPackageService.GetPackagePathFromAssemblyPath(assemblyPath);
var resolvedFileInfo = new ResolvedFileInfo
var resolvedFileInfo = new ResolvedFileInfo(assemblyPath)
{
SourcePath = assemblyPath,
VersionInfo = versionInfo,
RelativeOutputPath = Path.GetFileName(assemblyPath),
PackagePath = packagePath,
Expand Down Expand Up @@ -81,9 +80,8 @@ private IEnumerable<ResolvedFileInfo> ResolveFilesUsingComputeFilesToPublish(Pro
var relativePath = item.GetMetadataValue("RelativePath");
var packagePath = localPackageService.GetPackagePathFromAssemblyPath(assemblyPath);
var nuSpec = localPackageService.GetNuSpecFromPackagePath(packagePath) ?? throw new ApplicationException($"Cannot find package path from assembly path ({assemblyPath})");
var resolvedFileInfo = new ResolvedFileInfo
var resolvedFileInfo = new ResolvedFileInfo(assemblyPath)
{
SourcePath = assemblyPath,
VersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath),
NuSpec = nuSpec,
RelativeOutputPath = relativePath,
Expand Down

0 comments on commit f95ca4a

Please sign in to comment.