Skip to content

Commit 67d3a0a

Browse files
format and fixes
1 parent 0deb6b8 commit 67d3a0a

28 files changed

Lines changed: 112 additions & 103 deletions

Common.ExtendedObject.Tests/BiMapTests.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public class BiMapTests
2222
[TestMethod]
2323
public void Add_ValidPair_AddsToBothSides()
2424
{
25-
var map = new BiMap<string>();
26-
map.Add("Key", "Value");
25+
var map = new BiMap<string> { { "Key", "Value" } };
2726

2827
Assert.AreEqual("Value", map.GetForward("Key"));
2928
Assert.AreEqual("Key", map.GetReverse("Value"));
@@ -36,9 +35,8 @@ public void Add_ValidPair_AddsToBothSides()
3635
[ExpectedException(typeof(ArgumentException))]
3736
public void Add_DuplicateValue_ThrowsException()
3837
{
39-
var map = new BiMap<string>();
40-
map.Add("A", "Shared");
41-
map.Add("B", "Shared"); // This should trigger your duplicate check
38+
var map = new BiMap<string> { { "A", "Shared" }, { "B", "Shared" } // This should trigger your duplicate check
39+
};
4240
}
4341

4442
/// <summary>
@@ -47,8 +45,7 @@ public void Add_DuplicateValue_ThrowsException()
4745
[TestMethod]
4846
public void Remove_RemovesFromBothSides()
4947
{
50-
var map = new BiMap<int>();
51-
map.Add(1, 100);
48+
var map = new BiMap<int> { { 1, 100 } };
5249
map.RemoveByLeft(1);
5350

5451
Assert.IsFalse(map.Contains(1));

Communication/Listener.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ public void StopListening()
9393
}
9494

9595
/// <summary>
96-
/// Handles the client.
96+
/// Handles the client.
9797
/// </summary>
98-
/// <param name="obj">The object.</param>
98+
/// <param name="client">The client.</param>
9999
private static async Task HandleClientAsync(TcpClient client)
100100
{
101101
try

Communication/NetCom.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ public Task<bool> SaveFile(string filePath, string url, IProgress<int>? progress
3838
}
3939

4040
/// <inheritdoc />
41-
/// <summary>
42-
/// Saves the file.
43-
/// </summary>
44-
/// <param name="filePath">The file path.</param>
4541
public Task SaveFile(string filePath, IEnumerable<string> urls, IProgress<int>? progress = null,
4642
CancellationToken cancellationToken = default)
4743
{

Core.Apps/CommandFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public static IReadOnlyList<ICommand> GetCommands(Weave? weave = null)
4848
new HotPathAnalyzer(), new LicenseHeaderAnalyzer(), new UnusedClassAnalyzer(),
4949
new UnusedConstantAnalyzer(), new UnusedLocalVariableAnalyzer(), new UnusedParameterAnalyzer(),
5050
new UnusedPrivateFieldAnalyzer(), new DocCommentCoverageCommand(), new DeadReferenceAnalyzer(),
51-
new ApiExplorerCommand(), new LogTailCommand(), new SmartPingPro(), new Tree(), new StructPaddingAnalyzer(),
52-
new UnusedMemberAnalyzer(), new MagicNumberAnalyzer()
51+
new ApiExplorerCommand(), new LogTailCommand(), new SmartPingPro(), new Tree(),
52+
new StructPaddingAnalyzer(), new UnusedMemberAnalyzer(), new MagicNumberAnalyzer()
5353
});
5454

5555
// --- PRODUCERS (Require Registry) ---

Core.Apps/Development/DependencyExplorer.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
namespace Core.Apps.Development
2020
{
21+
/// <inheritdoc cref="ICommand" />
22+
/// <summary>
23+
/// Builds a map of project dependencies by scanning .csproj files in a given directory. It extracts both NuGet package references and project references, creating a structured representation of how projects depend on each other and on external libraries. The resulting map is stored in the registry for use in WPF visualizations or scripts, allowing developers to easily understand and analyze their project's dependency graph.
24+
/// </summary>
25+
/// <seealso cref="Weaver.Interfaces.ICommand" />
26+
/// <seealso cref="Weaver.Interfaces.IRegistryProducer" />
2127
public sealed class DependencyExplorer : ICommand, IRegistryProducer
2228
{
2329
/// <summary>
@@ -58,6 +64,7 @@ public DependencyExplorer(IVariableRegistry variables)
5864
/// <inheritdoc />
5965
public CommandSignature Signature => new(Namespace, Name, ParameterCount);
6066

67+
/// <inheritdoc />
6168
/// <inheritdoc />
6269
public CommandResult Execute(params string[] args)
6370
{
@@ -89,14 +96,9 @@ public CommandResult Execute(params string[] args)
8996
.Where(v => !string.IsNullOrEmpty(v))
9097
.ToList();
9198

92-
// 4. Create a Sub-Object for this project
93-
var details = new Dictionary<string, VmValue>
94-
{
95-
{ "packages", VmValue.FromString(string.Join(", ", packages)) },
96-
{ "references", VmValue.FromString(string.Join(", ", refs)) }
97-
};
98-
99-
projectMap[projName] = VmValue.FromObject(); // In your registry, this links to the dict
99+
// 4. Flatten directly into projectMap using prefixed keys
100+
projectMap[$"{projName}.packages"] = VmValue.FromString(string.Join(", ", packages));
101+
projectMap[$"{projName}.references"] = VmValue.FromString(string.Join(", ", refs));
100102

101103
sb.AppendLine($"Project: {projName}");
102104
sb.AppendLine($" - Libraries: {string.Join(", ", packages)}");

Core.Apps/Diagnostic.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public Diagnostic(string name, DiagnosticSeverity severity, string filePath, int
9393
/// </value>
9494
public string SeveritySymbol => Severity switch
9595
{
96-
DiagnosticSeverity.Error => "\U0001F534", // 🔴
96+
DiagnosticSeverity.Error => "\U0001F534", // 🔴
9797
DiagnosticSeverity.Warning => "\U0001F7E1", // 🟡
98-
DiagnosticSeverity.Info => "\U0001F535", // 🔵
99-
_ => "\u26AA" // ⚪
98+
DiagnosticSeverity.Info => "\U0001F535", // 🔵
99+
_ => "\u26AA" // ⚪
100100
};
101101

102102
/// <summary>

Core.Apps/FileManager/Tree.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
// ReSharper disable UnusedType.Global
10+
// ReSharper disable MemberCanBeInternal
1011

1112
using System;
1213
using System.IO;
@@ -66,15 +67,15 @@ public CommandResult Execute(params string[] args)
6667
/// <summary>
6768
/// Recursively builds the directory structure.
6869
/// </summary>
69-
private void BuildTree(string path, StringBuilder sb, string indent, bool last)
70+
private static void BuildTree(string path, StringBuilder sb, string indent, bool last)
7071
{
7172
var prefix = last ? "└── " : "├── ";
7273
sb.AppendLine($"{indent}{prefix}{Path.GetFileName(path)}");
7374

7475
indent += last ? " " : "│ ";
7576

76-
var dirs = Array.Empty<string>();
77-
var files = Array.Empty<string>();
77+
string[] dirs;
78+
string[] files;
7879

7980
try
8081
{

Core.Apps/Rules/MagicNumberAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Core.Apps.Rules
2424
{
2525
/// <inheritdoc cref="ICodeAnalyzer" />
2626
/// <summary>
27-
/// Analyzer that detects unexplained numeric literals (magic numbers) in method bodies, which can hurt readability and maintainability.
27+
/// Analyzer that detects unexplained numeric literals (magic numbers) in method bodies, which can hurt readability and maintainability.
2828
/// It ignores common "safe" numbers like 0, 1, -1, and 2, as well as literals that are part of constant definitions.
2929
/// </summary>
3030
/// <seealso cref="ICommand" />
@@ -61,7 +61,6 @@ public IEnumerable<Diagnostic> Analyze(string filePath, string fileContent)
6161
.AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location))
6262
.AddSyntaxTrees(tree);
6363

64-
var model = compilation.GetSemanticModel(tree);
6564
var root = tree.GetCompilationUnitRoot();
6665

6766
// Find all methods
@@ -113,7 +112,8 @@ public CommandResult Execute(params string[] args)
113112
{
114113
var results = AnalyzerExecutor.ExecutePath(this, args, "Usage: MagicNumber <fileOrDirectoryPath>");
115114
var output = results.Count > 0
116-
? string.Join("\n", results.Select(d => $"{Path.GetFileName(d.FilePath)} ({d.LineNumber}): {d.Message}"))
115+
? string.Join("\n",
116+
results.Select(d => $"{Path.GetFileName(d.FilePath)} ({d.LineNumber}): {d.Message}"))
117117
: "No magic numbers found.";
118118
return CommandResult.Ok(output, EnumTypes.Wstring);
119119
}

Core.Apps/Rules/StructPaddingAnalyzer.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ namespace Core.Apps.Rules
2828
/// <seealso cref="ICommand" />
2929
public sealed class StructPaddingAnalyzer : ICodeAnalyzer, ICommand
3030
{
31-
3231
/// <inheritdoc cref="ICodeAnalyzer" />
3332
public string Name => "StructPadding";
3433

@@ -55,10 +54,8 @@ public IEnumerable<Diagnostic> Analyze(string filePath, string fileContent)
5554
foreach (var structDecl in root.DescendantNodes().OfType<StructDeclarationSyntax>())
5655
{
5756
var fields = structDecl.Members.OfType<FieldDeclarationSyntax>();
58-
var fieldList = fields.SelectMany(f => f.Declaration.Variables.Select(v => new {
59-
Name = v.Identifier.Text,
60-
Size = GetFieldSize(f.Declaration.Type.ToString())
61-
})).ToList();
57+
var fieldList = fields.SelectMany(f => f.Declaration.Variables.Select(v =>
58+
new { Name = v.Identifier.Text, Size = GetFieldSize(f.Declaration.Type.ToString()) })).ToList();
6259

6360
if (fieldList.Count <= 1) continue;
6461

Core.Apps/Rules/UnusedMemberAnalyzer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Core.Apps.Rules
2424
{
2525
/// <inheritdoc cref="ICodeAnalyzer" />
2626
/// <summary>
27-
/// Analyzer that detects unused private fields, methods, and constants in a file. It uses the Roslyn API to parse the C# code, identify private members, and check if they are referenced anywhere in the file. If a private member is found to be unused, it reports a diagnostic message indicating the member's name and location.
27+
/// Analyzer that detects unused private fields, methods, and constants in a file. It uses the Roslyn API to parse the C# code, identify private members, and check if they are referenced anywhere in the file. If a private member is found to be unused, it reports a diagnostic message indicating the member's name and location.
2828
/// This helps developers identify and clean up dead code, improving readability and maintainability.
2929
/// </summary>
3030
/// <seealso cref="ICommand" />
@@ -101,7 +101,8 @@ public CommandResult Execute(params string[] args)
101101

102102
if (results.Count == 0) return CommandResult.Ok("No unused private members found.");
103103

104-
var output = string.Join("\n", results.Select(d => $"{Path.GetFileName(d.FilePath)} ({d.LineNumber}): {d.Message}"));
104+
var output = string.Join("\n",
105+
results.Select(d => $"{Path.GetFileName(d.FilePath)} ({d.LineNumber}): {d.Message}"));
105106
return CommandResult.Ok($"Unused members detected:\n{output}", EnumTypes.Wstring);
106107
}
107108
catch (Exception ex)

0 commit comments

Comments
 (0)