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
+109 -25
View File
@@ -20,20 +20,32 @@ public sealed class NestJobRunner : INestingEngine
this.plateNesterFactory = plateNesterFactory;
}
public NestJobResult Solve(NestJob job, IProgress<NestJobProgress> progress = null,
CancellationToken token = default)
public NestJobResult Solve(
NestJob job,
IProgress<NestJobProgress> progress = null,
CancellationToken token = default
)
{
ArgumentNullException.ThrowIfNull(job);
token.ThrowIfCancellationRequested();
NestJobValidator.Validate(job);
var plates = new List<NestJobPlateResult>();
var remaining = job.Parts.ToDictionary(part => part.Id, part => part.Quantity, StringComparer.Ordinal);
var remaining = job.Parts.ToDictionary(
part => part.Id,
part => part.Quantity,
StringComparer.Ordinal
);
var placed = job.Parts.ToDictionary(part => part.Id, _ => 0, StringComparer.Ordinal);
var parts = job.Parts.ToDictionary(part => part.Id, StringComparer.Ordinal);
var used = job.Plates.ToDictionary(stock => stock.Id, _ => 0, StringComparer.Ordinal);
var comparer = new NestJobCandidateComparer(job.Parts);
var nester = job.Parts.Count == 0 ? null : plateNesterFactory(job.Options.PlacementStrategy) ??
throw new NotSupportedException($"Unknown placement strategy: {job.Options.PlacementStrategy}.");
var nester =
job.Parts.Count == 0
? null
: plateNesterFactory(job.Options.PlacementStrategy)
?? throw new NotSupportedException(
$"Unknown placement strategy: {job.Options.PlacementStrategy}."
);
var reason = NestJobStopReason.Completed;
while (remaining.Values.Any(count => count > 0))
{
@@ -49,21 +61,55 @@ public sealed class NestJobRunner : INestingEngine
for (var index = 0; index < job.Plates.Count; index++)
{
var stock = job.Plates[index];
if (stock.Quantity is int quantity && used[stock.Id] >= quantity) continue;
if (stock.Quantity is int quantity && used[stock.Id] >= quantity)
continue;
hasAvailableStock = true;
var request = new PlatePlacementRequest(stock, job.Parts.Where(part => remaining[part.Id] > 0)
.Select(part => new NestJobPart(part.Id, part.Geometry, remaining[part.Id], part.Priority, part.Rotation)));
progress?.Report(new NestJobProgress(NestJobStage.EvaluatingCandidate, stock.Id,
plates.Count, plates.Count, placed.Values.Sum()));
var request = new PlatePlacementRequest(
stock,
job.Parts.Where(part => remaining[part.Id] > 0)
.Select(part => new NestJobPart(
part.Id,
part.Geometry,
remaining[part.Id],
part.Priority,
part.Rotation
))
);
progress?.Report(
new NestJobProgress(
NestJobStage.EvaluatingCandidate,
stock.Id,
plates.Count,
plates.Count,
placed.Values.Sum()
)
);
token.ThrowIfCancellationRequested();
var candidateProgress = progress == null ? null : new CandidateProgress(progress, stock.Id,
plates.Count, plates.Count, placed.Values.Sum());
var candidateProgress =
progress == null
? null
: new CandidateProgress(
progress,
stock.Id,
plates.Count,
plates.Count,
placed.Values.Sum()
);
var candidate = nester.Place(request, candidateProgress, token);
token.ThrowIfCancellationRequested();
NestJobValidator.ValidateCandidate(candidate, stock, remaining, parts);
var trial = new CandidateTrial(candidate, stock, index);
if (winner == null || comparer.Compare(trial.Candidate, trial.Stock, trial.StockIndex,
winner.Candidate, winner.Stock, winner.StockIndex) > 0)
if (
winner == null
|| comparer.Compare(
trial.Candidate,
trial.Stock,
trial.StockIndex,
winner.Candidate,
winner.Stock,
winner.StockIndex
) > 0
)
winner = trial;
}
@@ -86,27 +132,65 @@ public sealed class NestJobRunner : INestingEngine
}
used[winner.Stock.Id]++;
plates.Add(new NestJobPlateResult(plates.Count, winner.Stock, committed));
progress?.Report(new NestJobProgress(NestJobStage.PlateCommitted, winner.Stock.Id,
plates.Count - 1, plates.Count, placed.Values.Sum()));
progress?.Report(
new NestJobProgress(
NestJobStage.PlateCommitted,
winner.Stock.Id,
plates.Count - 1,
plates.Count,
placed.Values.Sum()
)
);
}
token.ThrowIfCancellationRequested();
return new NestJobResult(reason == NestJobStopReason.Completed ? NestJobStatus.Complete : NestJobStatus.Incomplete,
reason, plates, job.Parts.Select(part => new PartFulfillment(part.Id, part.Quantity, placed[part.Id], remaining[part.Id])),
job.Plates.Select(stock => new StockUsage(stock.Id, used[stock.Id],
stock.Quantity is int quantity ? quantity - used[stock.Id] : null)));
return new NestJobResult(
reason == NestJobStopReason.Completed
? NestJobStatus.Complete
: NestJobStatus.Incomplete,
reason,
plates,
job.Parts.Select(part => new PartFulfillment(
part.Id,
part.Quantity,
placed[part.Id],
remaining[part.Id]
)),
job.Plates.Select(stock => new StockUsage(
stock.Id,
used[stock.Id],
stock.Quantity is int quantity ? quantity - used[stock.Id] : null
))
);
}
private sealed record CandidateTrial(PlateCandidate Candidate, NestPlateStock Stock, int StockIndex);
private sealed record CandidateTrial(
PlateCandidate Candidate,
NestPlateStock Stock,
int StockIndex
);
private sealed class CandidateProgress(IProgress<NestJobProgress> progress, string stockId, int plateIndex,
int committedPlates, int committedParts) : IProgress<NestJobProgress>
private sealed class CandidateProgress(
IProgress<NestJobProgress> progress,
string stockId,
int plateIndex,
int committedPlates,
int committedParts
) : IProgress<NestJobProgress>
{
public void Report(NestJobProgress value)
{
ArgumentNullException.ThrowIfNull(value);
progress.Report(new NestJobProgress(NestJobStage.EvaluatingCandidate, stockId, plateIndex,
committedPlates, committedParts, value.LegacyProgress));
progress.Report(
new NestJobProgress(
NestJobStage.EvaluatingCandidate,
stockId,
plateIndex,
committedPlates,
committedParts,
value.LegacyProgress
)
);
}
}
}