using System;
#if !ROBUST_ANALYZERS_TEST
using JetBrains.Annotations;
#endif
namespace Robust.Shared.Serialization.Manager.Attributes
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
#if !ROBUST_ANALYZERS_TEST
[MeansImplicitAssignment]
[MeansImplicitUse(ImplicitUseKindFlags.Assign)]
[Virtual]
#endif
public class DataFieldAttribute : DataFieldBaseAttribute
{
///
/// The name of this field in YAML.
/// If null, the name of the C# field will be used instead, with the first letter lowercased.
///
public string? Tag { get; internal set; }
///
/// Whether or not this field being mapped is required for the component to function.
/// This will not guarantee that the field is mapped when the program is run,
/// it is meant to be used as metadata information.
///
public readonly bool Required;
public DataFieldAttribute(string? tag = null, bool readOnly = false, int priority = 1, bool required = false, bool serverOnly = false, Type? customTypeSerializer = null) : base(readOnly, priority, serverOnly, customTypeSerializer)
{
Tag = tag;
Required = required;
}
public override string? ToString()
{
return Tag;
}
}
public abstract class DataFieldBaseAttribute : Attribute
{
public readonly int Priority;
public readonly Type? CustomTypeSerializer;
public readonly bool ReadOnly;
public readonly bool ServerOnly;
protected DataFieldBaseAttribute(bool readOnly = false, int priority = 1, bool serverOnly = false, Type? customTypeSerializer = null)
{
ReadOnly = readOnly;
Priority = priority;
ServerOnly = serverOnly;
CustomTypeSerializer = customTypeSerializer;
}
}
}