Skip to content
Open
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
Binary file modified CoDepend/.codepend/snapshot
Binary file not shown.
8 changes: 6 additions & 2 deletions CoDepend/Application/DependencyGraphBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using CoDepend.Domain.Models;
using CoDepend.Domain.Models.Records;
using CoDepend.Domain.Utils;
using CoDepend.Infra;

namespace CoDepend.Application;

Expand Down Expand Up @@ -80,6 +81,7 @@ private async Task TryClassifyItem(
List<(RelativePath Parent, RelativePath Item, string AbsPath)> fileItems,
CancellationToken ct)
{
var logger = new Logger();
try
{
ct.ThrowIfCancellationRequested();
Expand All @@ -100,7 +102,8 @@ private async Task TryClassifyItem(
}
}
catch (OperationCanceledException) { throw; }
catch (Exception ex) { await Console.Error.WriteLineAsync($"Error while processing '{item.Value}': {ex}"); }

catch (Exception ex) { logger.LogError($"Error while processing '{item.Value}': {ex}"); }
}

private async Task<IEnumerable<(RelativePath Parent, RelativePath Item, IReadOnlyList<RelativePath> Deps)>> ParseAllAsync(
Expand All @@ -122,6 +125,7 @@ await Parallel.ForEachAsync(
CancellationToken ct)
{
var (parent, item, absPath) = fileItem;
var logger = new Logger();
try
{
var deps = new List<RelativePath>();
Expand All @@ -132,7 +136,7 @@ await Parallel.ForEachAsync(
catch (OperationCanceledException) { throw; }
catch (Exception ex)
{
await Console.Error.WriteLineAsync($"Error while processing '{item.Value}': {ex}");
logger.LogError($"Error while processing '{item.Value}': {ex}");
return null;
}
}
Expand Down
4 changes: 4 additions & 0 deletions CoDepend/Application/UpdateGraphUseCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using CoDepend.Domain.Interfaces;
using CoDepend.Domain.Models.Enums;
using CoDepend.Domain.Models.Records;
using CoDepend.Infra;

namespace CoDepend.Application;

Expand All @@ -25,15 +26,18 @@ public async Task RunAsync(CancellationToken ct = default)
var snapshotGraph = await snapshotManager.GetLastSavedDependencyGraphAsync(snapshotOptions, ct);
var projectChanges = await ChangeDetector.GetProjectChangesAsync(parserOptions, snapshotGraph, ct);
var graph = await new DependencyGraphBuilder(parsers, baseOptions).GetGraphAsync(projectChanges, snapshotGraph, ct);
var logger = new Logger();

if (renderOptions.Format != RenderFormat.None)
{
if (diff)
{
var compareGraph = await snapshotManager.GetLastSavedDependencyGraphAsync(snapshotOptions, ct) ?? throw new InvalidOperationException("Diff mode requires a saved snapshot, but none was found.");
logger.LogInformation("Running diff use case");
await renderer.RenderDiffViewsAndSaveToFiles(graph, compareGraph, renderOptions, ct);
}
else
logger.LogInformation("Running non-diff use case");
await renderer.RenderViewsAndSaveToFiles(graph, renderOptions, ct);
}

Expand Down
14 changes: 13 additions & 1 deletion CoDepend/Domain/DependencyGraphSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using CoDepend.Domain.Models;
using CoDepend.Domain.Models.Records;
using CoDepend.Infra;
using MessagePack;
using MessagePack.Resolvers;

Expand Down Expand Up @@ -109,7 +110,18 @@ public static byte[] Serialize(ProjectDependencyGraph graph, int version = 1)
DependsOn = dependsOn,
};

return MessagePackSerializer.Serialize(dto, MsgPackOptions);
var logger = new Logger();

var bArr = MessagePackSerializer.Serialize(dto, MsgPackOptions);

if(bArr.Any())
{
logger.LogInformation(bArr.Length.ToString());
}else
{
logger.LogWarning(bArr.Length.ToString());
}
return bArr;
}

public static ProjectDependencyGraph Deserialize(byte[] data, string projectRoot)
Expand Down
27 changes: 27 additions & 0 deletions CoDepend/Infra/Logger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace CoDepend.Infra;

public class Logger
{
public Logger()
{

}

public void LogInformation(string input)
{
Console.WriteLine($"INFO: {input}");
}


public void LogWarning(string input)
{
Console.WriteLine($"WARN: {input}");
}

public void LogError(string input)
{
Console.Error.WriteLine($"ERROR: {input}");
}
}