Class KnownValueAttribute
Namespace: AdCodicem.ValueObjects.Annotations
Assembly: AdCodicem.ValueObjects.Abstractions.dll
Declares a named constant of a value object, exposed as a static property on the generated type.
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
public sealed class KnownValueAttribute : Attribute
Inheritance
object ← Attribute ← KnownValueAttribute
Inherited Members
Attribute.Equals(object?), Attribute.GetCustomAttribute(Assembly, Type), Attribute.GetCustomAttribute(Assembly, Type, bool), Attribute.GetCustomAttribute(MemberInfo, Type), Attribute.GetCustomAttribute(MemberInfo, Type, bool), Attribute.GetCustomAttribute(Module, Type), Attribute.GetCustomAttribute(Module, Type, bool), Attribute.GetCustomAttribute(ParameterInfo, Type), Attribute.GetCustomAttribute(ParameterInfo, Type, bool), Attribute.GetCustomAttributes(Assembly), Attribute.GetCustomAttributes(Assembly, bool), Attribute.GetCustomAttributes(Assembly, Type), Attribute.GetCustomAttributes(Assembly, Type, bool), Attribute.GetCustomAttributes(MemberInfo), Attribute.GetCustomAttributes(MemberInfo, bool), Attribute.GetCustomAttributes(MemberInfo, Type), Attribute.GetCustomAttributes(MemberInfo, Type, bool), Attribute.GetCustomAttributes(Module), Attribute.GetCustomAttributes(Module, bool), Attribute.GetCustomAttributes(Module, Type), Attribute.GetCustomAttributes(Module, Type, bool), Attribute.GetCustomAttributes(ParameterInfo), Attribute.GetCustomAttributes(ParameterInfo, bool), Attribute.GetCustomAttributes(ParameterInfo, Type), Attribute.GetCustomAttributes(ParameterInfo, Type, bool), Attribute.GetHashCode(), Attribute.IsDefaultAttribute(), Attribute.IsDefined(Assembly, Type), Attribute.IsDefined(Assembly, Type, bool), Attribute.IsDefined(MemberInfo, Type), Attribute.IsDefined(MemberInfo, Type, bool), Attribute.IsDefined(Module, Type), Attribute.IsDefined(Module, Type, bool), Attribute.IsDefined(ParameterInfo, Type), Attribute.IsDefined(ParameterInfo, Type, bool), Attribute.Match(object?), Attribute.TypeId, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
[KnownValue("France", "FR")] on a CountryCode value object generates CountryCode.France,
adds the value to CountryCode.KnownValues, and surfaces it in the OpenAPI schema. Combined with
Constructors
KnownValueAttribute(string, object)
Initializes a new instance of the
public KnownValueAttribute(string name, object value)
Parameters
name string
Name of the generated static property. Must be a valid C# identifier, not a keyword, and a name the type does
not already have: neither a member it declares nor one the generated code uses, the metadata names of its
operators and the getters of its properties included, nor the name of another known value. The property's own
getter, get_ followed by the name, must be free too: no field, nested type or method without
parameters of the type takes it. Any other name is reported with the rule it breaks.
value object
The underlying value. Types that cannot appear as an attribute argument, such as
Properties
Description
Gets or sets the documentation of the generated static property.
public string? Description { get; set; }
Property Value
Name
Gets the name of the generated static property.
public string Name { get; }
Property Value
Value
Gets the underlying value.
public object Value { get; }