Skip to content

Commit

Permalink
Fix ServiceDescriptor.DebuggerToString()
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpetit committed Jul 5, 2023
1 parent 72b2b5d commit 17b9312
Showing 1 changed file with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1012,17 +1012,36 @@ private string DebuggerToString()
string debugText = $@"Lifetime = {Lifetime}, ServiceType = ""{ServiceType.FullName}""";

// Either implementation type, factory or instance is set.
if (ImplementationType != null)
{
debugText += $@", ImplementationType = ""{ImplementationType.FullName}""";
}
else if (ImplementationFactory != null)
if (IsKeyedService)
{
debugText += $@", ImplementationFactory = {ImplementationFactory.Method}";
debugText += $@", ServiceKey = ""{ServiceKey}""";
if (KeyedImplementationType != null)
{
debugText += $@", KeyedImplementationType = ""{KeyedImplementationType.FullName}""";
}
else if (KeyedImplementationFactory != null)
{
debugText += $@", KeyedImplementationFactory = {KeyedImplementationFactory.Method}";
}
else
{
debugText += $@", KeyedImplementationInstance = {KeyedImplementationInstance}";
}
}
else
{
debugText += $@", ImplementationInstance = {ImplementationInstance}";
if (ImplementationType != null)
{
debugText += $@", ImplementationType = ""{ImplementationType.FullName}""";
}
else if (ImplementationFactory != null)
{
debugText += $@", ImplementationFactory = {ImplementationFactory.Method}";
}
else
{
debugText += $@", ImplementationInstance = {ImplementationInstance}";
}
}

return debugText;
Expand Down

0 comments on commit 17b9312

Please sign in to comment.