Skip to content

Commit

Permalink
default Registration Strategy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Dec 5, 2023
1 parent 980da4e commit 201658b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Injectio.Generators/ServiceRegistrationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private static (IReadOnlyCollection<Diagnostic> diagnostics, bool hasServiceColl
&& implementationType == null
&& serviceTypes.Count == 0)
{
registrationStrategy = KnownTypes.RegistrationStrategyImplementedInterfacesShortName;
registrationStrategy = KnownTypes.RegistrationStrategySelfWithInterfacesShortName;
}

// no implementation type set, use class attribute is on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ namespace Microsoft.Extensions.DependencyInjection
)
);

global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd(
serviceCollection,
global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Describe(
typeof(global::Injectio.Sample.SingletonService),
typeof(global::Injectio.Sample.SingletonService),
global::Microsoft.Extensions.DependencyInjection.ServiceLifetime.Scoped
)
);
return serviceCollection;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ namespace Microsoft.Extensions.DependencyInjection
)
);

global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd(
serviceCollection,
global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Describe(
typeof(global::Injectio.Sample.ServiceTag),
typeof(global::Injectio.Sample.ServiceTag),
global::Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton
)
);
}

return serviceCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ namespace Microsoft.Extensions.DependencyInjection
)
);

global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd(
serviceCollection,
global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Describe(
typeof(global::Injectio.Sample.SingletonService),
typeof(global::Injectio.Sample.SingletonService),
global::Microsoft.Extensions.DependencyInjection.ServiceLifetime.Transient
)
);
return serviceCollection;
}
}
Expand Down

0 comments on commit 201658b

Please sign in to comment.