/// <summary>
        /// Disposes of an object if it implements IDisposable, otherwise does nothing
        /// </summary>
        public static string DisplayName(this Type t, NamespaceOption namespaceOption = NamespaceOption.Full)
        {
            if (ReferenceEquals(t, null))
            {
                return("[null]");
            }

            var displayName = t.Name;

            if (t.IsValueType)
            {
                return(displayName);
            }

            var ns = namespaceOption;

            if (t.Namespace == null || t.Namespace.StartsWith("System") || t.IsNested || t.IsGenericType)
            {
                ns = NamespaceOption.None;
            }

            switch (ns)
            {
            case NamespaceOption.Ending:
                var i = t.Namespace.LastIndexOf('.');
                if (i < 0)
                {
                    displayName = t.Namespace + '.' + displayName;
                }
                else
                {
                    displayName = ".." + t.Namespace.Substring(i) + '.' + displayName;
                }
                break;

            case NamespaceOption.Full:
                displayName = t.Namespace + '.' + displayName;
                break;
            }

            if (t.IsGenericType)
            {
                displayName  = displayName.Substring(0, displayName.IndexOf('`'));
                displayName += "<";
                displayName += string.Join(",", t.GetGenericArguments().Select(ga => ga.DisplayName(NamespaceOption.None)));
                displayName += ">";
            }

            if (t.IsNested)
            {
                displayName = t.DeclaringType.DisplayName(namespaceOption) + " { " + displayName + " }";
            }

            return(displayName);
        }
Beispiel #2
0
#pragma warning disable CA1801 // Remove unused parameter
        public async Task <int> ExecuteAsync(CancellationToken cancellationToken)
#pragma warning restore CA1801 // Remove unused parameter
        {
            // TODO - make CompileFile async and use the cancellationToken
            CompileManager.CompileFile(this.InputFileOption.Value() !, this.OutputFileOption.Value() !, LogError, new GraphQLGenerationOptions {
                Namespace = NamespaceOption.Value() ?? "Unspecified", LanguageVersion = float.Parse(LanguageVersionOption.Value() ?? "8.0")
            });

            await Task.Yield();

            return(0);
        }