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.
7 changes: 5 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 @@ -100,7 +101,8 @@ private async Task TryClassifyItem(
}
}
catch (OperationCanceledException) { throw; }
catch (Exception ex) { await Console.Error.WriteLineAsync($"Error while processing '{item.Value}': {ex}"); }
// 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 Down Expand Up @@ -132,7 +134,8 @@ await Parallel.ForEachAsync(
catch (OperationCanceledException) { throw; }
catch (Exception ex)
{
await Console.Error.WriteLineAsync($"Error while processing '{item.Value}': {ex}");
// await Console.Error.WriteLineAsync($"Error while processing '{item.Value}': {ex}");
Logger.LogError($"Error while processing '{item.Value}': {ex}");
return null;
}
}
Expand Down
5 changes: 5 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 @@ -30,11 +31,15 @@ public async Task RunAsync(CancellationToken ct = default)
{
if (diff)
{
Logger.LogInformation("Running diff use case");
var compareGraph = await snapshotManager.GetLastSavedDependencyGraphAsync(snapshotOptions, ct) ?? throw new InvalidOperationException("Diff mode requires a saved snapshot, but none was found.");
await renderer.RenderDiffViewsAndSaveToFiles(graph, compareGraph, renderOptions, ct);
}
else
{
Logger.LogInformation("Running non-diff use case");
await renderer.RenderViewsAndSaveToFiles(graph, renderOptions, ct);
}
}

await snapshotManager.SaveGraphAsync(graph, snapshotOptions, ct);
Expand Down
8 changes: 7 additions & 1 deletion CoDepend/Domain/DependencyGraphSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CoDepend.Domain.Models.Records;
using MessagePack;
using MessagePack.Resolvers;
using CoDepend.Infra;

namespace CoDepend.Domain;

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

return MessagePackSerializer.Serialize(dto, MsgPackOptions);
byte[] bytes = MessagePackSerializer.Serialize(dto, MsgPackOptions);

if (bytes.Length == 0) { Logger.LogWarning("byte[] is empty"); }
else { Logger.LogInformation($"Length of byte[] is {bytes.Length}"); }

return bytes;
}

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

namespace CoDepend.Infra;

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

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

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