fix: Allow empty or null names for BinItem
Removes validation that required non-empty item names, as parts may legitimately have no label assigned. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
namespace CutList.Core
|
||||||
|
|
||||||
namespace CutList.Core
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an item to be placed in a bin.
|
/// Represents an item to be placed in a bin.
|
||||||
@@ -8,18 +6,15 @@ namespace CutList.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class BinItem
|
public class BinItem
|
||||||
{
|
{
|
||||||
private string _name;
|
private string _name = string.Empty;
|
||||||
private double _length;
|
private double _length;
|
||||||
|
|
||||||
public BinItem(string name, double length)
|
public BinItem(string? name, double length)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
|
||||||
throw new ArgumentException("Item name cannot be empty", nameof(name));
|
|
||||||
|
|
||||||
if (length <= 0)
|
if (length <= 0)
|
||||||
throw new ArgumentException("Item length must be greater than zero", nameof(length));
|
throw new ArgumentException("Item length must be greater than zero", nameof(length));
|
||||||
|
|
||||||
_name = name;
|
_name = name ?? string.Empty;
|
||||||
_length = length;
|
_length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,12 +29,7 @@ namespace CutList.Core
|
|||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get => _name;
|
get => _name;
|
||||||
set
|
set => _name = value ?? string.Empty;
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(value))
|
|
||||||
throw new ArgumentException("Item name cannot be empty", nameof(value));
|
|
||||||
_name = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Length
|
public double Length
|
||||||
|
|||||||
Reference in New Issue
Block a user