style: apply CSharpier formatting to all C# sources

Repo-wide sweep with the pinned CSharpier 1.3.0 tool. Whitespace and
line-wrapping only; OpenNest.Engine.Tests (109) and OpenNest.IO.Tests
pass after reformat, full solution builds 0 errors.

Added .csharpierignore so csproj/config XML keeps its existing layout
(CSharpier's XML wrapping churns attributes with zero benefit).

Formatting is now enforceable: dotnet csharpier check . passes.
This commit is contained in:
aj
2026-09-20 16:41:50 -04:00
parent 8e6fa677fb
commit aec0523062
476 changed files with 16592 additions and 7800 deletions
@@ -14,7 +14,10 @@ public class ColumnFillStrategy : IFillStrategy
if (context.PartType == PartType.Rectangle)
return null;
var filler = new StripeFiller(context, NestDirection.Vertical) { CompleteStripesOnly = true };
var filler = new StripeFiller(context, NestDirection.Vertical)
{
CompleteStripesOnly = true,
};
return filler.Fill();
}
}
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using OpenNest.Engine.Fill;
using OpenNest.Math;
using System.Collections.Generic;
namespace OpenNest.Engine.Strategies
{
@@ -22,10 +22,13 @@ namespace OpenNest.Engine.Strategies
var angles = new[] { bestRotation, bestRotation + Angle.HalfPI };
return FillHelpers.BestOverAngles(context, angles,
angle => filler.Fill(context.Item.Drawing, angle,
context.Token, context.ReportProgress),
"Extents");
return FillHelpers.BestOverAngles(
context,
angles,
angle =>
filler.Fill(context.Item.Drawing, angle, context.Token, context.ReportProgress),
"Extents"
);
}
}
}
+19 -13
View File
@@ -1,9 +1,9 @@
using OpenNest.Engine;
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
using System;
using System.Collections.Generic;
using System.Threading;
using OpenNest.Engine;
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
namespace OpenNest.Engine.Strategies
{
@@ -20,6 +20,7 @@ namespace OpenNest.Engine.Strategies
public PartType PartType { get; set; }
public List<Part> CurrentBest { get; set; }
/// <summary>For progress reporting only; comparisons use Policy.Comparer.</summary>
public FillScore CurrentBestScore { get; set; }
public NestPhase WinnerPhase { get; set; }
@@ -37,7 +38,9 @@ namespace OpenNest.Engine.Strategies
/// </summary>
public void ReportProgress(List<Part> parts, string description)
{
var isNewBest = parts != null && parts.Count > 0
var isNewBest =
parts != null
&& parts.Count > 0
&& Policy.Comparer.IsBetter(parts, CurrentBest, WorkArea);
if (isNewBest)
@@ -47,15 +50,18 @@ namespace OpenNest.Engine.Strategies
WinnerPhase = ActivePhase;
}
NestEngineBase.ReportProgress(Progress, new ProgressReport
{
Phase = ActivePhase,
PlateNumber = PlateNumber,
Parts = isNewBest ? parts : CurrentBest,
WorkArea = WorkArea,
Description = description,
IsOverallBest = isNewBest,
});
NestEngineBase.ReportProgress(
Progress,
new ProgressReport
{
Phase = ActivePhase,
PlateNumber = PlateNumber,
Parts = isNewBest ? parts : CurrentBest,
WorkArea = WorkArea,
Description = description,
IsOverallBest = isNewBest,
}
);
}
}
}
+45 -29
View File
@@ -1,10 +1,10 @@
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
using OpenNest.Math;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
using OpenNest.Math;
namespace OpenNest.Engine.Strategies
{
@@ -30,25 +30,34 @@ namespace OpenNest.Engine.Strategies
return pattern;
}
public static List<Part> FillPattern(FillLinear engine, List<Part> groupParts, List<double> angles, Box workArea, IFillComparer comparer = null)
public static List<Part> FillPattern(
FillLinear engine,
List<Part> groupParts,
List<double> angles,
Box workArea,
IFillComparer comparer = null
)
{
var results = new ConcurrentBag<(List<Part> Parts, FillScore Score)>();
Parallel.ForEach(angles, angle =>
{
var pattern = BuildRotatedPattern(groupParts, angle);
Parallel.ForEach(
angles,
angle =>
{
var pattern = BuildRotatedPattern(groupParts, angle);
if (pattern.Parts.Count == 0)
return;
if (pattern.Parts.Count == 0)
return;
var h = engine.Fill(pattern, NestDirection.Horizontal);
if (h != null && h.Count > 0)
results.Add((h, FillScore.Compute(h, workArea)));
var h = engine.Fill(pattern, NestDirection.Horizontal);
if (h != null && h.Count > 0)
results.Add((h, FillScore.Compute(h, workArea)));
var v = engine.Fill(pattern, NestDirection.Vertical);
if (v != null && v.Count > 0)
results.Add((v, FillScore.Compute(v, workArea)));
});
var v = engine.Fill(pattern, NestDirection.Vertical);
if (v != null && v.Count > 0)
results.Add((v, FillScore.Compute(v, workArea)));
}
);
List<Part> best = null;
var bestScore = default(FillScore);
@@ -82,7 +91,8 @@ namespace OpenNest.Engine.Strategies
Func<NestDirection, List<Part>> fillFunc,
NestDirection? preferred,
IFillComparer comparer,
Box workArea)
Box workArea
)
{
if (preferred == null)
{
@@ -92,15 +102,18 @@ namespace OpenNest.Engine.Strategies
if ((h == null || h.Count == 0) && (v == null || v.Count == 0))
return new List<Part>();
if (h == null || h.Count == 0) return v;
if (v == null || v.Count == 0) return h;
if (h == null || h.Count == 0)
return v;
if (v == null || v.Count == 0)
return h;
return comparer.IsBetter(h, v, workArea) ? h : v;
}
var other = preferred == NestDirection.Horizontal
? NestDirection.Vertical
: NestDirection.Horizontal;
var other =
preferred == NestDirection.Horizontal
? NestDirection.Vertical
: NestDirection.Horizontal;
var pref = fillFunc(preferred.Value);
if (pref != null && pref.Count > 0)
@@ -119,7 +132,8 @@ namespace OpenNest.Engine.Strategies
FillContext context,
IReadOnlyList<double> angles,
Func<double, List<Part>> fillAtAngle,
string phaseLabel)
string phaseLabel
)
{
var workArea = context.WorkArea;
var comparer = context.Policy?.Comparer ?? new DefaultFillComparer();
@@ -139,8 +153,10 @@ namespace OpenNest.Engine.Strategies
best = result;
}
context.ReportProgress(best,
$"{phaseLabel}: {i + 1}/{angles.Count} angles, {angleDeg:F0}° best = {best?.Count ?? 0} parts");
context.ReportProgress(
best,
$"{phaseLabel}: {i + 1}/{angles.Count} angles, {angleDeg:F0}° best = {best?.Count ?? 0} parts"
);
}
return best ?? new List<Part>();
@@ -160,10 +176,10 @@ namespace OpenNest.Engine.Strategies
{
var b2 = parts[j].BoundingBox;
var overlapX = System.Math.Min(b1.Right, b2.Right)
- System.Math.Max(b1.Left, b2.Left);
var overlapY = System.Math.Min(b1.Top, b2.Top)
- System.Math.Max(b1.Bottom, b2.Bottom);
var overlapX =
System.Math.Min(b1.Right, b2.Right) - System.Math.Max(b1.Left, b2.Left);
var overlapY =
System.Math.Min(b1.Top, b2.Top) - System.Math.Max(b1.Bottom, b2.Bottom);
if (overlapX <= Tolerance.Epsilon || overlapY <= Tolerance.Epsilon)
continue;
@@ -19,8 +19,7 @@ namespace OpenNest.Engine.Strategies
LoadFrom(typeof(FillStrategyRegistry).Assembly);
}
public static IReadOnlyList<IFillStrategy> Strategies =>
sorted ??= FilterStrategies();
public static IReadOnlyList<IFillStrategy> Strategies => sorted ??= FilterStrategies();
/// <summary>
/// Returns all registered strategies regardless of enabled/disabled state.
@@ -35,9 +34,10 @@ namespace OpenNest.Engine.Strategies
private static List<IFillStrategy> FilterStrategies()
{
var source = enabledFilter != null
? strategies.Where(s => enabledFilter.Contains(s.Name))
: strategies.Where(s => !disabled.Contains(s.Name));
var source =
enabledFilter != null
? strategies.Where(s => enabledFilter.Contains(s.Name))
: strategies.Where(s => !disabled.Contains(s.Name));
return source.OrderBy(s => s.Order).ToList();
}
@@ -68,9 +68,10 @@ namespace OpenNest.Engine.Strategies
/// </summary>
public static void SetEnabled(params string[] names)
{
enabledFilter = names != null && names.Length > 0
? new HashSet<string>(names, StringComparer.OrdinalIgnoreCase)
: null;
enabledFilter =
names != null && names.Length > 0
? new HashSet<string>(names, StringComparer.OrdinalIgnoreCase)
: null;
sorted = null;
}
@@ -78,13 +79,19 @@ namespace OpenNest.Engine.Strategies
{
foreach (var type in assembly.GetTypes())
{
if (type.IsAbstract || type.IsInterface || !typeof(IFillStrategy).IsAssignableFrom(type))
if (
type.IsAbstract
|| type.IsInterface
|| !typeof(IFillStrategy).IsAssignableFrom(type)
)
continue;
var ctor = type.GetConstructor(Type.EmptyTypes);
if (ctor == null)
{
Debug.WriteLine($"[FillStrategyRegistry] Skipping {type.Name}: no parameterless constructor");
Debug.WriteLine(
$"[FillStrategyRegistry] Skipping {type.Name}: no parameterless constructor"
);
continue;
}
@@ -92,18 +99,28 @@ namespace OpenNest.Engine.Strategies
{
var instance = (IFillStrategy)ctor.Invoke(null);
if (strategies.Any(s => s.Name.Equals(instance.Name, StringComparison.OrdinalIgnoreCase)))
if (
strategies.Any(s =>
s.Name.Equals(instance.Name, StringComparison.OrdinalIgnoreCase)
)
)
{
Debug.WriteLine($"[FillStrategyRegistry] Duplicate strategy '{instance.Name}' skipped");
Debug.WriteLine(
$"[FillStrategyRegistry] Duplicate strategy '{instance.Name}' skipped"
);
continue;
}
strategies.Add(instance);
Debug.WriteLine($"[FillStrategyRegistry] Registered: {instance.Name} (Order={instance.Order})");
Debug.WriteLine(
$"[FillStrategyRegistry] Registered: {instance.Name} (Order={instance.Order})"
);
}
catch (Exception ex)
{
Debug.WriteLine($"[FillStrategyRegistry] Failed to instantiate {type.Name}: {ex.Message}");
Debug.WriteLine(
$"[FillStrategyRegistry] Failed to instantiate {type.Name}: {ex.Message}"
);
}
}
@@ -121,11 +138,15 @@ namespace OpenNest.Engine.Strategies
{
var assembly = Assembly.LoadFrom(dll);
LoadFrom(assembly);
Debug.WriteLine($"[FillStrategyRegistry] Loaded plugin assembly: {Path.GetFileName(dll)}");
Debug.WriteLine(
$"[FillStrategyRegistry] Loaded plugin assembly: {Path.GetFileName(dll)}"
);
}
catch (Exception ex)
{
Debug.WriteLine($"[FillStrategyRegistry] Failed to load {Path.GetFileName(dll)}: {ex.Message}");
Debug.WriteLine(
$"[FillStrategyRegistry] Failed to load {Path.GetFileName(dll)}: {ex.Message}"
);
}
}
}
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using OpenNest.Engine.Fill;
using OpenNest.Math;
using System.Collections.Generic;
namespace OpenNest.Engine.Strategies
{
@@ -20,27 +20,38 @@ namespace OpenNest.Engine.Strategies
var comparer = context.Policy?.Comparer ?? new DefaultFillComparer();
var preferred = context.Policy?.PreferredDirection;
return FillHelpers.BestOverAngles(context, angles,
return FillHelpers.BestOverAngles(
context,
angles,
angle =>
{
var engine = new FillLinear(workArea, context.Plate.PartSpacing) { Label = "Linear" };
var engine = new FillLinear(workArea, context.Plate.PartSpacing)
{
Label = "Linear",
};
var result = FillHelpers.FillWithDirectionPreference(
dir => engine.Fill(context.Item.Drawing, angle, dir),
preferred, comparer, workArea);
preferred,
comparer,
workArea
);
if (result != null && result.Count > 0)
{
context.AngleResults.Add(new AngleResult
{
AngleDeg = Angle.ToDegrees(angle),
Direction = preferred ?? NestDirection.Horizontal,
PartCount = result.Count
});
context.AngleResults.Add(
new AngleResult
{
AngleDeg = Angle.ToDegrees(angle),
Direction = preferred ?? NestDirection.Horizontal,
PartCount = result.Count,
}
);
}
return result;
},
"Linear");
"Linear"
);
}
}
}
@@ -1,6 +1,6 @@
using OpenNest.Engine.Fill;
using System.Collections.Generic;
using System.Threading;
using OpenNest.Engine.Fill;
namespace OpenNest.Engine.Strategies
{
@@ -29,8 +29,12 @@ namespace OpenNest.Engine.Strategies
var comparer = context.Policy?.Comparer;
var dedup = GridDedup.GetOrCreate(context.SharedState);
var filler = new PairFiller(context.Plate, comparer, dedup);
var result = filler.Fill(context.Item, context.WorkArea,
context.Token, context.ReportProgress);
var result = filler.Fill(
context.Item,
context.WorkArea,
context.Token,
context.ReportProgress
);
context.SharedState["BestFits"] = result.BestFits;
@@ -1,5 +1,5 @@
using OpenNest.RectanglePacking;
using System.Collections.Generic;
using OpenNest.RectanglePacking;
namespace OpenNest.Engine.Strategies
{
@@ -14,7 +14,10 @@ public class RowFillStrategy : IFillStrategy
if (context.PartType == PartType.Rectangle)
return null;
var filler = new StripeFiller(context, NestDirection.Horizontal) { CompleteStripesOnly = true };
var filler = new StripeFiller(context, NestDirection.Horizontal)
{
CompleteStripesOnly = true,
};
return filler.Fill();
}
}