Repository: dotnet/runtime
File: src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs (C#)

Code before:
                    _builder.Append($@"
        {nestedIndentation}/// <para><b>Level:</b> {levelName}</para>");
                }

                _builder.Append($@"
        {nestedIndentation}/// </summary>");
            }

            private static string GetLogLevelName(LoggerMethod lm)
            {
                if (lm.Level == null)
                {
                    // Dynamic log level - don't include in documentation
                    return string.Empty;
                }

                return lm.Level switch
                {
                    0 => "Trace",
                    1 => "Debug",
                    2 => "Information",
                    3 => "Warning",
                    4 => "Error",
                    5 => "Critical",
                    6 => "None",
                    _ => $"LogLevel({lm.Level})",
                };
            }

            private void GenEnumerationHelper()
            {
                if (_needEnumerationHelper)
                {
                                _builder.Append($@"
/// {GeneratedTypeSummary}
[{s_generatedCodeAttribute}]
[{EditorBrowsableAttribute}]
internal static class __LoggerMessageGenerator
{{
    public static string Enumerate(global::System.Collections.IEnumerable? enumerable)
    {{
        if (enumerable == null)
        {{
            return ""(null)"";
        }}

        var sb = new global::System.Text.StringBuilder();
        _ = sb.Append('[');

        bool first = true;
        foreach (object e in enumerable)

Review comment (suggestion):
@copilot Change this to use `LogLevel.ToString` (cast if necessary), instead of hardcoding strings here.

Code after:
                foreach (char c in text)
                {
                    if (c is '<' or '>' or '&' or '"' or '\'' or '\n' or '\r')
                    {
                        return PerformEscaping(text);
                    }
                }

                return text;

                static string PerformEscaping(string text)
                {
                    var sb = new StringBuilder(text.Length + 20);
                    foreach (char c in text)
                    {
                        switch (c)
                        {
                            case '<':
                                sb.Append("&lt;");
                                break;
                            case '>':
                                sb.Append("&gt;");
                                break;
                            case '&':
                                sb.Append("&amp;");
                                break;
                            case '"':
                                sb.Append("&quot;");
                                break;
                            case '\'':
                                sb.Append("&apos;");
                                break;
                            case '\n':
                                sb.Append("&#10;");
                                break;
                            case '\r':
                                sb.Append("&#13;");
                                break;
                            default:
                                sb.Append(c);
                                break;
                        }
                    }
                    return sb.ToString();
                }
            }

            private static string GetLogLevelName(int level)
            {
                return level switch
                {