using AyCode.Core.Serializers.Attributes;

namespace AyCode.Core.Tests.TestModels;

/// <summary>
/// Intentionally NOT marked with [AcBinarySerializable].
/// Used to reproduce the generated-writer path where the parent has a complex reference property
/// without a generated writer on the child type.
/// </summary>
public class NonGeneratedComplexCustomer
{
    public int Id { get; set; }
    public string? Name { get; set; }
}

/// <summary>
/// Regression model for SGen complex-property null handling.
/// The Customer property is non-nullable in signature, but runtime data can still contain null.
/// Serializer must emit PropertySkip instead of dereferencing null.
/// </summary>
[AcBinarySerializable]
public class SGenNullComplexParent
{
    public int Id { get; set; }
    public NonGeneratedComplexCustomer Customer { get; set; } = null!;
    public string? Note { get; set; }
}

/// <summary>
/// Regression model for SGen Collection-property null handling — the fallback WriteValueGenerated
/// branch in GenWriter.cs PropertyTypeKind.Collection case (~line 321), when the element type has
/// no generated writer (cross-assembly / unattributed). The Items property is non-nullable in
/// signature, but runtime data can still contain null. Serializer must emit PropertySkip instead
/// of forwarding null into the WriteValueGenerated bridge.
/// </summary>
[AcBinarySerializable]
public class SGenNullCollectionParent
{
    public int Id { get; set; }
    public List<NonGeneratedComplexCustomer> Items { get; set; } = null!;
    public string? Note { get; set; }
}

/// <summary>
/// Regression model for SGen Dictionary-property null handling — the EmitDirectDictionaryWrite
/// branch in GenWriter.cs (~line 1031). The branch was already null-safe at the time of the
/// N4P8 audit (explicit `if (a == null) PropertySkip` at line ~1037), but no regression test
/// existed to pin the behaviour. The Mapping property is non-nullable in signature, but runtime
/// data can still contain null — same pattern as <see cref="SGenNullComplexParent"/> /
/// <see cref="SGenNullCollectionParent"/>.
/// </summary>
[AcBinarySerializable]
public class SGenNullDictionaryParent
{
    public int Id { get; set; }
    public Dictionary<string, NonGeneratedComplexCustomer> Mapping { get; set; } = null!;
    public string? Note { get; set; }
}
