// // This file was generated by RhoMicro.CodeAnalysis.UnionsGenerator // The tool used to generate this code may be subject to license terms; // this generated code is however not subject to those terms, instead it is // subject to the license (if any) applied to the containing project. // #nullable enable #pragma warning disable namespace RhoMicro.CodeAnalysis; using System; #region Setting Enums /// /// Defines settings for generating an implementation of . /// enum ToStringSetting { /// /// The generator will emit an implementation that returns detailed information, including: /// /// the name of the union type /// a list of types representable by the union type /// an indication of which type is being represented by the instance /// the value currently being represented by the instance /// /// Detailed, /// /// The generator will not generate an implementation of . /// None, /// /// The generator will generate an implementation that returns the result of calling on the currently represented value. /// Simple } /// /// Defines settings for annotating the target with an instance of . /// enum LayoutSetting { /// /// Generate an annotation optimized for size. /// Small, /// /// Do not generate any annotations. /// Auto } /// /// Defines settings for controlling the accessibility of generated constructors. /// enum ConstructorAccessibilitySetting { /// /// Generated constructors should always be private, unless /// no conversion operators are generated for the type they /// accept. This would be the case for interface types or /// supertypes of the target union. /// PublicIfInconvertible, /// /// Generated constructors should always be private. /// Private, /// /// Generated constructors should always be public /// Public } /// /// Defines settings on how to implement interfaces that all representable /// types implement. /// enum InterfaceMatchSetting { /// /// Generated interface implementations should be explicit if at least /// one of the representable types implements the interface explicitly; /// otherwise, interface implementations should be implicit. /// Auto, /// /// Generated interface implementations should always be explicit. /// Explicit, /// /// Generated interface implementations should always be implicit. /// Implicit, /// /// No interfaces implementations should be generated. /// Omit } /// /// Defines settings for the kind of diagnostics to report. /// [Flags] enum DiagnosticsLevelSettings { /// /// Instructs the analyzer not to emit diagnostics /// None = 0x00, /// /// Instructs the analyzer to report info diagnostics. /// Info = 0x01, /// /// Instructs the analyzer to report warning diagnostics. /// Warning = 0x02, /// /// Instructs the analyzer to report error diagnostics. /// Error = 0x04, /// /// Instructs the analyzer to report all diagnostics. /// All = Info | Warning | Error } /// /// Defines miscellaneous settings. /// [Flags] enum MiscellaneousSettings { /// /// None = 0x00, /// /// The default settings. /// Default = None, /// /// Indicates whether the generated source code should be available as a string constant on the union type itself. /// This setting is generally only useful if the generated implementation should be emitted from another generator. /// EmitGeneratedSourceCode = 0x01, /// /// Indicates whether to generate a custom converter type /// for System.Text.Json deserialization. If set, this will also cause /// the union type to be annotated with an appropriate JsonConverter attribute. /// GenerateJsonConverter = 0x02, /// /// Indicates that the generator should emit a comment detailing the structure of the union type. /// EmitStructuralRepresentation = 0x04 } /// /// Defines settings pertaining to equality operator implementations. /// enum EqualityOperatorsSetting { /// /// Equality operators will be emitted only if the target union type is a value type. /// EmitOperatorsIfValueType, /// /// Equality operators will be emitted. /// EmitOperators, /// /// Equality operators will be omitted. /// OmitOperators } #endregion #region Attribute Declaration /// /// Supplies the generator with additional settings on how to generate a targeted union type. /// If the target member is an assembly, the attribute supplies default values for any union /// type setting not defined. /// [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] #if UNIONS_GENERATOR [GenerateFactory] #endif sealed partial class UnionTypeSettingsAttribute : Attribute { #region Settings /// /// Defines how to generate an implementation . /// public ToStringSetting ToStringSetting { get; set; } = ToStringSetting.Detailed; /// /// Defines whether to generate a size optimizing annotation. /// public LayoutSetting Layout { get; set; } = LayoutSetting.Auto; /// /// The level of diagnostics to be reported by the analyzer. /// public DiagnosticsLevelSettings DiagnosticsLevel { get; set; } = DiagnosticsLevelSettings.All; /// /// The desired accessibility of generated constructors. /// public ConstructorAccessibilitySetting ConstructorAccessibility { get; set; } = ConstructorAccessibilitySetting.Private; /// /// Indicates how to generate implementations for /// interfaces implemented by all representable types. Implementations will /// map calls to interface instance methods and properties onto the represented /// value. /// /// Please note that currently, only fully bound and constructed interface implementations are supported. /// /// public InterfaceMatchSetting InterfaceMatchSetting { get; set; } = InterfaceMatchSetting.Auto; /// /// Indicates how to generate equality operators. /// By default, equality operators will only be emitted for value types, so as to preserve /// reference equality for comparing reference union types via == or !=. /// public EqualityOperatorsSetting EqualityOperatorsSetting { get; set; } = EqualityOperatorsSetting.EmitOperatorsIfValueType; /// /// Gets or sets miscellaneous settings. /// public MiscellaneousSettings Miscellaneous { get; set; } = MiscellaneousSettings.Default; #endregion #region Strings /// /// A raw code preface to prepend before the generated type declaration. /// public String TypeDeclarationPreface { get; set; } = ""; /// /// The name of the generic parameter for generic Is, As and factory methods. /// Set this property in order to avoid name collisions with generic union type parameters /// public String GenericTValueName { get; set; } = "TValue"; /// /// The name of the generic parameter for the TryConvert method. /// Set this property in order to avoid name collisions with generic union type parameters /// public String TryConvertTypeName { get; set; } = "TUnion"; /// /// The name of the generic parameter for the Match method. /// Set this property in order to avoid name collisions with generic union type parameters /// public String MatchTypeName { get; set; } = "TMatchResult"; /// /// The name to use for the discriminating tag type. /// public String TagTypeName { get; set; } = "__Tag"; /// /// The name to use for the container type containing value types. /// public String ValueTypeContainerTypeName { get; set; } = "__ValueTypeContainer"; /// /// The name to use for the field containing value types. /// public String ValueTypeContainerName { get; set; } = "__value"; /// /// The name to use for the field containing reference types. /// public String ReferenceTypeContainerName { get; set; } = "__reference"; /// /// The name to use for the field containing the discriminating tag. /// public String TagFieldName { get; set; } = "__tag"; /// /// The name to use for the default (uninitialized) tag value. /// public String TagNoneName { get; set; } = "__None"; /// /// The name of the generated json converter type. /// public String JsonConverterTypeName { get; set; } = "JsonConverter"; #endregion } #endregion