diff --git a/Makefile b/Makefile index 798a628..c8e136b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SOLUTION_FILE = $(ROOT_FOLDER)Purview.Telemetry.SourceGenerator.sln TEST_PROJECT = $(ROOT_FOLDER)Purview.Telemetry.SourceGenerator.sln CONFIGURATION = Release -PACK_VERSION = 1.0.9 +PACK_VERSION = 1.0.10 ARTIFACT_FOLDER = p:/sync-projects/.local-nuget/ # Targets diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenAssemblyEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenAssemblyEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs similarity index 73% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenAssemblyEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenAssemblyEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs index dae4186..c132ae7 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenAssemblyEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenAssemblyEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestActivitiesCore.DependencyInjection.g.cs +//HintName: Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestActivitiesCore + static class TestActivitiesCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestActivities(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestActivities), typeof(Testing.TestActivitiesCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs similarity index 73% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs index dae4186..c132ae7 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestActivitiesCore.DependencyInjection.g.cs +//HintName: Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestActivitiesCore + static class TestActivitiesCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestActivities(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestActivities), typeof(Testing.TestActivitiesCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs similarity index 73% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs index dae4186..c132ae7 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorActivityTests.Generate_GivenInterfaceEnableDI_GeneratesActivity.DotNet8_0#Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestActivitiesCore.DependencyInjection.g.cs +//HintName: Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestActivitiesCore + static class TestActivitiesCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestActivities(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestActivities), typeof(Testing.TestActivitiesCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenAssemblyEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenAssemblyEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs index 8315f6a..bf44461 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenAssemblyEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestLoggerCore.DependencyInjection.g.cs +//HintName: Testing.TestLoggerCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestLoggerCore + static class TestLoggerCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestLogger(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestLogger), typeof(Testing.TestLoggerCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs index 8315f6a..bf44461 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestLoggerCore.DependencyInjection.g.cs +//HintName: Testing.TestLoggerCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestLoggerCore + static class TestLoggerCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestLogger(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestLogger), typeof(Testing.TestLoggerCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenAssemblyEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenAssemblyEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs index 8315f6a..bf44461 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenAssemblyEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorLoggingTests.Generate_GivenInterfaceEnableDI_GeneratesLog.DotNet8_0#Testing.TestLoggerCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestLoggerCore.DependencyInjection.g.cs +//HintName: Testing.TestLoggerCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestLoggerCore + static class TestLoggerCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestLogger(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestLogger), typeof(Testing.TestLoggerCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs index c1cf286..eb07be0 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestMetricsCore.DependencyInjection.g.cs +//HintName: Testing.TestMetricsCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestMetricsCore + static class TestMetricsCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestMetrics), typeof(Testing.TestMetricsCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs index c1cf286..eb07be0 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestMetricsCore.DependencyInjection.g.cs +//HintName: Testing.TestMetricsCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestMetricsCore + static class TestMetricsCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestMetrics), typeof(Testing.TestMetricsCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs index c1cf286..eb07be0 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Testing.TestMetricsCore.DependencyInjection.g.cs +//HintName: Testing.TestMetricsCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class TestMetricsCore + static class TestMetricsCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Testing.ITestMetrics), typeof(Testing.TestMetricsCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMESection_GeneratesTelemetry.DotNet8_0#EntityStoreTelemetryCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMESection_GeneratesTelemetry.DotNet8_0#EntityStoreTelemetryCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMESection_GeneratesTelemetry.DotNet8_0#EntityStoreTelemetryCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMESection_GeneratesTelemetry.DotNet8_0#EntityStoreTelemetryCoreDIExtension.DependencyInjection.g.verified.cs index a61d673..6190319 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMESection_GeneratesTelemetry.DotNet8_0#EntityStoreTelemetryCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMESection_GeneratesTelemetry.DotNet8_0#EntityStoreTelemetryCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: EntityStoreTelemetryCore.DependencyInjection.g.cs +//HintName: EntityStoreTelemetryCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class EntityStoreTelemetryCore + static class EntityStoreTelemetryCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddEntityStoreTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(IEntityStoreTelemetry), typeof(EntityStoreTelemetryCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiActivitiesSection_GeneratesTelemetry.DotNet8_0#ActivityTelemetryCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiActivitiesSection_GeneratesTelemetry.DotNet8_0#ActivityTelemetryCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiActivitiesSection_GeneratesTelemetry.DotNet8_0#ActivityTelemetryCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiActivitiesSection_GeneratesTelemetry.DotNet8_0#ActivityTelemetryCoreDIExtension.DependencyInjection.g.verified.cs index b990c66..6eb466f 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiActivitiesSection_GeneratesTelemetry.DotNet8_0#ActivityTelemetryCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiActivitiesSection_GeneratesTelemetry.DotNet8_0#ActivityTelemetryCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: ActivityTelemetryCore.DependencyInjection.g.cs +//HintName: ActivityTelemetryCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class ActivityTelemetryCore + static class ActivityTelemetryCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivityTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(IActivityTelemetry), typeof(ActivityTelemetryCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiLoggingSection_GeneratesTelemetry.DotNet8_0#LoggingTelemetryCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiLoggingSection_GeneratesTelemetry.DotNet8_0#LoggingTelemetryCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiLoggingSection_GeneratesTelemetry.DotNet8_0#LoggingTelemetryCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiLoggingSection_GeneratesTelemetry.DotNet8_0#LoggingTelemetryCoreDIExtension.DependencyInjection.g.verified.cs index fee7e70..c55be27 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiLoggingSection_GeneratesTelemetry.DotNet8_0#LoggingTelemetryCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiLoggingSection_GeneratesTelemetry.DotNet8_0#LoggingTelemetryCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: LoggingTelemetryCore.DependencyInjection.g.cs +//HintName: LoggingTelemetryCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class LoggingTelemetryCore + static class LoggingTelemetryCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddLoggingTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(ILoggingTelemetry), typeof(LoggingTelemetryCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCoreDIExtension.DependencyInjection.g.verified.cs similarity index 75% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCoreDIExtension.DependencyInjection.g.verified.cs index b8b9094..2eaaaa8 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: MeterTelemetryCore.DependencyInjection.g.cs +//HintName: MeterTelemetryCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class MeterTelemetryCore + static class MeterTelemetryCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddMeterTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(IMeterTelemetry), typeof(MeterTelemetryCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCoreDIExtension.DependencyInjection.g.verified.cs similarity index 74% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCoreDIExtension.DependencyInjection.g.verified.cs index 1b5d8af..62f7e88 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromWikiMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: ServiceTelemetryCore.DependencyInjection.g.cs +//HintName: ServiceTelemetryCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class ServiceTelemetryCore + static class ServiceTelemetryCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddServiceTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(IServiceTelemetry), typeof(ServiceTelemetryCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenICacheServiceProviderTelemetry_GeneratesTelemetry.DotNet8_0#Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCore.DependencyInjection.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenICacheServiceProviderTelemetry_GeneratesTelemetry.DotNet8_0#Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCoreDIExtension.DependencyInjection.g.verified.cs similarity index 69% rename from src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenICacheServiceProviderTelemetry_GeneratesTelemetry.DotNet8_0#Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCore.DependencyInjection.g.verified.cs rename to src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenICacheServiceProviderTelemetry_GeneratesTelemetry.DotNet8_0#Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCoreDIExtension.DependencyInjection.g.verified.cs index 45a154e..509cd2b 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenICacheServiceProviderTelemetry_GeneratesTelemetry.DotNet8_0#Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCore.DependencyInjection.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenICacheServiceProviderTelemetry_GeneratesTelemetry.DotNet8_0#Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCoreDIExtension.DependencyInjection.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCore.DependencyInjection.g.cs +//HintName: Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCoreDIExtension.DependencyInjection.g.cs //------------------------------------------------------------------------------ // // This code was generated by the Purview.Telemetry.SourceGenerator @@ -16,14 +16,12 @@ namespace Microsoft.Extensions.DependencyInjection { [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - static class CacheServiceProviderTelemetryCore + static class CacheServiceProviderTelemetryCoreDIExtension { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] static public Microsoft.Extensions.DependencyInjection.IServiceCollection AddCacheServiceProviderTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { - services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(Purview.Interfaces.ApplicationServices.Caching.ICacheServiceProviderTelemetry), typeof(Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCore), Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton)); - - return services; + return services.AddSingleton(); } } } diff --git a/src/Purview.Telemetry.SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs b/src/Purview.Telemetry.SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs index e889cca..b2a49db 100644 --- a/src/Purview.Telemetry.SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs +++ b/src/Purview.Telemetry.SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs @@ -39,7 +39,7 @@ public static void GenerateImplementation( var classNameToGenerate = attribute.DependencyInjectionClassName.Value; if (string.IsNullOrWhiteSpace(classNameToGenerate)) - classNameToGenerate = implementationClassName; + classNameToGenerate = implementationClassName + "DIExtension"; logger?.Debug($"Generating service dependency class {classNameToGenerate} for: {fullyQualifiedNamespace}{sourceInterfaceName}"); @@ -102,21 +102,15 @@ static void EmitMethod(StringBuilder builder, int indent, string className, stri .Append(Constants.DependencyInjection.IServiceCollection) .AppendLine(" services)") .Append(indent, '{') - .Append(indent + 1, "services.Add(new ", withNewLine: false) - .Append(Constants.DependencyInjection.ServiceDescriptor) - .Append("(typeof(") + .Append(indent + 1, "return services.AddSingleton<", withNewLine: false) // serviceType... .Append(fullyQualifiedNamespace) .Append(interfaceName) - .Append("), typeof(") + .Append(", ") // implementationType .Append(fullyQualifiedNamespace) .Append(className) - .Append("), ") - .Append(Constants.DependencyInjection.Singleton) - .AppendLine("));") - .AppendLine() - .Append(indent + 1, "return services;") + .AppendLine(">();") .Append(indent, '}') ; } diff --git a/version.json b/version.json index d44bdc3..37a2eda 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.0.9", + "version": "1.0.10", "cloudBuild": { "buildNumber": { "enabled": true,