Skip to content

Commit 17b9312

Browse files
committed
Fix ServiceDescriptor.DebuggerToString()
1 parent 72b2b5d commit 17b9312

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceDescriptor.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,17 +1012,36 @@ private string DebuggerToString()
10121012
string debugText = $@"Lifetime = {Lifetime}, ServiceType = ""{ServiceType.FullName}""";
10131013

10141014
// Either implementation type, factory or instance is set.
1015-
if (ImplementationType != null)
1016-
{
1017-
debugText += $@", ImplementationType = ""{ImplementationType.FullName}""";
1018-
}
1019-
else if (ImplementationFactory != null)
1015+
if (IsKeyedService)
10201016
{
1021-
debugText += $@", ImplementationFactory = {ImplementationFactory.Method}";
1017+
debugText += $@", ServiceKey = ""{ServiceKey}""";
1018+
if (KeyedImplementationType != null)
1019+
{
1020+
debugText += $@", KeyedImplementationType = ""{KeyedImplementationType.FullName}""";
1021+
}
1022+
else if (KeyedImplementationFactory != null)
1023+
{
1024+
debugText += $@", KeyedImplementationFactory = {KeyedImplementationFactory.Method}";
1025+
}
1026+
else
1027+
{
1028+
debugText += $@", KeyedImplementationInstance = {KeyedImplementationInstance}";
1029+
}
10221030
}
10231031
else
10241032
{
1025-
debugText += $@", ImplementationInstance = {ImplementationInstance}";
1033+
if (ImplementationType != null)
1034+
{
1035+
debugText += $@", ImplementationType = ""{ImplementationType.FullName}""";
1036+
}
1037+
else if (ImplementationFactory != null)
1038+
{
1039+
debugText += $@", ImplementationFactory = {ImplementationFactory.Method}";
1040+
}
1041+
else
1042+
{
1043+
debugText += $@", ImplementationInstance = {ImplementationInstance}";
1044+
}
10261045
}
10271046

10281047
return debugText;

0 commit comments

Comments
 (0)