Exemplo n.º 1
0
        protected override async Task <bool> Compile(
            GenerateCommandContext context,
            string path,
            Configuration config,
            ClientGenerator generator,
            IReadOnlyList <DocumentInfo> documents,
            ICollection <HCError> errors)
        {
            string hashFile = FileSystem.CombinePath(
                path,
                WellKnownDirectories.Generated,
                WellKnownFiles.Hash);

            if (await SkipCompileAsync(hashFile, documents, context.Force)
                .ConfigureAwait(false))
            {
                return(true);
            }

            generator.ModifyOptions(o =>
            {
                o.LanguageVersion = context.Language;
                o.EnableDISupport = context.DISupport;
            });

            generator.SetNamespace(context.Namespace);

            IReadOnlyList <HCError> validationErrors = generator.Validate();

            if (validationErrors.Count > 0)
            {
                foreach (HCError error in validationErrors)
                {
                    errors.Add(error);
                }
                return(false);
            }

            await generator.BuildAsync().ConfigureAwait(false);

            await Task.Run(() => File.WriteAllText(hashFile, CreateHash(documents)))
            .ConfigureAwait(false);

            if (context.PersistedQueryFile is { } fileName)
            {
                using IActivity activity = Output.WriteActivity("Export queries", fileName);
                FileSystem.EnsureDirectoryExists(FileSystem.GetDirectoryName(fileName));
                await generator.ExportPersistedQueriesAsync(fileName).ConfigureAwait(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        protected override Task <bool> Compile(
            string path,
            Configuration config,
            ClientGenerator generator)
        {
            IReadOnlyList <HCError> validationErrors = generator.Validate();

            if (validationErrors.Count > 0)
            {
                WriteErrors(validationErrors);
                return(Task.FromResult(false));
            }

            return(Task.FromResult(true));
        }
Exemplo n.º 3
0
        protected override async Task <bool> Compile(
            string path,
            Configuration config,
            ClientGenerator generator)
        {
            IReadOnlyList <HCError> validationErrors = generator.Validate();

            if (validationErrors.Count > 0)
            {
                WriteErrors(validationErrors);
                return(false);
            }

            await generator.BuildAsync();

            return(true);
        }
        protected override async Task <bool> Compile(
            GenerateCommandContext context,
            string path,
            Configuration config,
            ClientGenerator generator,
            IReadOnlyList <DocumentInfo> documents,
            ICollection <HCError> errors)
        {
            string hashFile = FileSystem.CombinePath(
                path,
                WellKnownDirectories.Generated,
                WellKnownFiles.Hash);

            if (await SkipCompileAsync(path, hashFile, documents, context.Force))
            {
                return(true);
            }

            generator.ModifyOptions(o =>
            {
                o.LanguageVersion = context.Language;
                o.EnableDISupport = context.DISupport;
            });

            generator.SetNamespace(context.Namespace);

            IReadOnlyList <HCError> validationErrors = generator.Validate();

            if (validationErrors.Count > 0)
            {
                foreach (HCError error in validationErrors)
                {
                    errors.Add(error);
                }
                return(false);
            }

            await generator.BuildAsync();

            await File.WriteAllTextAsync(hashFile, CreateHash(documents));

            return(true);
        }
Exemplo n.º 5
0
        protected override Task <bool> Compile(
            CompileCommandContext context,
            string path,
            Configuration config,
            ClientGenerator generator,
            IReadOnlyList <DocumentInfo> documents,
            ICollection <HCError> errors)
        {
            IReadOnlyList <HCError> validationErrors = generator.Validate();

            if (validationErrors.Count > 0)
            {
                foreach (HCError error in validationErrors)
                {
                    errors.Add(error);
                }
                return(Task.FromResult(false));
            }

            return(Task.FromResult(true));
        }
Exemplo n.º 6
0
        protected override async Task <bool> Compile(
            string path,
            Configuration config,
            ClientGenerator generator)
        {
            if (Enum.TryParse(LanguageVersion, true, out LanguageVersion version))
            {
                generator.ModifyOptions(o => o.LanguageVersion = version);
            }

            generator.ModifyOptions(o => o.EnableDISupport = DISupport);

            IReadOnlyList <HCError> validationErrors = generator.Validate();

            if (validationErrors.Count > 0)
            {
                WriteErrors(validationErrors);
                return(false);
            }

            await generator.BuildAsync();

            return(true);
        }