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
@@ -24,11 +24,24 @@ public class NestJobExampleTests
// Mixed inventory: five large sheets and unlimited small sheets.
new[]
{
new NestPlateStock("large", new Size(600.0, 400.0), quantity: 5, partSpacing: 2.0,
edgeSpacing: new Spacing(5.0, 5.0, 5.0, 5.0), quadrant: 1),
new NestPlateStock("small", new Size(300.0, 300.0), quantity: null, partSpacing: 2.0,
edgeSpacing: new Spacing(5.0, 5.0, 5.0, 5.0), quadrant: 1),
});
new NestPlateStock(
"large",
new Size(600.0, 400.0),
quantity: 5,
partSpacing: 2.0,
edgeSpacing: new Spacing(5.0, 5.0, 5.0, 5.0),
quadrant: 1
),
new NestPlateStock(
"small",
new Size(300.0, 300.0),
quantity: null,
partSpacing: 2.0,
edgeSpacing: new Spacing(5.0, 5.0, 5.0, 5.0),
quadrant: 1
),
}
);
var result = new NestJobRunner(PlateNesterFactory.Create).Solve(job);
@@ -36,22 +49,30 @@ public class NestJobExampleTests
Console.WriteLine($"Status: {result.Status}, stop reason: {result.StopReason}.");
foreach (var plate in result.Plates)
{
Console.WriteLine($"Plate {plate.PlateIndex} from stock '{plate.StockId}' " +
$"({plate.Stock.Size.Width} x {plate.Stock.Size.Length}):");
Console.WriteLine(
$"Plate {plate.PlateIndex} from stock '{plate.StockId}' "
+ $"({plate.Stock.Size.Width} x {plate.Stock.Size.Length}):"
);
foreach (var placement in plate.Placements)
Console.WriteLine($" {placement.PartId} #{placement.InstanceIndex} at " +
$"({placement.X:F1}, {placement.Y:F1}) rotated {placement.Rotation:F3} rad.");
Console.WriteLine(
$" {placement.PartId} #{placement.InstanceIndex} at "
+ $"({placement.X:F1}, {placement.Y:F1}) rotated {placement.Rotation:F3} rad."
);
}
// -- Every requirement reports exact fulfillment, including leftovers. --
foreach (var fulfillment in result.Fulfillment)
Console.WriteLine($"Requirement '{fulfillment.PartId}': requested {fulfillment.Requested}, " +
$"placed {fulfillment.Placed}, unplaced {fulfillment.Unplaced}.");
Console.WriteLine(
$"Requirement '{fulfillment.PartId}': requested {fulfillment.Requested}, "
+ $"placed {fulfillment.Placed}, unplaced {fulfillment.Unplaced}."
);
// -- Every stock line reports physical sheets used and remaining availability. --
foreach (var usage in result.StockUsage)
Console.WriteLine($"Stock '{usage.StockId}': used {usage.Used}, " +
$"remaining {(usage.Remaining.HasValue ? usage.Remaining.Value.ToString() : "unlimited")}.");
Console.WriteLine(
$"Stock '{usage.StockId}': used {usage.Used}, "
+ $"remaining {(usage.Remaining.HasValue ? usage.Remaining.Value.ToString() : "unlimited")}."
);
// Invariants the enumeration relies on: conservation per requirement and per stock line, no
// empty plates, every plate bound to supplied stock, and per-placement instance accounting.
@@ -64,28 +85,45 @@ public class NestJobExampleTests
{
var stock = job.Plates.First(candidate => candidate.Id == usage.StockId);
Assert.True(usage.Used >= 0);
Assert.Equal(stock.Quantity is int capacity ? capacity - usage.Used : (int?)null, usage.Remaining);
Assert.Equal(
stock.Quantity is int capacity ? capacity - usage.Used : (int?)null,
usage.Remaining
);
}
Assert.All(result.Plates, plate => Assert.NotEmpty(plate.Placements));
var plateCountByStock = result.Plates.GroupBy(plate => plate.StockId)
var plateCountByStock = result
.Plates.GroupBy(plate => plate.StockId)
.ToDictionary(group => group.Key, group => group.Count());
foreach (var usage in result.StockUsage)
Assert.Equal(usage.Used, plateCountByStock.GetValueOrDefault(usage.StockId));
var instanceIndicesByPart = result.Plates
.SelectMany(plate => plate.Placements)
var instanceIndicesByPart = result
.Plates.SelectMany(plate => plate.Placements)
.GroupBy(placement => placement.PartId)
.ToDictionary(group => group.Key, group => group.Select(placement => placement.InstanceIndex));
.ToDictionary(
group => group.Key,
group => group.Select(placement => placement.InstanceIndex)
);
foreach (var fulfillment in result.Fulfillment)
Assert.Equal(Enumerable.Range(0, fulfillment.Placed),
instanceIndicesByPart.GetValueOrDefault(fulfillment.PartId, new List<int>()).OrderBy(index => index));
Assert.Equal(
Enumerable.Range(0, fulfillment.Placed),
instanceIndicesByPart
.GetValueOrDefault(fulfillment.PartId, new List<int>())
.OrderBy(index => index)
);
// The default heuristic completes this synthetic job from the mixed inventory.
Assert.Equal(NestJobStatus.Complete, result.Status);
Assert.Equal(NestJobStopReason.Completed, result.StopReason);
Assert.Equal(5, result.Fulfillment.Single(fulfillment => fulfillment.PartId == "bracket").Placed);
Assert.Equal(8, result.Fulfillment.Single(fulfillment => fulfillment.PartId == "plate-clip").Placed);
Assert.Equal(
5,
result.Fulfillment.Single(fulfillment => fulfillment.PartId == "bracket").Placed
);
Assert.Equal(
8,
result.Fulfillment.Single(fulfillment => fulfillment.PartId == "plate-clip").Placed
);
}
[Fact]
@@ -94,9 +132,19 @@ public class NestJobExampleTests
// Same shape of job, but a plate budget forces an explicit partial result.
var job = new NestJob(
new[] { Part("part", 100.0, 100.0, 6, priority: 0) },
new[] { new NestPlateStock("sheet", new Size(220.0, 220.0), quantity: null, partSpacing: 2.0,
edgeSpacing: new Spacing(5.0, 5.0, 5.0, 5.0), quadrant: 1) },
new NestJobOptions("Default", maxPlates: 1));
new[]
{
new NestPlateStock(
"sheet",
new Size(220.0, 220.0),
quantity: null,
partSpacing: 2.0,
edgeSpacing: new Spacing(5.0, 5.0, 5.0, 5.0),
quadrant: 1
),
},
new NestJobOptions("Default", maxPlates: 1)
);
var result = new NestJobRunner(PlateNesterFactory.Create).Solve(job);
@@ -143,6 +191,17 @@ public class NestJobExampleTests
Assert.Same(drawing, placed.BaseDrawing);
}
private static NestJobPart Part(string id, double width, double length, int quantity, int priority) =>
new(id, PartGeometrySnapshot.FromProgram(TestDrawingFactory.Rectangle(width, length)), quantity, priority);
private static NestJobPart Part(
string id,
double width,
double length,
int quantity,
int priority
) =>
new(
id,
PartGeometrySnapshot.FromProgram(TestDrawingFactory.Rectangle(width, length)),
quantity,
priority
);
}