using System;

namespace AyCode.Core.Serializers.Attributes;

/// <summary>
/// Marks a class or struct for Source Generator based binary serialization.
/// When applied, the Source Generator will create optimized serialize/deserialize methods
/// at compile time, eliminating the need for runtime reflection or compiled expressions.
/// </summary>
/// <remarks>
/// If this attribute is not present, the serializer falls back to the existing
/// compiled expression based approach which works for all types.
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
public sealed class AcBinarySerializableAttribute : Attribute
{
    public bool EnableMetadataFeature { get; }
    public bool EnableIdTrackingFeature { get; }
    public bool EnableRefHandlingFeature { get; }
    public bool EnableInternStringFeature { get; }

    public AcBinarySerializableAttribute() : this(true)
    {
    }

    public AcBinarySerializableAttribute(bool enableAllFeatures)
    {
        EnableMetadataFeature = enableAllFeatures;
        EnableIdTrackingFeature = enableAllFeatures;
        EnableRefHandlingFeature = enableAllFeatures;
        EnableInternStringFeature = enableAllFeatures;
    }

    public AcBinarySerializableAttribute(bool enableMetadataFeature, bool enableIdTrackingFeature, bool enableRefHandlingFeature, bool enableInternStringFeature)
    {
        EnableMetadataFeature = enableMetadataFeature;
        EnableIdTrackingFeature = enableIdTrackingFeature;
        EnableRefHandlingFeature = enableRefHandlingFeature;
        EnableInternStringFeature = enableInternStringFeature;
    }
}
