public static ClrTypeInfo MakeNullable(this ClrTypeInfo clrTypeInfo)
        {
            if (clrTypeInfo.IsNullable)
            {
                throw new InvalidOperationException($"Type '{clrTypeInfo.FullName}' is already nullable.");
            }
            var genericClrType = (ClrTypeInfo)clrTypeInfo.Clone();

            genericClrType.CSharpName += "?";
            genericClrType.IsNullable  = true;
            return(genericClrType);
        }
        public static ClrTypeInfo MakeJsonElement(this ClrTypeInfo clrTypeInfo)
        {
            var type = typeof(JsonElement);
            var jsonElementClrType = (ClrTypeInfo)clrTypeInfo.Clone();

            jsonElementClrType.CSharpName = type.Name;
#pragma warning disable CS8601, CS8604 // Type should not have these properties as null
            jsonElementClrType.Id        = type.FullName;
            jsonElementClrType.Namespace = type.Namespace;
            jsonElementClrType.ReferenceNamespaces.Add(type.Namespace);
#pragma warning restore CS8601, CS8604
            return(jsonElementClrType);
        }
        public static ClrTypeInfo MakeEnumerableType(this ClrTypeInfo clrTypeInfo)
        {
            var enumerableClrType = (ClrTypeInfo)clrTypeInfo.Clone();

            enumerableClrType.IsGenericType        = true;
            enumerableClrType.IsInterface          = true;
            enumerableClrType.IsNullable           = true;
            enumerableClrType.GenericTypeArguments = new[] { clrTypeInfo };
#pragma warning disable CS8601 // Possible null reference assignment.
            enumerableClrType.FullName = typeof(IEnumerable <>).FullName;
#pragma warning restore CS8601 // Possible null reference assignment.
            enumerableClrType.CSharpName = $"IEnumerable<{clrTypeInfo.CSharpName}>";
            enumerableClrType.ReferenceNamespaces.Add("System.Collections.Generic");
            return(enumerableClrType);
        }
        public IEnumerable <ClrTypeInfo> ShallowTranslate(ClassEntity classEntity)
        {
            var classEntityName = classEntity.FormattedName;

            if (classTranslationOptions.Aliases.ContainsKey(classEntityName))
            {
                classEntityName = classTranslationOptions.Aliases[classEntityName];
            }

            var namespaceName = classEntity.NamespaceEntity.FullFormattedName;

            if (namespaceName is not null && classTranslationOptions.NamespaceAliases.ContainsKey(namespaceName))
            {
                namespaceName = classTranslationOptions.NamespaceAliases[namespaceName];
            }
            var @namespace = FullyQualifyNamespace(namespaceName);

            var clrTypeInfo = new ClrTypeInfo()
            {
                Id                        = $"{FullyQualifyNamespace(classEntity.NamespaceEntity.FullFormattedName)}.{classEntity.FormattedName}",
                Namespace                 = @namespace,
                Name                      = classEntity.Name,
                FullName                  = $"{@namespace}.{classEntity.FormattedName}",
                CSharpName                = classEntityName,
                IsNullable                = classEntity.Type != ClassType.EnumClass,
                IsEnum                    = classEntity.Type == ClassType.EnumClass,
                EnumValues                = classEntity.Type == ClassType.EnumClass ? classEntity.Properties.Select(EnumPropertyDefinitionTranslator.TranslatePropertyDefinition).ToArray() : null,
                IsInterface               = false,
                IsNullType                = false,
                IsGenericType             = false,
                GenericTypeArguments      = Enumerable.Empty <ClrTypeInfo>(),
                IsObsolete                = classEntity.TypeDefinition.IsDeprecated,
                ObsoleteMessage           = classEntity.TypeDefinition.Deprecated,
                IsGenerated               = true,
                GeneratedNamespace        = namespaceName,
                InitialGeneratedNamespace = classEntity.NamespaceEntity.FullFormattedName,
                RequiredNamespaces        = new HashSet <string>(),
                ReferenceNamespaces       = new HashSet <string>()
                {
                    @namespace
                },
                Interfaces   = new HashSet <string>(),
                BaseTypeName = classEntity.BaseClassName,
                Description  = classEntity.Description,
                Metadata     = new Dictionary <string, object>()
                {
                    { Constants.TypeMetadata.ClassType, classEntity.Type },
                    { Constants.TypeMetadata.ApiNamespace, classEntity.NamespaceEntity.Name }
                }
            };

            if (classEntity.ImplementInterface)
            {
                var interfaceTypeName = $"I{classEntity.FormattedName}";
                clrTypeInfo.Interfaces.Add(interfaceTypeName);
                var interfaceClrTypeInfo = (ClrTypeInfo)clrTypeInfo.Clone();
                interfaceClrTypeInfo.Id           = $"{@namespace}.{interfaceTypeName}";
                interfaceClrTypeInfo.Name         = interfaceTypeName;
                interfaceClrTypeInfo.FullName     = $"{@namespace}.{interfaceTypeName}";
                interfaceClrTypeInfo.CSharpName   = $"I{classEntityName}";
                interfaceClrTypeInfo.IsInterface  = true;
                interfaceClrTypeInfo.Interfaces   = new HashSet <string>();
                interfaceClrTypeInfo.BaseTypeName = null;

                clrTypeStore.AddClrType(interfaceClrTypeInfo);
                yield return(interfaceClrTypeInfo);
            }

            clrTypeStore.AddClrType(clrTypeInfo);
            yield return(clrTypeInfo);
        }