Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.Razor.Logging;

Expand Down Expand Up @@ -32,7 +34,7 @@ public void AppendLiteral(string s)

public void AppendFormatted<T>(T t)
{
_builder.Object.Append(t?.ToString() ?? "[null]");
_builder.Object.Append(GetMessage(t));
}

public void AppendFormatted<T>(T t, string format)
Expand All @@ -46,4 +48,19 @@ public override string ToString()
_builder.Dispose();
return result;
}

private static string GetMessage(object? value)
=> value switch
{
VisualStudio.LanguageServer.Protocol.Range range => range.ToDisplayString(),
VisualStudio.LanguageServer.Protocol.Position position => position.ToDisplayString(),
VisualStudio.LanguageServer.Protocol.ISumType sumType => GetMessage(sumType.Value),

Roslyn.LanguageServer.Protocol.Range range => range.ToDisplayString(),
Roslyn.LanguageServer.Protocol.Position position => position.ToDisplayString(),
Roslyn.LanguageServer.Protocol.ISumType sumType => GetMessage(sumType.Value),

null => "[null]",
_ => value.ToString() ?? "[null]"
};
}