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 53dd062b5d4b4c..69f87fdcd48f6c 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs
@@ -16,10 +16,18 @@ internal class Emitter
private const int MaxLoggerMessageDefineArguments = 6;
private const int DefaultStringBuilderCapacity = 1024;
+ private static readonly string s_generatedTypeSummary =
+ " " +
+ "This API supports the logging infrastructure and is not intended to be used directly from your code. " +
+ "It is subject to change in the future. " +
+ "";
private static readonly string s_generatedCodeAttribute =
$"global::System.CodeDom.Compiler.GeneratedCodeAttribute(" +
$"\"{typeof(Emitter).Assembly.GetName().Name}\", " +
$"\"{typeof(Emitter).Assembly.GetName().Version}\")";
+ private static readonly string s_editorBrowsableAttribute =
+ "global::System.ComponentModel.EditorBrowsableAttribute(" +
+ "global::System.ComponentModel.EditorBrowsableState.Never)";
private readonly StringBuilder _builder = new StringBuilder(DefaultStringBuilderCapacity);
private bool _needEnumerationHelper;
@@ -127,7 +135,9 @@ namespace {lc.Namespace}
private void GenStruct(LoggerMethod lm, string nestedIndentation)
{
_builder.AppendLine($@"
+ {nestedIndentation}/// {s_generatedTypeSummary}
{nestedIndentation}[{s_generatedCodeAttribute}]
+ {nestedIndentation}[{s_editorBrowsableAttribute}]
{nestedIndentation}private readonly struct __{lm.Name}Struct : global::System.Collections.Generic.IReadOnlyList>
{nestedIndentation}{{");
GenFields(lm, nestedIndentation);
@@ -156,7 +166,7 @@ private void GenStruct(LoggerMethod lm, string nestedIndentation)
{nestedIndentation}}}
");
_builder.Append($@"
- {nestedIndentation}public static string Format(__{lm.Name}Struct state, global::System.Exception? ex) => state.ToString();
+ {nestedIndentation}public static readonly global::System.Func<__{lm.Name}Struct, global::System.Exception?, string> Format = (state, ex) => state.ToString();
{nestedIndentation}public int Count => {lm.TemplateParameters.Count + 1};
@@ -489,7 +499,9 @@ private void GenEnumerationHelper()
if (_needEnumerationHelper)
{
_builder.Append($@"
+/// {s_generatedTypeSummary}
[{s_generatedCodeAttribute}]
+[{s_editorBrowsableAttribute}]
internal static class __LoggerMessageGenerator
{{
public static string Enumerate(global::System.Collections.IEnumerable? enumerable)
diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/.editorconfig b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/.editorconfig
new file mode 100644
index 00000000000000..e9356fee5e6d29
--- /dev/null
+++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/.editorconfig
@@ -0,0 +1,4 @@
+# editorconfig.org
+
+[*.generated.txt]
+insert_final_newline = false
diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDefaultValues.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDefaultValues.generated.txt
index f4747ef679f83c..5292db82ac8c84 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDefaultValues.generated.txt
+++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDefaultValues.generated.txt
@@ -5,7 +5,9 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses
{
partial class TestWithDefaultValues
{
+ /// This API supports the logging infrastructure and is not intended to be used directly from your code. It is subject to change in the future.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
private readonly struct __M0Struct : global::System.Collections.Generic.IReadOnlyList>
{
@@ -15,7 +17,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses
return $"";
}
- public static string Format(__M0Struct state, global::System.Exception? ex) => state.ToString();
+ public static readonly global::System.Func<__M0Struct, global::System.Exception?, string> Format = (state, ex) => state.ToString();
public int Count => 1;
diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDynamicLogLevel.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDynamicLogLevel.generated.txt
index 1d1af4719fe40d..6326923544aa9e 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDynamicLogLevel.generated.txt
+++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithDynamicLogLevel.generated.txt
@@ -5,7 +5,9 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses
{
partial class TestWithDynamicLogLevel
{
+ /// This API supports the logging infrastructure and is not intended to be used directly from your code. It is subject to change in the future.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
private readonly struct __M9Struct : global::System.Collections.Generic.IReadOnlyList>
{
@@ -15,7 +17,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses
return $"M9";
}
- public static string Format(__M9Struct state, global::System.Exception? ex) => state.ToString();
+ public static readonly global::System.Func<__M9Struct, global::System.Exception?, string> Format = (state, ex) => state.ToString();
public int Count => 1;
diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMoreThan6Params.generated.txt b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMoreThan6Params.generated.txt
index 3387ec2da1a327..84611c6766f720 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMoreThan6Params.generated.txt
+++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/Baselines/TestWithMoreThan6Params.generated.txt
@@ -5,7 +5,9 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses
{
partial class TestWithMoreThan6Params
{
+ /// This API supports the logging infrastructure and is not intended to be used directly from your code. It is subject to change in the future.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
private readonly struct __Method9Struct : global::System.Collections.Generic.IReadOnlyList>
{
private readonly global::System.Int32 _p1;
@@ -41,7 +43,7 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses
return $"M9 {p1} {p2} {p3} {p4} {p5} {p6} {p7}";
}
- public static string Format(__Method9Struct state, global::System.Exception? ex) => state.ToString();
+ public static readonly global::System.Func<__Method9Struct, global::System.Exception?, string> Format = (state, ex) => state.ToString();
public int Count => 8;
@@ -88,7 +90,9 @@ namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses
}
}
}
+/// This API supports the logging infrastructure and is not intended to be used directly from your code. It is subject to change in the future.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "%VERSION%")]
+[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
internal static class __LoggerMessageGenerator
{
public static string Enumerate(global::System.Collections.IEnumerable? enumerable)