﻿[  
// <auto-generated/>
#nullable enable
namespace Microsoft.Extensions.AmbientMetadata
{
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Gen.BuildMetadata", "VERSION")]
    internal static class BuildMetadataGeneratedExtensions
    {
        private const string DefaultSectionName = "ambientmetadata:build";

        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Gen.BuildMetadata", "VERSION")]
        [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
        private sealed class BuildMetadataSource : global::Microsoft.Extensions.Configuration.IConfigurationSource
        {
            public string SectionName { get; }

            public BuildMetadataSource(string sectionName)
            {
#if !NET
                if (string.IsNullOrWhiteSpace(sectionName))
                {
                    if (sectionName is null)
                    {
                        throw new global::System.ArgumentNullException(nameof(sectionName));
                    }

                    throw new global::System.ArgumentException("The value cannot be an empty string or composed entirely of whitespace.", nameof(sectionName));
                }
#else
                global::System.ArgumentException.ThrowIfNullOrWhiteSpace(sectionName);
#endif

                SectionName = sectionName;
            }

            public global::Microsoft.Extensions.Configuration.IConfigurationProvider Build(global::Microsoft.Extensions.Configuration.IConfigurationBuilder builder)
            {
                return new global::Microsoft.Extensions.Configuration.Memory.MemoryConfigurationProvider(new global::Microsoft.Extensions.Configuration.Memory.MemoryConfigurationSource())
                {
                    { $"{SectionName}:buildid", "TEST_GITHUB_RUNID" },
                    { $"{SectionName}:buildnumber", "TEST_GITHUB_RUNNUMBER" },
                    { $"{SectionName}:sourcebranchname", "TEST_GITHUB_REFNAME" },
                    { $"{SectionName}:sourceversion", "TEST_GITHUB_SHA" },
                };
            }
        }

        public static global::Microsoft.Extensions.Hosting.IHostBuilder UseBuildMetadata(this global::Microsoft.Extensions.Hosting.IHostBuilder builder, string sectionName = DefaultSectionName)
        {
#if !NET
            if (builder is null)
            {
                throw new global::System.ArgumentNullException(nameof(builder));
            }

            if (string.IsNullOrWhiteSpace(sectionName))
            {
                if (sectionName is null)
                {
                    throw new global::System.ArgumentNullException(nameof(sectionName));
                }

                throw new global::System.ArgumentException("The value cannot be an empty string or composed entirely of whitespace.", nameof(sectionName));
            }
#else
            global::System.ArgumentNullException.ThrowIfNull(builder);
            global::System.ArgumentException.ThrowIfNullOrWhiteSpace(sectionName);
#endif

            _ = builder.ConfigureHostConfiguration(configBuilder => configBuilder.AddBuildMetadata(sectionName))
                .ConfigureServices((hostBuilderContext, serviceCollection) =>
                    global::Microsoft.Extensions.DependencyInjection.BuildMetadataServiceCollectionExtensions.AddBuildMetadata(serviceCollection, hostBuilderContext.Configuration.GetSection(sectionName)));

            return builder;
        }

        public static TBuilder UseBuildMetadata<TBuilder>(this TBuilder builder, string sectionName = DefaultSectionName)
            where TBuilder : global::Microsoft.Extensions.Hosting.IHostApplicationBuilder
        {
#if !NET
            if (builder is null)
            {
                throw new global::System.ArgumentNullException(nameof(builder));
            }

            if (string.IsNullOrWhiteSpace(sectionName))
            {
                if (sectionName is null)
                {
                    throw new global::System.ArgumentNullException(nameof(sectionName));
                }

                throw new global::System.ArgumentException("The value cannot be an empty string or composed entirely of whitespace.", nameof(sectionName));
            }
#else
            global::System.ArgumentNullException.ThrowIfNull(builder);
            global::System.ArgumentException.ThrowIfNullOrWhiteSpace(sectionName);
#endif

            _ = builder.Configuration.AddBuildMetadata(sectionName);
            global::Microsoft.Extensions.DependencyInjection.BuildMetadataServiceCollectionExtensions.AddBuildMetadata(builder.Services, builder.Configuration.GetSection(sectionName));

            return builder;
        }

        public static global::Microsoft.Extensions.Configuration.IConfigurationBuilder AddBuildMetadata(this global::Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string sectionName = DefaultSectionName)
        {
#if !NET
            if (builder is null)
            {
                throw new global::System.ArgumentNullException(nameof(builder));
            }

            if (string.IsNullOrWhiteSpace(sectionName))
            {
                if (sectionName is null)
                {
                    throw new global::System.ArgumentNullException(nameof(sectionName));
                }

                throw new global::System.ArgumentException("The value cannot be an empty string or composed entirely of whitespace.", nameof(sectionName));
            }
#else
            global::System.ArgumentNullException.ThrowIfNull(builder);
            global::System.ArgumentException.ThrowIfNullOrWhiteSpace(sectionName);
#endif

            return builder.Add(new BuildMetadataSource(sectionName));
        }
    }
}

]
