Skip to content

OnixLabs.Core.Reflection.TypeDeclarationFlags

matthew edited this page May 27, 2026 · 1 revision

TypeDeclarationFlags Enum

Specifies flags that control how a type name is formatted by GetCSharpTypeDeclaration.

Namespace OnixLabs.Core.Reflection
Assembly OnixLabs.Core.dll (NuGet)

Definition

[Flags]
public enum TypeDeclarationFlags

This is a [Flags] enumeration, so its members can be combined with the bitwise OR (|) operator to control multiple aspects of the output simultaneously.

Fields

Name Value Description
None 0 No type name arguments are applied. Only simple CLR type names are used, excluding generic type arguments and tuple syntax.
UseNamespaceQualifiedTypeNames 1 Namespace-qualified CLR type names are used where applicable. If the namespace-qualified name is not available, the type's simple CLR type name is used instead.
UseAliasedTypeNames 2 Type alias names (for example, int, string, bool) are used where applicable. Supersedes UseNamespaceQualifiedTypeNames: if an alias is not available, the namespace-qualified name is used when UseNamespaceQualifiedTypeNames is set; otherwise the simple CLR type name is used.
UseNullableShorthandTypeNames 4 Nullable<T> types are formatted using nullable shorthand syntax (for example, int?). Supersedes UseGenericTypeArguments.
UseGenericTypeArguments 8 If a type is generic, it is formatted with its generic type arguments (for example, List<Int32>).
UseValueTupleSyntax 16 ValueTuple types are formatted using tuple syntax (for example, (String, Int32)). Supersedes UseGenericTypeArguments.
UseValueTupleNames 32 ValueTuple types are formatted using tuple element names where applicable (for example, (String Item1, Int32 Item2)). Supersedes UseValueTupleSyntax and UseGenericTypeArguments.
All 63 All type name flags are set. Equivalent to UseNamespaceQualifiedTypeNames | UseAliasedTypeNames | UseNullableShorthandTypeNames | UseGenericTypeArguments | UseValueTupleSyntax | UseValueTupleNames.

Remarks

The flags interact according to a precedence chain that determines which formatting wins when multiple flags apply to the same construct:

  • UseAliasedTypeNames supersedes UseNamespaceQualifiedTypeNames for types that have a C# language alias.
  • UseNullableShorthandTypeNames supersedes UseGenericTypeArguments for Nullable<T> types.
  • UseValueTupleSyntax supersedes UseGenericTypeArguments for value tuples.
  • UseValueTupleNames supersedes both UseValueTupleSyntax and UseGenericTypeArguments for value tuples.

The following table illustrates how typeof(int), typeof(int?), typeof(List<int>), and typeof((string, int)) render under representative flag combinations.

Type Flags Result
int None Int32
int UseAliasedTypeNames int
int UseNamespaceQualifiedTypeNames System.Int32
int? UseNullableShorthandTypeNames Int32?
int? UseNullableShorthandTypeNames | UseAliasedTypeNames int?
int? UseGenericTypeArguments Nullable<Int32>
List<int> UseGenericTypeArguments List<Int32>
List<int> All System.Collections.Generic.List<int>
(string, int) UseValueTupleSyntax (String, Int32)
(string, int) UseValueTupleNames (String Item1, Int32 Item2)
(string, int) All (string Item1, int Item2)

See Also

ONIXLabs .NET Library


Clone this wiki locally