/// <summary>
        /// Returns the <see cref="TextWriter"/> of the current <see cref="CodeTypeDeclaration"/>.
        /// </summary>
        /// <param name="codeObject"></param>
        /// <param name="namespaceName"></param>
        /// <returns></returns>
        public static TextWriter ToTextWriter(this CodeTypeDeclaration codeObject, string namespaceName = null)
        {
            if (namespaceName == null)
            {
                namespaceName = "DefaultCodeNamespace";
            }

            var ccu = new CodeCompileUnit();

            var codeNamespace = new CodeNamespace(namespaceName);

            codeNamespace.Types.Add(codeObject);
            ccu.Namespaces.Add(codeNamespace);

            return(ccu.ToStringWriter());
        }