fix(core): tell value-type Auto settings without advice from an advised default
Auto<T>.Resolve returned default instead of the fallback for value types because AutoValue cannot be null there. Auto<T> now records HasAdvice; the render pipeline's ProjectValues workaround and the advisor's ReasonKey heuristic are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
9 files changed
+41
-61
No files matched your search
@@ -94,10 +94,6 @@ internal static class ParameterBindings
|
||||
|
||||
public static string Size(int width, int height) => string.Create(CultureInfo.InvariantCulture, $"{width}x{height}");
|
||||
|
||||
public static bool HasAdvice<T>(Auto<T> auto) => typeof(T).IsValueType
|
||||
? auto.ReasonKey is not null && !auto.ReasonKey.StartsWith(AdvisorKeys.MissingPrefix, StringComparison.Ordinal)
|
||||
: auto.AutoValue is not null;
|
||||
|
||||
private static ParameterBinding AutoField<T>(string parameter, AdvisorSection section, bool module, Func<ProjectSettings, Auto<T>> get, Func<ProjectSettings, Auto<T>, ProjectSettings> set) => new()
|
||||
{
|
||||
Parameter = parameter,
|
||||
@@ -108,7 +104,7 @@ internal static class ParameterBindings
|
||||
ResetToAuto = s => set(s, get(s).Reset()),
|
||||
};
|
||||
|
||||
private static object? EffectiveOf<T>(Auto<T> auto) => !auto.IsAuto && auto.Manual is not null ? auto.Manual : HasAdvice(auto) ? auto.AutoValue : null;
|
||||
private static object? EffectiveOf<T>(Auto<T> auto) => !auto.IsAuto && auto.Manual is not null ? auto.Manual : auto.HasAdvice ? auto.AutoValue : null;
|
||||
|
||||
/// <summary>
|
||||
/// Stores a value with its reason. Missing data changes no value: the missing-data reason is stored only when the
|
||||
@@ -118,7 +114,7 @@ internal static class ParameterBindings
|
||||
{
|
||||
var args = Strings(recommendation.ReasonArgs);
|
||||
if (recommendation.Value is null)
|
||||
return HasAdvice(auto) ? auto : auto with { ReasonKey = recommendation.ReasonKey, ReasonArgs = args };
|
||||
return auto.HasAdvice ? auto : auto with { ReasonKey = recommendation.ReasonKey, ReasonArgs = args };
|
||||
if (recommendation.Value is not T value)
|
||||
throw new InvalidOperationException($"{recommendation.Parameter} expects {typeof(T).Name}, got {recommendation.Value.GetType().Name}.");
|
||||
return auto.WithAdvice(value, recommendation.ReasonKey, args);
|
||||
|
||||
Reference in new issue
Block a user