mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-07 09:02:11 -04:00
Nest Info edits only the material name, but SaveNestInfo replaced the nest's material with new Material(name), so pressing OK without touching the material silently dropped its grade and density. SaveNestInfo now goes through NestMaterialSelection.Apply in OpenNest.Data: a name with the same SharedListNames.Key as the current material (trimmed, whitespace collapsed, invariant upper case) keeps its grade and density and takes the typed name; any other name gets a name-only material, as before. It always returns a new Material. SharedListNames.Key is the name normalizer the shared customer/material lists will use. Behavioral reds (each restored byte-identically): restoring the old name-only path fails both keep-grade tests; exact-string matching, dropping the upper-casing or the whitespace collapse fails the normalized-name test; returning the current instance fails the copy test. EditNestInfoFormTests cover Load -> Save through the real form; they are cross-compiled here and execute in the windows-desktop CI job.
19 lines
653 B
C#
19 lines
653 B
C#
namespace OpenNest.Data;
|
|
|
|
/// <summary>
|
|
/// Normalized matching key for names in company lists (customers, materials).
|
|
/// </summary>
|
|
public static class SharedListNames
|
|
{
|
|
/// <summary>
|
|
/// Returns the name trimmed, with internal whitespace runs collapsed to one
|
|
/// space, in invariant upper case. Names that differ only in spacing or case
|
|
/// share a key. A null or blank name has the empty key.
|
|
/// </summary>
|
|
public static string Key(string? name) =>
|
|
name == null
|
|
? ""
|
|
: string.Join(' ', name.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries))
|
|
.ToUpperInvariant();
|
|
}
|