Refactor WriteValueGenerated for clarity and efficiency

Update WriteValueGenerated to require non-null values and call WriteValueNonPrimitive directly, clarifying its use for complex types in generated writers. Improve XML docs to reflect new behavior and intent.
This commit is contained in:
Loretta 2026-02-14 21:04:31 +01:00
parent 4ef65ee501
commit 12b3244aa3
1 changed files with 5 additions and 4 deletions

View File

@ -470,14 +470,15 @@ public static partial class AcBinarySerializer
#region Generated Writer Bridge Methods
/// <summary>
/// Bridge for generated writers to call the runtime WriteValue for complex/collection properties.
/// Generated writers handle primitives directly; complex types delegate here.
/// Bridge for generated writers: writes a non-null complex/collection value directly.
/// Skips null check (caller handles it) and TryWritePrimitive (caller knows it's complex).
/// Equivalent to the runtime's WriteValueNonPrimitive path.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void WriteValueGenerated<TOutput>(object? value, Type type, BinarySerializationContext<TOutput> context, int depth)
internal static void WriteValueGenerated<TOutput>(object value, Type type, BinarySerializationContext<TOutput> context, int depth)
where TOutput : struct, IBinaryOutputBase
{
WriteValue(value, type, context, depth);
WriteValueNonPrimitive(value, type, context, depth);
}
/// <summary>