From af8feed563ca422956938bf0f9eb8bd5df8a4a16 Mon Sep 17 00:00:00 2001 From: John Douglas Leitch Date: Thu, 29 Jan 2026 23:55:42 -0500 Subject: [PATCH 1/7] Fixed LoggerMessageGenerator message escaping. --- .../gen/LoggerMessageGenerator.Emitter.cs | 11 ++++- .../LoggerMessageGeneratorEmitterTests.cs | 42 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs index a230e2f0354b80..682f8deae8cef0 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs @@ -581,7 +581,7 @@ private static string ConvertEndOfLineAndQuotationCharactersToEscapeForm(string int index = 0; while (index < s.Length) { - if (s[index] is '\n' or '\r' or '"') + if (s[index] is < (char)0x20 or '"' or '\\') { break; } @@ -615,6 +615,15 @@ private static string ConvertEndOfLineAndQuotationCharactersToEscapeForm(string sb.Append('"'); break; + case < (char)0x20: + sb.AppendFormat("\\x{0:x2}", (byte)s[index]); + break; + + case '\\': + sb.Append('\\'); + sb.Append('\\'); + break; + default: sb.Append(s[index]); break; diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs index 4fcc33163d6380..88a206f8031997 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs @@ -277,6 +277,48 @@ public void GenericTypeParameterAttributesAreRetained() Assert.NotNull(type.GenericTypeParameters[1].GetCustomAttribute()); } + [Theory] + [InlineData(@"Foo \\ bar: {foo}")] + [InlineData(@"Foo \\\\ bar: {foo}")] + [InlineData(@"Foo \"" bar: {foo}")] + [InlineData(@"Foo \r bar: {foo}")] + [InlineData(@"Foo \n bar: {foo}")] + [InlineData(@"Foo \x00 bar: {foo}")] + [InlineData(@"Foo \x1f bar: {foo}")] + public async Task EmittedMessageIsWellFormed(string message) + { + var code = + $$""" + namespace Test + { + using Microsoft.Extensions.Logging; + + partial class C + { + [LoggerMessage(EventId = 5230, Level = LogLevel.Information, Message = "{{message}}")] + static partial void Test(ILogger logger, string foo); + } + } + """; + + var (diagnostics, generatedSources) = await RoslynTestUtils + .RunGenerator( + new LoggerMessageGenerator(), + new[] { typeof(ILogger).Assembly, typeof(LoggerMessageAttribute).Assembly }, + new[] { code }, + includeBaseReferences: true) + .ConfigureAwait(false); + + var generatedSource = generatedSources[0]; + var generatedSourceDiagnostics = generatedSource.SyntaxTree.GetDiagnostics(); + var src = generatedSource.SourceText.ToString(); + + Assert.Empty(diagnostics); + Assert.Single(generatedSources); + Assert.Contains($"\"{message}\"", src); + Assert.Empty(generatedSourceDiagnostics); + } + private async Task VerifyAgainstBaselineUsingFile(string filename, string testSourceCode) { string baseline = LineEndingsHelper.Normalize(File.ReadAllText(Path.Combine("Baselines", filename))); From 655ea4059adf97de6ce4ec506fb102d246aa0003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Cincura=20=E2=86=B9?= Date: Fri, 30 Jan 2026 10:41:41 +0100 Subject: [PATCH 2/7] Update src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../LoggerMessageGeneratorEmitterTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs index 88a206f8031997..69e0405b13818c 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs @@ -309,12 +309,12 @@ partial class C includeBaseReferences: true) .ConfigureAwait(false); + Assert.Empty(diagnostics); + Assert.Single(generatedSources); + var generatedSource = generatedSources[0]; var generatedSourceDiagnostics = generatedSource.SyntaxTree.GetDiagnostics(); var src = generatedSource.SourceText.ToString(); - - Assert.Empty(diagnostics); - Assert.Single(generatedSources); Assert.Contains($"\"{message}\"", src); Assert.Empty(generatedSourceDiagnostics); } From ebc2841f154d3fb04e23de6e5af5aa21a8efb12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Cincura=20=E2=86=B9?= Date: Fri, 30 Jan 2026 10:43:11 +0100 Subject: [PATCH 3/7] Reorder diagnostics check in LoggerMessageGeneratorEmitterTests Moved the diagnostics retrieval after the source text assertion to ensure proper validation of generated diagnostics. --- .../LoggerMessageGeneratorEmitterTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs index 69e0405b13818c..2af564ca621d13 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs @@ -313,9 +313,10 @@ partial class C Assert.Single(generatedSources); var generatedSource = generatedSources[0]; - var generatedSourceDiagnostics = generatedSource.SyntaxTree.GetDiagnostics(); var src = generatedSource.SourceText.ToString(); Assert.Contains($"\"{message}\"", src); + + var generatedSourceDiagnostics = generatedSource.SyntaxTree.GetDiagnostics(); Assert.Empty(generatedSourceDiagnostics); } From 2f6a0f4fc74971c15524754d88554cbe6bd968c1 Mon Sep 17 00:00:00 2001 From: John Douglas Leitch Date: Fri, 30 Jan 2026 14:07:54 -0500 Subject: [PATCH 4/7] Fixed hex escape sequence issue. --- .../gen/LoggerMessageGenerator.Emitter.cs | 2 +- .../LoggerMessageGeneratorEmitterTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs index 682f8deae8cef0..bdd3c9812161c6 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs @@ -616,7 +616,7 @@ private static string ConvertEndOfLineAndQuotationCharactersToEscapeForm(string break; case < (char)0x20: - sb.AppendFormat("\\x{0:x2}", (byte)s[index]); + sb.AppendFormat("\\u{0:x4}", (byte)s[index]); break; case '\\': diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs index 2af564ca621d13..c9cd2d5e6f8a63 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs @@ -283,8 +283,8 @@ public void GenericTypeParameterAttributesAreRetained() [InlineData(@"Foo \"" bar: {foo}")] [InlineData(@"Foo \r bar: {foo}")] [InlineData(@"Foo \n bar: {foo}")] - [InlineData(@"Foo \x00 bar: {foo}")] - [InlineData(@"Foo \x1f bar: {foo}")] + [InlineData(@"Foo \u0000 bar: {foo}")] + [InlineData(@"Foo \u001f bar: {foo}")] public async Task EmittedMessageIsWellFormed(string message) { var code = From 80ad84dd7c127080af2814f7c82288e3062d4406 Mon Sep 17 00:00:00 2001 From: John Douglas Leitch Date: Fri, 30 Jan 2026 23:53:52 -0500 Subject: [PATCH 5/7] Updated LoggerMessageGenerator to use SymbolDisplay.FormatLiteral, expanded test. --- .../gen/LoggerMessageGenerator.Emitter.cs | 65 ++----------------- .../LoggerMessageGeneratorEmitterTests.cs | 27 +++++--- 2 files changed, 22 insertions(+), 70 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs index bdd3c9812161c6..fae46142a5594a 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; namespace Microsoft.Extensions.Logging.Generators { @@ -181,7 +182,7 @@ private void GenStruct(LoggerMethod lm, string nestedIndentation) string formatMethodEnd = formatMethodBegin.Length > 0 ? ")" : ""; _builder.Append($@" - {nestedIndentation}return {formatMethodBegin}$""{ConvertEndOfLineAndQuotationCharactersToEscapeForm(lm.Message)}""{formatMethodEnd}; + {nestedIndentation}return {formatMethodBegin}${SymbolDisplay.FormatLiteral(lm.Message, quote: true)}{formatMethodEnd}; {nestedIndentation}}} "); _builder.Append($@" @@ -280,7 +281,7 @@ private void GenCases(LoggerMethod lm, string nestedIndentation) _builder.AppendLine($" {nestedIndentation}{index++} => new global::System.Collections.Generic.KeyValuePair(\"{name}\", this.{NormalizeSpecialSymbol(p.CodeName)}),"); } - _builder.AppendLine($" {nestedIndentation}{index++} => new global::System.Collections.Generic.KeyValuePair(\"{{OriginalFormat}}\", \"{ConvertEndOfLineAndQuotationCharactersToEscapeForm(lm.Message)}\"),"); + _builder.AppendLine($" {nestedIndentation}{index++} => new global::System.Collections.Generic.KeyValuePair(\"{{OriginalFormat}}\", {SymbolDisplay.FormatLiteral(lm.Message, quote: true)}),"); } private void GenCallbackArguments(LoggerMethod lm) @@ -406,7 +407,7 @@ private void GenLogMethod(LoggerMethod lm, string nestedIndentation) GenDefineTypes(lm, brackets: true); - _builder.Append(@$"({level}, new global::Microsoft.Extensions.Logging.EventId({lm.EventId}, {eventName}), ""{ConvertEndOfLineAndQuotationCharactersToEscapeForm(lm.Message)}"", new global::Microsoft.Extensions.Logging.LogDefineOptions() {{ SkipEnabledCheck = true }}); + _builder.Append(@$"({level}, new global::Microsoft.Extensions.Logging.EventId({lm.EventId}, {eventName}), {SymbolDisplay.FormatLiteral(lm.Message, quote: true)}, new global::Microsoft.Extensions.Logging.LogDefineOptions() {{ SkipEnabledCheck = true }}); "); } @@ -576,64 +577,6 @@ public static string Enumerate(global::System.Collections.IEnumerable? enumerabl } } - private static string ConvertEndOfLineAndQuotationCharactersToEscapeForm(string s) - { - int index = 0; - while (index < s.Length) - { - if (s[index] is < (char)0x20 or '"' or '\\') - { - break; - } - index++; - } - - if (index >= s.Length) - { - return s; - } - - StringBuilder sb = new StringBuilder(s.Length); - sb.Append(s, 0, index); - - while (index < s.Length) - { - switch (s[index]) - { - case '\n': - sb.Append('\\'); - sb.Append('n'); - break; - - case '\r': - sb.Append('\\'); - sb.Append('r'); - break; - - case '"': - sb.Append('\\'); - sb.Append('"'); - break; - - case < (char)0x20: - sb.AppendFormat("\\u{0:x4}", (byte)s[index]); - break; - - case '\\': - sb.Append('\\'); - sb.Append('\\'); - break; - - default: - sb.Append(s[index]); - break; - } - - index++; - } - - return sb.ToString(); - } /// /// Checks if variableOrTemplateName contains a special symbol ('@') as starting char /// diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs index c9cd2d5e6f8a63..95ea729d1a1d5d 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs @@ -278,14 +278,23 @@ public void GenericTypeParameterAttributesAreRetained() } [Theory] - [InlineData(@"Foo \\ bar: {foo}")] - [InlineData(@"Foo \\\\ bar: {foo}")] - [InlineData(@"Foo \"" bar: {foo}")] - [InlineData(@"Foo \r bar: {foo}")] - [InlineData(@"Foo \n bar: {foo}")] - [InlineData(@"Foo \u0000 bar: {foo}")] - [InlineData(@"Foo \u001f bar: {foo}")] - public async Task EmittedMessageIsWellFormed(string message) + [InlineData(@"Foo \\ bar: {foo}", null)] + [InlineData(@"Foo \\\\ bar: {foo}", null)] + [InlineData(@"Foo \"" bar: {foo}", null)] + [InlineData(@"Foo \x22 bar: {foo}", @"Foo \"" bar: {foo}")] + [InlineData(@"Foo \u0022 bar: {foo}", @"Foo \"" bar: {foo}")] + [InlineData(@"Foo \r bar: {foo}", null)] + [InlineData(@"Foo \x0d bar: {foo}", @"Foo \r bar: {foo}")] + [InlineData(@"Foo \u000d bar: {foo}", @"Foo \r bar: {foo}")] + [InlineData(@"Foo \n bar: {foo}", null)] + [InlineData(@"Foo \x0a bar: {foo}", @"Foo \n bar: {foo}")] + [InlineData(@"Foo \u000a bar: {foo}", @"Foo \n bar: {foo}")] + [InlineData(@"Foo \0 bar: {foo}", null)] + [InlineData(@"Foo \x00 bar: {foo}", @"Foo \0 bar: {foo}")] + [InlineData(@"Foo \u0000 bar: {foo}", @"Foo \0 bar: {foo}")] + [InlineData(@"Foo \x1f bar: {foo}", @"Foo \u001f bar: {foo}")] + [InlineData(@"Foo \u001f bar: {foo}", null)] + public async Task EmittedMessageIsWellFormed(string message, string? expectedMessage) { var code = $$""" @@ -314,7 +323,7 @@ partial class C var generatedSource = generatedSources[0]; var src = generatedSource.SourceText.ToString(); - Assert.Contains($"\"{message}\"", src); + Assert.Contains($"\"{expectedMessage ?? message}\"", src); var generatedSourceDiagnostics = generatedSource.SyntaxTree.GetDiagnostics(); Assert.Empty(generatedSourceDiagnostics); From 38dbcaff354dd020781b31ce3edeae1b2afc17ee Mon Sep 17 00:00:00 2001 From: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com> Date: Sun, 1 Feb 2026 10:39:53 -0800 Subject: [PATCH 6/7] Remove trailing space from logging generated code --- ...romPrimaryConstructorWithParameterUsedInMethod.generated.txt | 2 +- ...TestWithLoggerInFieldAndFromPrimaryConstructor.generated.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructorWithParameterUsedInMethod.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructorWithParameterUsedInMethod.generated.txt index 4fc0f50d5c735b..819e66ee7c48a3 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructorWithParameterUsedInMethod.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructorWithParameterUsedInMethod.generated.txt @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __M0Callback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] public partial void M0() diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerInFieldAndFromPrimaryConstructor.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerInFieldAndFromPrimaryConstructor.generated.txt index acfd43a0d287b4..004210d7cc054b 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerInFieldAndFromPrimaryConstructor.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerInFieldAndFromPrimaryConstructor.generated.txt @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __M0Callback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] public partial void M0() From 2f0cf56238adf69fbd030e155041c6685a4662db Mon Sep 17 00:00:00 2001 From: Tarek Mahmoud Sayed Date: Sun, 1 Feb 2026 14:07:37 -0800 Subject: [PATCH 7/7] Remove more trailing spaces from logging baseline test files --- .../TestWithLoggerFromPrimaryConstructor.generated.txt | 2 +- .../TestWithMultipleClassesStableOrder.generated.txt | 6 +++--- .../Baselines/TestWithNestedClass.generated.txt | 2 +- ...hNestedClassWithGenericTypesWithAttributes.generated.txt | 2 +- .../Baselines/TestWithSkipEnabledCheck.generated.txt | 2 +- .../Baselines/TestWithTwoParams.generated.txt | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructor.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructor.generated.txt index ba6b0d865e6bf4..e96d098eb58158 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructor.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithLoggerFromPrimaryConstructor.generated.txt @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __M0Callback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] public partial void M0() diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMultipleClassesStableOrder.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMultipleClassesStableOrder.generated.txt index 0b8ab636f8430d..ad12596823cfad 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMultipleClassesStableOrder.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMultipleClassesStableOrder.generated.txt @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __LogACallback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(1, nameof(LogA)), "Message from ClassA", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(1, nameof(LogA)), "Message from ClassA", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] static partial void LogA(global::Microsoft.Extensions.Logging.ILogger logger) @@ -25,7 +25,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __LogBCallback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Information, new global::Microsoft.Extensions.Logging.EventId(2, nameof(LogB)), "Message from ClassB", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Information, new global::Microsoft.Extensions.Logging.EventId(2, nameof(LogB)), "Message from ClassB", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] static partial void LogB(global::Microsoft.Extensions.Logging.ILogger logger) @@ -43,7 +43,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __LogCCallback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Warning, new global::Microsoft.Extensions.Logging.EventId(3, nameof(LogC)), "Message from ClassC", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Warning, new global::Microsoft.Extensions.Logging.EventId(3, nameof(LogC)), "Message from ClassC", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] static partial void LogC(global::Microsoft.Extensions.Logging.ILogger logger) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClass.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClass.generated.txt index 893edde95fa3fc..29b331a346264a 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClass.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClass.generated.txt @@ -17,7 +17,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses.NestedNamesp { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __M9Callback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(9, nameof(M9)), "M9", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(9, nameof(M9)), "M9", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] public static partial void M9(global::Microsoft.Extensions.Logging.ILogger logger) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClassWithGenericTypesWithAttributes.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClassWithGenericTypesWithAttributes.generated.txt index c7ddd086fcf27e..e28c566fc631b7 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClassWithGenericTypesWithAttributes.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithNestedClassWithGenericTypesWithAttributes.generated.txt @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __M0Callback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(42, nameof(M0)), "a = {a}; b = {b}; c = {c}", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(42, nameof(M0)), "a = {a}; b = {b}; c = {c}", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] public static partial void M0(global::Microsoft.Extensions.Logging.ILogger logger, A a, B b, C c) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithSkipEnabledCheck.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithSkipEnabledCheck.generated.txt index 8b12047f86455f..d72647ae287170 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithSkipEnabledCheck.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithSkipEnabledCheck.generated.txt @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action __M0Callback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Information, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "Message: When using SkipEnabledCheck, the generated code skips logger.IsEnabled(logLevel) check before calling log. To be used when consumer has already guarded logger method in an IsEnabled check.", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define(global::Microsoft.Extensions.Logging.LogLevel.Information, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "Message: When using SkipEnabledCheck, the generated code skips logger.IsEnabled(logLevel) check before calling log. To be used when consumer has already guarded logger method in an IsEnabled check.", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] public static partial void M0(global::Microsoft.Extensions.Logging.ILogger logger) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithTwoParams.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithTwoParams.generated.txt index 14ffb45b81fa41..3802352b42d910 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithTwoParams.generated.txt +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithTwoParams.generated.txt @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] private static readonly global::System.Action, global::System.Exception?> __M0Callback = - global::Microsoft.Extensions.Logging.LoggerMessage.Define>(global::Microsoft.Extensions.Logging.LogLevel.Error, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0 {a1} {a2}", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); + global::Microsoft.Extensions.Logging.LoggerMessage.Define>(global::Microsoft.Extensions.Logging.LogLevel.Error, new global::Microsoft.Extensions.Logging.EventId(0, nameof(M0)), "M0 {a1} {a2}", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")] public static partial void M0(global::Microsoft.Extensions.Logging.ILogger logger, global::System.Int32 a1, global::System.Collections.Generic.IEnumerable a2)