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
+2 -5
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -16,10 +16,7 @@ namespace OpenNest.Shapes
public override Drawing GetDrawing()
{
var entities = new List<Entity>
{
new Circle(0, 0, Diameter / 2.0)
};
var entities = new List<Entity> { new Circle(0, 0, Diameter / 2.0) };
return CreateDrawing(entities);
}
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -24,7 +24,7 @@ namespace OpenNest.Shapes
{
new Line(0, 0, Base, 0),
new Line(Base, 0, midX, Height),
new Line(midX, Height, 0, 0)
new Line(midX, Height, 0, 0),
};
return CreateDrawing(entities);
+2 -2
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -32,7 +32,7 @@ namespace OpenNest.Shapes
new Line(Width, lh, lw, lh),
new Line(lw, lh, lw, Height),
new Line(lw, Height, 0, Height),
new Line(0, Height, 0, 0)
new Line(0, Height, 0, 0),
};
return CreateDrawing(entities);
+3 -2
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -30,7 +30,8 @@ namespace OpenNest.Shapes
var angle = start + i * step;
vertices[i] = new Vector(
center + circumRadius * System.Math.Cos(angle),
center + circumRadius * System.Math.Sin(angle));
center + circumRadius * System.Math.Sin(angle)
);
}
var entities = new List<Entity>();
+6 -2
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -50,7 +50,11 @@ namespace OpenNest.Shapes
entities.Add(new Circle(cx, cy, holeRadius));
}
if (!Blind && !string.IsNullOrEmpty(PipeSize) && PipeSizes.TryGetOD(PipeSize, out var pipeOD))
if (
!Blind
&& !string.IsNullOrEmpty(PipeSize)
&& PipeSizes.TryGetOD(PipeSize, out var pipeOD)
)
{
var boreDiameter = pipeOD + PipeClearance;
entities.Add(new Circle(0, 0, boreDiameter / 2.0));
+39 -38
View File
@@ -6,44 +6,45 @@ namespace OpenNest.Shapes
{
public readonly record struct Entry(string Label, double OuterDiameter);
public static IReadOnlyList<Entry> All { get; } = new[]
{
new Entry("1/8", 0.405),
new Entry("1/4", 0.540),
new Entry("3/8", 0.675),
new Entry("1/2", 0.840),
new Entry("3/4", 1.050),
new Entry("1", 1.315),
new Entry("1 1/4", 1.660),
new Entry("1 1/2", 1.900),
new Entry("2", 2.375),
new Entry("2 1/2", 2.875),
new Entry("3", 3.500),
new Entry("3 1/2", 4.000),
new Entry("4", 4.500),
new Entry("4 1/2", 5.000),
new Entry("5", 5.563),
new Entry("6", 6.625),
new Entry("7", 7.625),
new Entry("8", 8.625),
new Entry("9", 9.625),
new Entry("10", 10.750),
new Entry("11", 11.750),
new Entry("12", 12.750),
new Entry("14", 14.000),
new Entry("16", 16.000),
new Entry("18", 18.000),
new Entry("20", 20.000),
new Entry("24", 24.000),
new Entry("26", 26.000),
new Entry("28", 28.000),
new Entry("30", 30.000),
new Entry("32", 32.000),
new Entry("34", 34.000),
new Entry("36", 36.000),
new Entry("42", 42.000),
new Entry("48", 48.000),
};
public static IReadOnlyList<Entry> All { get; } =
new[]
{
new Entry("1/8", 0.405),
new Entry("1/4", 0.540),
new Entry("3/8", 0.675),
new Entry("1/2", 0.840),
new Entry("3/4", 1.050),
new Entry("1", 1.315),
new Entry("1 1/4", 1.660),
new Entry("1 1/2", 1.900),
new Entry("2", 2.375),
new Entry("2 1/2", 2.875),
new Entry("3", 3.500),
new Entry("3 1/2", 4.000),
new Entry("4", 4.500),
new Entry("4 1/2", 5.000),
new Entry("5", 5.563),
new Entry("6", 6.625),
new Entry("7", 7.625),
new Entry("8", 8.625),
new Entry("9", 9.625),
new Entry("10", 10.750),
new Entry("11", 11.750),
new Entry("12", 12.750),
new Entry("14", 14.000),
new Entry("16", 16.000),
new Entry("18", 18.000),
new Entry("20", 20.000),
new Entry("24", 24.000),
new Entry("26", 26.000),
new Entry("28", 28.000),
new Entry("30", 30.000),
new Entry("32", 32.000),
new Entry("34", 34.000),
new Entry("36", 36.000),
new Entry("42", 42.000),
new Entry("48", 48.000),
};
public static bool TryGetOD(string label, out double outerDiameter)
{
+56 -23
View File
@@ -29,17 +29,18 @@ namespace OpenNest.Shapes
/// Standard mill sheet sizes (inches), sorted by area ascending.
/// Canonical orientation: Width &lt;= Length.
/// </summary>
public static IReadOnlyList<Entry> All { get; } = new[]
{
new Entry("48x96", 48, 96), // 4608
new Entry("48x120", 48, 120), // 5760
new Entry("48x144", 48, 144), // 6912
new Entry("60x120", 60, 120), // 7200
new Entry("60x144", 60, 144), // 8640
new Entry("72x120", 72, 120), // 8640
new Entry("72x144", 72, 144), // 10368
new Entry("96x240", 96, 240), // 23040
};
public static IReadOnlyList<Entry> All { get; } =
new[]
{
new Entry("48x96", 48, 96), // 4608
new Entry("48x120", 48, 120), // 5760
new Entry("48x144", 48, 144), // 6912
new Entry("60x120", 60, 120), // 7200
new Entry("60x144", 60, 144), // 8640
new Entry("72x120", 72, 120), // 8640
new Entry("72x144", 72, 144), // 10368
new Entry("96x240", 96, 240), // 23040
};
/// <summary>
/// Looks up a standard size by label. Case-insensitive.
@@ -77,7 +78,10 @@ namespace OpenNest.Shapes
/// <summary>
/// Recommends a plate size for the envelope of the given boxes.
/// </summary>
public static PlateSizeResult Recommend(IEnumerable<Box> boxes, PlateSizeOptions options = null)
public static PlateSizeResult Recommend(
IEnumerable<Box> boxes,
PlateSizeOptions options = null
)
{
if (boxes == null)
throw new ArgumentNullException(nameof(boxes));
@@ -91,10 +95,14 @@ namespace OpenNest.Shapes
foreach (var box in boxes)
{
hasAny = true;
if (box.Left < minX) minX = box.Left;
if (box.Bottom < minY) minY = box.Bottom;
if (box.Right > maxX) maxX = box.Right;
if (box.Top > maxY) maxY = box.Top;
if (box.Left < minX)
minX = box.Left;
if (box.Bottom < minY)
minY = box.Bottom;
if (box.Right > maxX)
maxX = box.Right;
if (box.Top > maxY)
maxY = box.Top;
}
if (!hasAny)
@@ -109,7 +117,11 @@ namespace OpenNest.Shapes
/// Recommends a plate size for a (width, length) pair.
/// Inputs are treated as orientation-independent.
/// </summary>
public static PlateSizeResult Recommend(double width, double length, PlateSizeOptions options = null)
public static PlateSizeResult Recommend(
double width,
double length,
PlateSizeOptions options = null
)
{
options ??= new PlateSizeOptions();
@@ -174,10 +186,23 @@ namespace OpenNest.Shapes
if (!string.IsNullOrWhiteSpace(label))
{
var parts = label.Split(new[] { 'x', 'X' }, 2);
if (parts.Length == 2
&& double.TryParse(parts[0].Trim(), System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var a)
&& double.TryParse(parts[1].Trim(), System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var b)
&& a > 0 && b > 0)
if (
parts.Length == 2
&& double.TryParse(
parts[0].Trim(),
System.Globalization.NumberStyles.Float,
System.Globalization.CultureInfo.InvariantCulture,
out var a
)
&& double.TryParse(
parts[1].Trim(),
System.Globalization.NumberStyles.Float,
System.Globalization.CultureInfo.InvariantCulture,
out var b
)
&& a > 0
&& b > 0
)
{
var width = System.Math.Min(a, b);
var length = System.Math.Max(a, b);
@@ -190,13 +215,20 @@ namespace OpenNest.Shapes
return false;
}
private static Entry? PickBest(IReadOnlyList<Entry> catalog, double width, double length, PlateSizeSelection selection)
private static Entry? PickBest(
IReadOnlyList<Entry> catalog,
double width,
double length,
PlateSizeSelection selection
)
{
var fitting = catalog.Where(e => e.Fits(width, length));
fitting = selection switch
{
PlateSizeSelection.NarrowestFirst => fitting.OrderBy(e => e.Width).ThenBy(e => e.Area),
PlateSizeSelection.NarrowestFirst => fitting
.OrderBy(e => e.Width)
.ThenBy(e => e.Area),
_ => fitting.OrderBy(e => e.Area).ThenBy(e => e.Width),
};
@@ -249,6 +281,7 @@ namespace OpenNest.Shapes
{
/// <summary>Pick the cheapest sheet that contains the bbox (smallest area).</summary>
SmallestArea,
/// <summary>Prefer narrower-width sheets (e.g. 48-wide before 60-wide).</summary>
NarrowestFirst,
}
+2 -2
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -23,7 +23,7 @@ namespace OpenNest.Shapes
new Line(0, 0, Length, 0),
new Line(Length, 0, Length, Width),
new Line(Length, Width, 0, Width),
new Line(0, Width, 0, 0)
new Line(0, Width, 0, 0),
};
return CreateDrawing(entities);
+2 -2
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -22,7 +22,7 @@ namespace OpenNest.Shapes
{
new Line(0, 0, Width, 0),
new Line(Width, 0, 0, Height),
new Line(0, Height, 0, 0)
new Line(0, Height, 0, 0),
};
return CreateDrawing(entities);
+2 -2
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -21,7 +21,7 @@ namespace OpenNest.Shapes
var entities = new List<Entity>
{
new Circle(0, 0, OuterDiameter / 2.0),
new Circle(0, 0, InnerDiameter / 2.0)
new Circle(0, 0, InnerDiameter / 2.0),
};
return CreateDrawing(entities);
+9 -10
View File
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using OpenNest.Geometry;
using OpenNest.Math;
using System.Collections.Generic;
namespace OpenNest.Shapes
{
@@ -10,7 +10,8 @@ namespace OpenNest.Shapes
public double Width { get; set; }
public double Radius { get; set; }
public override string GenerateName() => $"Rounded Rectangle {Dim(Length)}x{Dim(Width)} R{Dim(Radius)}";
public override string GenerateName() =>
$"Rounded Rectangle {Dim(Length)}x{Dim(Width)} R{Dim(Radius)}";
public override void SetPreviewDefaults()
{
@@ -37,29 +38,27 @@ namespace OpenNest.Shapes
entities.Add(new Line(r, 0, Length - r, 0));
// Bottom-right corner arc: center at (Length-r, r), from 270deg to 360deg
entities.Add(new Arc(Length - r, r, r,
Angle.ToRadians(270), Angle.ToRadians(360)));
entities.Add(new Arc(Length - r, r, r, Angle.ToRadians(270), Angle.ToRadians(360)));
// Right edge
entities.Add(new Line(Length, r, Length, Width - r));
// Top-right corner arc: center at (Length-r, Width-r), from 0deg to 90deg
entities.Add(new Arc(Length - r, Width - r, r,
Angle.ToRadians(0), Angle.ToRadians(90)));
entities.Add(
new Arc(Length - r, Width - r, r, Angle.ToRadians(0), Angle.ToRadians(90))
);
// Top edge (right to left)
entities.Add(new Line(Length - r, Width, r, Width));
// Top-left corner arc: center at (r, Width-r), from 90deg to 180deg
entities.Add(new Arc(r, Width - r, r,
Angle.ToRadians(90), Angle.ToRadians(180)));
entities.Add(new Arc(r, Width - r, r, Angle.ToRadians(90), Angle.ToRadians(180)));
// Left edge
entities.Add(new Line(0, Width - r, 0, r));
// Bottom-left corner arc: center at (r, r), from 180deg to 270deg
entities.Add(new Arc(r, r, r,
Angle.ToRadians(180), Angle.ToRadians(270)));
entities.Add(new Arc(r, r, r, Angle.ToRadians(180), Angle.ToRadians(270)));
}
return CreateDrawing(entities);
+7 -5
View File
@@ -1,9 +1,9 @@
using OpenNest.Converters;
using OpenNest.Geometry;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using OpenNest.Converters;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -11,7 +11,7 @@ namespace OpenNest.Shapes
{
private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
PropertyNameCaseInsensitive = true,
};
public string Name { get; set; }
@@ -36,7 +36,8 @@ namespace OpenNest.Shapes
public virtual void SetPreviewDefaults() { }
public static List<T> LoadFromJson<T>(string path) where T : ShapeDefinition
public static List<T> LoadFromJson<T>(string path)
where T : ShapeDefinition
{
var json = File.ReadAllText(path);
return JsonSerializer.Deserialize<List<T>>(json, JsonOptions);
@@ -50,7 +51,8 @@ namespace OpenNest.Shapes
if (pgm == null)
throw new InvalidOperationException(
$"Failed to create program for shape '{Name}'. Check that parameters produce valid geometry.");
$"Failed to create program for shape '{Name}'. Check that parameters produce valid geometry."
);
return new Drawing(Name, pgm);
}
+2 -2
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -37,7 +37,7 @@ namespace OpenNest.Shapes
new Line(Width, Height, 0, Height),
new Line(0, Height, 0, stemTop),
new Line(0, stemTop, stemLeft, stemTop),
new Line(stemLeft, stemTop, stemLeft, 0)
new Line(stemLeft, stemTop, stemLeft, 0),
};
return CreateDrawing(entities);
+4 -3
View File
@@ -1,5 +1,5 @@
using OpenNest.Geometry;
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Shapes
{
@@ -9,7 +9,8 @@ namespace OpenNest.Shapes
public double BottomWidth { get; set; }
public double Height { get; set; }
public override string GenerateName() => $"Trapezoid {Dim(TopWidth)}x{Dim(BottomWidth)}x{Dim(Height)}";
public override string GenerateName() =>
$"Trapezoid {Dim(TopWidth)}x{Dim(BottomWidth)}x{Dim(Height)}";
public override void SetPreviewDefaults()
{
@@ -27,7 +28,7 @@ namespace OpenNest.Shapes
new Line(0, 0, BottomWidth, 0),
new Line(BottomWidth, 0, offset + TopWidth, Height),
new Line(offset + TopWidth, Height, offset, Height),
new Line(offset, Height, 0, 0)
new Line(offset, Height, 0, 0),
};
return CreateDrawing(entities);