Skip to content

Commit

Permalink
Merge pull request #40 from purview-dev/fixed-no-ns-bug
Browse files Browse the repository at this point in the history
bug: fixed issue where the DI class name was used instead of the generated class when no namespace was used for the interface
  • Loading branch information
kieronlanning authored Jun 3, 2024
2 parents 09d1795 + 4c4fc7c commit 4bf67d9
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 87 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestActivitiesCore.DependencyInjection.g.cs
//HintName: Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestActivities, Testing.TestActivitiesCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestActivitiesCore.DependencyInjection.g.cs
//HintName: Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestActivities, Testing.TestActivitiesCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestActivitiesCore.DependencyInjection.g.cs
//HintName: Testing.TestActivitiesCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestActivities, Testing.TestActivitiesCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestLoggerCore.DependencyInjection.g.cs
//HintName: Testing.TestLoggerCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestLogger, Testing.TestLoggerCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestLoggerCore.DependencyInjection.g.cs
//HintName: Testing.TestLoggerCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestLogger, Testing.TestLoggerCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestLoggerCore.DependencyInjection.g.cs
//HintName: Testing.TestLoggerCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestLogger, Testing.TestLoggerCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestMetricsCore.DependencyInjection.g.cs
//HintName: Testing.TestMetricsCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestMetrics, Testing.TestMetricsCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestMetricsCore.DependencyInjection.g.cs
//HintName: Testing.TestMetricsCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestMetrics, Testing.TestMetricsCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Testing.TestMetricsCore.DependencyInjection.g.cs
//HintName: Testing.TestMetricsCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Testing.ITestMetrics, Testing.TestMetricsCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: EntityStoreTelemetryCore.DependencyInjection.g.cs
//HintName: EntityStoreTelemetryCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<IEntityStoreTelemetry, EntityStoreTelemetryCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: ActivityTelemetryCore.DependencyInjection.g.cs
//HintName: ActivityTelemetryCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<IActivityTelemetry, ActivityTelemetryCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: LoggingTelemetryCore.DependencyInjection.g.cs
//HintName: LoggingTelemetryCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<ILoggingTelemetry, LoggingTelemetryCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: MeterTelemetryCore.DependencyInjection.g.cs
//HintName: MeterTelemetryCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<IMeterTelemetry, MeterTelemetryCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: ServiceTelemetryCore.DependencyInjection.g.cs
//HintName: ServiceTelemetryCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<IServiceTelemetry, ServiceTelemetryCore>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCore.DependencyInjection.g.cs
//HintName: Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCoreDIExtension.DependencyInjection.g.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Purview.Telemetry.SourceGenerator
Expand All @@ -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<Purview.Interfaces.ApplicationServices.Caching.ICacheServiceProviderTelemetry, Purview.Interfaces.ApplicationServices.Caching.CacheServiceProviderTelemetryCore>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}");

Expand Down Expand Up @@ -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, '}')
;
}
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 4bf67d9

Please sign in to comment.