diff --git a/src/AutoLoggerMessageGenerator/Extractors/EnclosingClassExtractor.cs b/src/AutoLoggerMessageGenerator/Extractors/EnclosingClassExtractor.cs deleted file mode 100644 index 1f2ca2f..0000000 --- a/src/AutoLoggerMessageGenerator/Extractors/EnclosingClassExtractor.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; - -namespace AutoLoggerMessageGenerator.Extractors; - -internal static class EnclosingClassExtractor -{ - public static (string Namespace, string ClassName) Extract(InvocationExpressionSyntax invocationExpression) - { - string className = string.Empty, ns = string.Empty; - - SyntaxNode syntaxNode = invocationExpression; - while (syntaxNode.Parent is not null) - { - if (syntaxNode is ClassDeclarationSyntax classDeclarationSyntax) - className = classDeclarationSyntax.Identifier.Text; - - if (syntaxNode is NamespaceDeclarationSyntax namespaceDeclarationSyntax) - ns = namespaceDeclarationSyntax.Name.ToString(); - - if (syntaxNode is FileScopedNamespaceDeclarationSyntax fileScopedNamespaceDeclarationSyntax) - ns = fileScopedNamespaceDeclarationSyntax.Name.ToString(); - - syntaxNode = syntaxNode.Parent; - } - - return (ns, className); - } -} diff --git a/src/AutoLoggerMessageGenerator/Extractors/LocationContextExtractor.cs b/src/AutoLoggerMessageGenerator/Extractors/LocationContextExtractor.cs new file mode 100644 index 0000000..69df5cb --- /dev/null +++ b/src/AutoLoggerMessageGenerator/Extractors/LocationContextExtractor.cs @@ -0,0 +1,39 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace AutoLoggerMessageGenerator.Extractors; + +internal static class LocationContextExtractor +{ + public static LocationContext Extract(InvocationExpressionSyntax invocationExpression) + { + string? className = null, ns = null, methodName = null; + + SyntaxNode syntaxNode = invocationExpression; + while (syntaxNode.Parent is not null) + { + if (className is null && syntaxNode is ClassDeclarationSyntax classDeclarationSyntax) + className = classDeclarationSyntax.Identifier.Text; + + if (ns is null) + { + if (syntaxNode is NamespaceDeclarationSyntax namespaceDeclarationSyntax) + ns = namespaceDeclarationSyntax.Name.ToString(); + + if (syntaxNode is FileScopedNamespaceDeclarationSyntax fileScopedNamespaceDeclarationSyntax) + ns = fileScopedNamespaceDeclarationSyntax.Name.ToString(); + } + + if (methodName is null && syntaxNode is MethodDeclarationSyntax methodDeclarationSyntax) + methodName = methodDeclarationSyntax.Identifier.Text; + + syntaxNode = syntaxNode.Parent; + } + + return new LocationContext( + ns ?? string.Empty, className ?? string.Empty, methodName ?? string.Empty + ); + } + + public record LocationContext(string Namespace, string ClassName, string MethodName); +} diff --git a/src/AutoLoggerMessageGenerator/Extractors/LogCallExtractor.cs b/src/AutoLoggerMessageGenerator/Extractors/LogCallExtractor.cs index dcc631a..8a22087 100644 --- a/src/AutoLoggerMessageGenerator/Extractors/LogCallExtractor.cs +++ b/src/AutoLoggerMessageGenerator/Extractors/LogCallExtractor.cs @@ -12,7 +12,7 @@ internal static class LogCallExtractor InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel) { - var (ns, className) = EnclosingClassExtractor.Extract(invocationExpression); + var (ns, className, parentMethodName) = LocationContextExtractor.Extract(invocationExpression); var location = CallLocationMapper.Map(semanticModel, invocationExpression); if (location is null) @@ -33,6 +33,16 @@ internal static class LogCallExtractor if (parameters is null) return default; - return new LogMessageCall(Guid.NewGuid(), location.Value, ns, className, methodSymbol.Name, logLevel, message, parameters.Value); + return new LogMessageCall( + Guid.NewGuid(), + location.Value, + ns, + className, + parentMethodName, + methodSymbol.Name, + logLevel, + message, + parameters.Value + ); } } diff --git a/src/AutoLoggerMessageGenerator/Extractors/LoggerScopeCallExtractor.cs b/src/AutoLoggerMessageGenerator/Extractors/LoggerScopeCallExtractor.cs index 2ebcba4..9bd068a 100644 --- a/src/AutoLoggerMessageGenerator/Extractors/LoggerScopeCallExtractor.cs +++ b/src/AutoLoggerMessageGenerator/Extractors/LoggerScopeCallExtractor.cs @@ -12,7 +12,7 @@ internal static class LoggerScopeCallExtractor InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel) { - var (ns, className) = EnclosingClassExtractor.Extract(invocationExpression); + var (ns, className, parentMethodName) = LocationContextExtractor.Extract(invocationExpression); var location = CallLocationMapper.Map(semanticModel, invocationExpression); if (location is null) @@ -29,6 +29,6 @@ internal static class LoggerScopeCallExtractor if (parameters is null) return default; - return new LoggerScopeCall(location.Value, ns, className, methodSymbol.Name, message, parameters.Value); + return new LoggerScopeCall(location.Value, ns, className, parentMethodName, methodSymbol.Name, message, parameters.Value); } } diff --git a/src/AutoLoggerMessageGenerator/Models/LogMessageCall.cs b/src/AutoLoggerMessageGenerator/Models/LogMessageCall.cs index 3f9e065..2d1e094 100644 --- a/src/AutoLoggerMessageGenerator/Models/LogMessageCall.cs +++ b/src/AutoLoggerMessageGenerator/Models/LogMessageCall.cs @@ -10,6 +10,7 @@ internal readonly record struct LogMessageCall( string Namespace, string ClassName, string MethodName, + string LogMethodName, string LogLevel, string Message, ImmutableArray Parameters @@ -17,7 +18,7 @@ ImmutableArray Parameters { public string GeneratedMethodName => IdentifierHelper.ToValidCSharpMethodName( - $"{Constants.LogMethodPrefix}{Namespace}{ClassName}_{Location.Line}_{Location.Character}" + $"{Constants.LogMethodPrefix}{Namespace}_{ClassName}_{MethodName}_{Location.Line}_{Location.Character}" ); public bool Equals(LogMessageCall other) => @@ -25,11 +26,13 @@ public bool Equals(LogMessageCall other) => Namespace == other.Namespace && ClassName == other.ClassName && MethodName == other.MethodName && + LogMethodName == other.LogMethodName && LogLevel == other.LogLevel && Message == other.Message && Parameters.SequenceEqual(other.Parameters); public override int GetHashCode() => - (Location, Namespace, ClassName, MethodName, LogLevel, Message, Parameters).GetHashCode(); + (Location, Namespace, ClassName, MethodName, LogMethodName, LogLevel, Message, Parameters) + .GetHashCode(); }; diff --git a/src/AutoLoggerMessageGenerator/Models/LoggerScopeCall.cs b/src/AutoLoggerMessageGenerator/Models/LoggerScopeCall.cs index 135a12c..282d540 100644 --- a/src/AutoLoggerMessageGenerator/Models/LoggerScopeCall.cs +++ b/src/AutoLoggerMessageGenerator/Models/LoggerScopeCall.cs @@ -8,13 +8,14 @@ internal readonly record struct LoggerScopeCall( string Namespace, string ClassName, string MethodName, + string LogScopeMethodName, string Message, ImmutableArray Parameters ) { public string GeneratedMethodName => IdentifierHelper.ToValidCSharpMethodName( - $"{Constants.LogScopeMethodPrefix}{Namespace}{ClassName}_{Location.Line}_{Location.Character}" + $"{Constants.LogScopeMethodPrefix}{Namespace}_{ClassName}_{MethodName}_{Location.Line}_{Location.Character}" ); public bool Equals(LoggerScopeCall other) => @@ -22,9 +23,12 @@ public bool Equals(LoggerScopeCall other) => Namespace == other.Namespace && ClassName == other.ClassName && MethodName == other.MethodName && + LogScopeMethodName == other.LogScopeMethodName && Message == other.Message && Parameters.SequenceEqual(other.Parameters); - public override int GetHashCode() => (Location, Namespace, ClassName, MethodName, Message, Parameters).GetHashCode(); + public override int GetHashCode() => + (Location, Namespace, ClassName, MethodName, LogScopeMethodName, Message, Parameters) + .GetHashCode(); }; diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/BaseSourceGeneratorTest.cs b/tests/AutoLoggerMessageGenerator.UnitTests/BaseSourceGeneratorTest.cs index d285b32..e88c8ae 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/BaseSourceGeneratorTest.cs +++ b/tests/AutoLoggerMessageGenerator.UnitTests/BaseSourceGeneratorTest.cs @@ -10,6 +10,7 @@ internal abstract class BaseSourceGeneratorTest public const string LoggerName = "logger"; public const string Namespace = "Foo"; public const string ClassName = "Test"; + public const string Method = "Main"; protected static async Task<(CSharpCompilation Compilation, SyntaxTree SyntaxTree)> CompileSourceCode( string body, string additionalClassMemberDeclarations = "", @@ -25,7 +26,7 @@ public class {{ClassName}}(ILogger {{LoggerName}}) { {{additionalClassMemberDeclarations}} - public void Main() + public void {{Method}}() { {{body}} } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Caching/LogCallInputSourceComparerTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Caching/LogCallInputSourceComparerTests.cs index 07aa24a..2617545 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Caching/LogCallInputSourceComparerTests.cs +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Caching/LogCallInputSourceComparerTests.cs @@ -95,8 +95,16 @@ private static InputSource CreateInputSource(Compilation? compilation = default, references ??= [new Reference("some lib", new Version("1.2.3"))]; logCalls ??= [ - new LogMessageCall(Guid.NewGuid(), MockLogCallLocationBuilder.Build("some file", 1, 2), "namespace", "class", "name", - "information", "message", []) + new LogMessageCall( + Guid.NewGuid(), + MockLogCallLocationBuilder.Build("some file", 1, 2), + "namespace", + "class", + "method", + "name", + "information", + "message", + []) ]; return new InputSource(compilation, (configuration.Value, (references.Value, logCalls.Value))); diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_11.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_11.verified.txt index 0416127..03b6d5a 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_11.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_11.verified.txt @@ -12,21 +12,21 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage internal static class LoggerInterceptors { [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")] - public static void Log_namespace1class1_1_11(this ILogger @logger, string @message) + public static void Log_namespace1_class1_method1_1_11(this ILogger @logger, string @message) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1class1_1_11(@logger); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1_class1_method1_1_11(@logger); } [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")] - public static void Log_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam) + public static void Log_namespace2_class2_method2_2_22(this ILogger @logger, string @message, int @intParam) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2class2_2_22(@logger, @intParam); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2_class2_method2_2_22(@logger, @intParam); } [FakeInterceptableLocation(-1, "ZmlsZTMoMywzMyk=")] - public static void Log_namespace3class3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) + public static void Log_namespace3_class3_method3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_14.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_14.verified.txt index 54975f6..ef81308 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_14.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_14.verified.txt @@ -13,21 +13,21 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage internal static class LoggerInterceptors { [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")] - public static void Log_namespace1class1_1_11(this ILogger @logger, string @message) + public static void Log_namespace1_class1_method1_1_11(this ILogger @logger, string @message) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1class1_1_11(@logger); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1_class1_method1_1_11(@logger); } [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")] - public static void Log_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam) + public static void Log_namespace2_class2_method2_2_22(this ILogger @logger, string @message, int @intParam) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2class2_2_22(@logger, @intParam); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2_class2_method2_2_22(@logger, @intParam); } [FakeInterceptableLocation(-1, "ZmlsZTMoMywzMyk=")] - public static void Log_namespace3class3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) + public static void Log_namespace3_class3_method3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Rosyln_4_08.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Rosyln_4_08.verified.txt index 0416127..03b6d5a 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Rosyln_4_08.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Rosyln_4_08.verified.txt @@ -12,21 +12,21 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage internal static class LoggerInterceptors { [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")] - public static void Log_namespace1class1_1_11(this ILogger @logger, string @message) + public static void Log_namespace1_class1_method1_1_11(this ILogger @logger, string @message) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1class1_1_11(@logger); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1_class1_method1_1_11(@logger); } [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")] - public static void Log_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam) + public static void Log_namespace2_class2_method2_2_22(this ILogger @logger, string @message, int @intParam) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2class2_2_22(@logger, @intParam); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2_class2_method2_2_22(@logger, @intParam); } [FakeInterceptableLocation(-1, "ZmlsZTMoMywzMyk=")] - public static void Log_namespace3class3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) + public static void Log_namespace3_class3_method3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) { - Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs index 68bbab5..b85146e 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs @@ -19,7 +19,8 @@ public async Task Emit_ShouldGenerateValidLoggingExtensionsAttribute() Location: MockLogCallLocationBuilder.Build("file", 1, 11), Namespace: "namespace1", ClassName: "class1", - MethodName: "name1", + MethodName: "method1", + LogMethodName: "name1", LogLevel: "Information", Message: "Message1", Parameters: [new CallParameter("string", MessageParameterName, CallParameterType.Message)] @@ -29,7 +30,8 @@ public async Task Emit_ShouldGenerateValidLoggingExtensionsAttribute() Location: MockLogCallLocationBuilder.Build("file2", 2, 22), Namespace: "namespace2", ClassName: "class2", - MethodName: "name2", + MethodName: "method2", + LogMethodName: "name2", LogLevel: "Warning", Message: "Message2", Parameters: [ @@ -42,7 +44,8 @@ public async Task Emit_ShouldGenerateValidLoggingExtensionsAttribute() Location: MockLogCallLocationBuilder.Build("file3", 3, 33), Namespace: "namespace3", ClassName: "class3", - MethodName: "name3", + MethodName: "method3", + LogMethodName: "name3", LogLevel: "Error", Message: "Message3", Parameters: [ diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_11.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_11.verified.txt index 405a2af..399e94c 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_11.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_11.verified.txt @@ -12,21 +12,21 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage internal static class LoggerScopeInterceptors { [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")] - public static IDisposable? LogScope_namespace1class1_1_11(this ILogger @logger, string @message) + public static IDisposable? LogScope_namespace1_class1_method1_1_11(this ILogger @logger, string @message) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1class1_1_11(@logger); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1_class1_method1_1_11(@logger); } [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")] - public static IDisposable? LogScope_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam) + public static IDisposable? LogScope_namespace2_class2_method2_2_22(this ILogger @logger, string @message, int @intParam) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2class2_2_22(@logger, @intParam); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2_class2_method2_2_22(@logger, @intParam); } [FakeInterceptableLocation(-1, "ZmlsZTMoMywzMyk=")] - public static IDisposable? LogScope_namespace3class3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) + public static IDisposable? LogScope_namespace3_class3_method3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_14.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_14.verified.txt index 9f24b49..4c2d1ce 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_14.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_14.verified.txt @@ -13,21 +13,21 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage internal static class LoggerScopeInterceptors { [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")] - public static IDisposable? LogScope_namespace1class1_1_11(this ILogger @logger, string @message) + public static IDisposable? LogScope_namespace1_class1_method1_1_11(this ILogger @logger, string @message) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1class1_1_11(@logger); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1_class1_method1_1_11(@logger); } [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")] - public static IDisposable? LogScope_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam) + public static IDisposable? LogScope_namespace2_class2_method2_2_22(this ILogger @logger, string @message, int @intParam) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2class2_2_22(@logger, @intParam); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2_class2_method2_2_22(@logger, @intParam); } [FakeInterceptableLocation(-1, "ZmlsZTMoMywzMyk=")] - public static IDisposable? LogScope_namespace3class3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) + public static IDisposable? LogScope_namespace3_class3_method3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Rosyln_4_08.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Rosyln_4_08.verified.txt index 405a2af..399e94c 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Rosyln_4_08.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Rosyln_4_08.verified.txt @@ -12,21 +12,21 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage internal static class LoggerScopeInterceptors { [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")] - public static IDisposable? LogScope_namespace1class1_1_11(this ILogger @logger, string @message) + public static IDisposable? LogScope_namespace1_class1_method1_1_11(this ILogger @logger, string @message) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1class1_1_11(@logger); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1_class1_method1_1_11(@logger); } [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")] - public static IDisposable? LogScope_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam) + public static IDisposable? LogScope_namespace2_class2_method2_2_22(this ILogger @logger, string @message, int @intParam) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2class2_2_22(@logger, @intParam); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2_class2_method2_2_22(@logger, @intParam); } [FakeInterceptableLocation(-1, "ZmlsZTMoMywzMyk=")] - public static IDisposable? LogScope_namespace3class3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) + public static IDisposable? LogScope_namespace3_class3_method3_3_33(this ILogger @logger, string @message, int @intParam, bool @boolParam, SomeClass @objectParam) { - return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs index f1c7099..e734723 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs @@ -18,7 +18,8 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInte Location: MockLogCallLocationBuilder.Build("file", 1, 11), Namespace: "namespace1", ClassName: "class1", - MethodName: "name1", + MethodName: "method1", + LogScopeMethodName: "name1", Message: "Message1", Parameters: [new CallParameter("string", MessageParameterName, CallParameterType.Message)] ), @@ -26,7 +27,8 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInte Location: MockLogCallLocationBuilder.Build("file2", 2, 22), Namespace: "namespace2", ClassName: "class2", - MethodName: "name2", + MethodName: "method2", + LogScopeMethodName: "name2", Message: "Message2", Parameters: [ new CallParameter("string", MessageParameterName, CallParameterType.Message), @@ -37,7 +39,8 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInte Location: MockLogCallLocationBuilder.Build("file3", 3, 33), Namespace: "namespace3", ClassName: "class3", - MethodName: "name3", + MethodName: "method3", + LogScopeMethodName: "name3", Message: "Message3", Parameters: [ new CallParameter("string", MessageParameterName, CallParameterType.Message), diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_11.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_11.verified.txt index 0e1804d..84802a5 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_11.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_11.verified.txt @@ -9,22 +9,22 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)] internal static class LoggerScopes { - private static readonly Func _LogScope_namespace1class1_1_11 = LoggerMessage.DefineScope("Message1"); - public static IDisposable? LogScope_namespace1class1_1_11(ILogger @logger) + private static readonly Func _LogScope_namespace1_class1_method1_1_11 = LoggerMessage.DefineScope("Message1"); + public static IDisposable? LogScope_namespace1_class1_method1_1_11(ILogger @logger) { - return _LogScope_namespace1class1_1_11(@logger); + return _LogScope_namespace1_class1_method1_1_11(@logger); } - private static readonly Func _LogScope_namespace2class2_2_22 = LoggerMessage.DefineScope("Message2"); - public static IDisposable? LogScope_namespace2class2_2_22(ILogger @logger, int @intParam) + private static readonly Func _LogScope_namespace2_class2_method2_2_22 = LoggerMessage.DefineScope("Message2"); + public static IDisposable? LogScope_namespace2_class2_method2_2_22(ILogger @logger, int @intParam) { - return _LogScope_namespace2class2_2_22(@logger, @intParam); + return _LogScope_namespace2_class2_method2_2_22(@logger, @intParam); } - private static readonly Func _LogScope_namespace3class3_3_33 = LoggerMessage.DefineScope("Message3"); - public static IDisposable? LogScope_namespace3class3_3_33(ILogger @logger, int @intParam, bool @boolParam, SomeClass @objectParam) + private static readonly Func _LogScope_namespace3_class3_method3_3_33 = LoggerMessage.DefineScope("Message3"); + public static IDisposable? LogScope_namespace3_class3_method3_3_33(ILogger @logger, int @intParam, bool @boolParam, SomeClass @objectParam) { - return _LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + return _LogScope_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_14.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_14.verified.txt index f8bf99c..250ea07 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_14.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_14.verified.txt @@ -10,22 +10,22 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)] internal static class LoggerScopes { - private static readonly Func _LogScope_namespace1class1_1_11 = LoggerMessage.DefineScope("Message1"); - public static IDisposable? LogScope_namespace1class1_1_11(ILogger @logger) + private static readonly Func _LogScope_namespace1_class1_method1_1_11 = LoggerMessage.DefineScope("Message1"); + public static IDisposable? LogScope_namespace1_class1_method1_1_11(ILogger @logger) { - return _LogScope_namespace1class1_1_11(@logger); + return _LogScope_namespace1_class1_method1_1_11(@logger); } - private static readonly Func _LogScope_namespace2class2_2_22 = LoggerMessage.DefineScope("Message2"); - public static IDisposable? LogScope_namespace2class2_2_22(ILogger @logger, int @intParam) + private static readonly Func _LogScope_namespace2_class2_method2_2_22 = LoggerMessage.DefineScope("Message2"); + public static IDisposable? LogScope_namespace2_class2_method2_2_22(ILogger @logger, int @intParam) { - return _LogScope_namespace2class2_2_22(@logger, @intParam); + return _LogScope_namespace2_class2_method2_2_22(@logger, @intParam); } - private static readonly Func _LogScope_namespace3class3_3_33 = LoggerMessage.DefineScope("Message3"); - public static IDisposable? LogScope_namespace3class3_3_33(ILogger @logger, int @intParam, bool @boolParam, SomeClass @objectParam) + private static readonly Func _LogScope_namespace3_class3_method3_3_33 = LoggerMessage.DefineScope("Message3"); + public static IDisposable? LogScope_namespace3_class3_method3_3_33(ILogger @logger, int @intParam, bool @boolParam, SomeClass @objectParam) { - return _LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + return _LogScope_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Rosyln_4_08.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Rosyln_4_08.verified.txt index 0e1804d..84802a5 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Rosyln_4_08.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Rosyln_4_08.verified.txt @@ -9,22 +9,22 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)] internal static class LoggerScopes { - private static readonly Func _LogScope_namespace1class1_1_11 = LoggerMessage.DefineScope("Message1"); - public static IDisposable? LogScope_namespace1class1_1_11(ILogger @logger) + private static readonly Func _LogScope_namespace1_class1_method1_1_11 = LoggerMessage.DefineScope("Message1"); + public static IDisposable? LogScope_namespace1_class1_method1_1_11(ILogger @logger) { - return _LogScope_namespace1class1_1_11(@logger); + return _LogScope_namespace1_class1_method1_1_11(@logger); } - private static readonly Func _LogScope_namespace2class2_2_22 = LoggerMessage.DefineScope("Message2"); - public static IDisposable? LogScope_namespace2class2_2_22(ILogger @logger, int @intParam) + private static readonly Func _LogScope_namespace2_class2_method2_2_22 = LoggerMessage.DefineScope("Message2"); + public static IDisposable? LogScope_namespace2_class2_method2_2_22(ILogger @logger, int @intParam) { - return _LogScope_namespace2class2_2_22(@logger, @intParam); + return _LogScope_namespace2_class2_method2_2_22(@logger, @intParam); } - private static readonly Func _LogScope_namespace3class3_3_33 = LoggerMessage.DefineScope("Message3"); - public static IDisposable? LogScope_namespace3class3_3_33(ILogger @logger, int @intParam, bool @boolParam, SomeClass @objectParam) + private static readonly Func _LogScope_namespace3_class3_method3_3_33 = LoggerMessage.DefineScope("Message3"); + public static IDisposable? LogScope_namespace3_class3_method3_3_33(ILogger @logger, int @intParam, bool @boolParam, SomeClass @objectParam) { - return _LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam); + return _LogScope_namespace3_class3_method3_3_33(@logger, @intParam, @boolParam, @objectParam); } } diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs index 1654a33..6b32081 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs @@ -18,7 +18,8 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineSco Location: MockLogCallLocationBuilder.Build("file", 1, 11), Namespace: "namespace1", ClassName: "class1", - MethodName: "name1", + MethodName: "method1", + LogScopeMethodName: "name1", Message: "Message1", Parameters: [new CallParameter("string", MessageParameterName, CallParameterType.Message)] ), @@ -26,7 +27,8 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineSco Location: MockLogCallLocationBuilder.Build("file2", 2, 22), Namespace: "namespace2", ClassName: "class2", - MethodName: "name2", + MethodName: "method2", + LogScopeMethodName: "name2", Message: "Message2", Parameters: [ new CallParameter("string", MessageParameterName, CallParameterType.Message), @@ -37,7 +39,8 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineSco Location: MockLogCallLocationBuilder.Build("file3", 3, 33), Namespace: "namespace3", ClassName: "class3", - MethodName: "name3", + MethodName: "method3", + LogScopeMethodName: "name3", Message: "Message3", Parameters: [ new CallParameter("string", MessageParameterName, CallParameterType.Message), diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/EnclosingClassExtractorTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/EnclosingClassExtractorTests.cs deleted file mode 100644 index 946e4a5..0000000 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/EnclosingClassExtractorTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -using AutoLoggerMessageGenerator.Extractors; - -namespace AutoLoggerMessageGenerator.UnitTests.Extractors; - -internal class EnclosingClassExtractorTests : BaseSourceGeneratorTest -{ - [Test] - [Arguments(false, Namespace, ClassName)] - [Arguments(true, "", ClassName)] - public async Task Extract_WithLogCallAndGivenNamespace_ShouldReturnExpectedNamespaceAndClassName( - bool useGlobalNamespace, string expectedNamespace, string expectedClassName) - { - var message = $$"""{{LoggerName}}.LogInformation("Hello world");"""; - var (_, syntaxTree) = await CompileSourceCode(message, useGlobalNamespace: useGlobalNamespace); - var (invocationExpression, _, _) = FindMethodInvocation(null, syntaxTree); - - var (ns, className) = EnclosingClassExtractor.Extract(invocationExpression); - - await Assert.That(ns).IsEqualTo(expectedNamespace); - await Assert.That(className).IsEqualTo(expectedClassName); - } - - [Test] - public async Task Extract_WithNestedClasses_ShouldReturnOuterClassName() - { - const string additionalDeclaration = """ - class Outer - { - class Inner - { - private ILogger logger; - public void Log() => logger.LogInformation("Hello world"); - } - } - """; - var (_, syntaxTree) = await CompileSourceCode(string.Empty, additionalDeclaration); - var (invocationExpression, _, _) = FindMethodInvocation(null, syntaxTree); - - var (ns, className) = EnclosingClassExtractor.Extract(invocationExpression); - - await Assert.That(ns).IsEqualTo(Namespace); - await Assert.That(className).IsEqualTo(ClassName); - } -} diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LocationContextExtractorTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LocationContextExtractorTests.cs new file mode 100644 index 0000000..3da07e7 --- /dev/null +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LocationContextExtractorTests.cs @@ -0,0 +1,66 @@ +using AutoLoggerMessageGenerator.Extractors; + +namespace AutoLoggerMessageGenerator.UnitTests.Extractors; + +internal class LocationContextExtractorTests : BaseSourceGeneratorTest +{ + [Test] + [Arguments(false, Namespace, ClassName, Method)] + [Arguments(true, "", ClassName, Method)] + public async Task Extract_WithLogCallAndGivenNamespace_ShouldReturnExpectedNamespaceAndClassName( + bool useGlobalNamespace, string expectedNamespace, string expectedClassName, string expectedMethodName) + { + var message = $$"""{{LoggerName}}.LogInformation("Hello world");"""; + var (_, syntaxTree) = await CompileSourceCode(message, useGlobalNamespace: useGlobalNamespace); + var (invocationExpression, _, _) = FindMethodInvocation(null, syntaxTree); + + var (ns, className, methodName) = LocationContextExtractor.Extract(invocationExpression); + + await Assert.That(ns).IsEqualTo(expectedNamespace); + await Assert.That(className).IsEqualTo(expectedClassName); + await Assert.That(methodName).IsEqualTo(expectedMethodName); + } + + [Test] + public async Task Extract_WithNestedClasses_ShouldReturnInnerClassName() + { + const string additionalDeclaration = """ + class Outer + { + class Inner + { + private ILogger logger; + public void Log() => logger.LogInformation("Hello world"); + } + } + """; + var (_, syntaxTree) = await CompileSourceCode(string.Empty, additionalDeclaration); + var (invocationExpression, _, _) = FindMethodInvocation(null, syntaxTree); + + var (ns, className, methodName) = LocationContextExtractor.Extract(invocationExpression); + + await Assert.That(ns).IsEqualTo(Namespace); + await Assert.That(className).IsEqualTo("Inner"); + await Assert.That(methodName).IsEqualTo("Log"); + } + + [Test] + public async Task Extract_FromAnonymousFunction_ShouldReturnEmptyMethodName() + { + const string additionalDeclaration = """ + class Foo + { + private ILogger logger; + private Action Bar = () => logger.LogInformation("Hello world"); + } + """; + var (_, syntaxTree) = await CompileSourceCode(string.Empty, additionalDeclaration); + var (invocationExpression, _, _) = FindMethodInvocation(null, syntaxTree); + + var (ns, className, methodName) = LocationContextExtractor.Extract(invocationExpression); + + await Assert.That(ns).IsEqualTo(Namespace); + await Assert.That(className).IsEqualTo("Foo"); + await Assert.That(methodName).IsEqualTo(string.Empty); + } +} diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt index 84308d4..9ee8203 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt @@ -28,7 +28,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: LogInformation, + MethodName: Main, + LogMethodName: LogInformation, LogLevel: Information, Message: Hello world {arg1} {arg2}, Parameters: [ @@ -51,5 +52,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: Log_FooTest_12_16 + GeneratedMethodName: Log_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt index 935e87f..a08cdb9 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt @@ -28,7 +28,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: LogInformation, + MethodName: Main, + LogMethodName: LogInformation, LogLevel: Information, Message: Hello world {arg1} {arg2}, Parameters: [ @@ -51,5 +52,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: Log_FooTest_12_16 + GeneratedMethodName: Log_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt index 29c586b..c840c7d 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt @@ -28,7 +28,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: LogInformation, + MethodName: Main, + LogMethodName: LogInformation, LogLevel: Information, Message: Hello world {arg1} {arg2}, Parameters: [ @@ -51,5 +52,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: Log_FooTest_12_16 + GeneratedMethodName: Log_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt index 2b6a799..a41fb20 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt @@ -28,7 +28,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: LogInformation, + MethodName: Main, + LogMethodName: LogInformation, LogLevel: Information, Message: Hello world, Parameters: [ @@ -39,5 +40,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: Log_FooTest_12_16 + GeneratedMethodName: Log_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt index 9f1185a..f56f2fb 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt @@ -28,7 +28,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: LogInformation, + MethodName: Main, + LogMethodName: LogInformation, LogLevel: Information, Message: Hello world, Parameters: [ @@ -39,5 +40,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: Log_FooTest_12_16 + GeneratedMethodName: Log_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt index 3ff25d2..ce377b0 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt @@ -28,7 +28,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: LogInformation, + MethodName: Main, + LogMethodName: LogInformation, LogLevel: Information, Message: Hello world, Parameters: [ @@ -39,5 +40,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: Log_FooTest_12_16 + GeneratedMethodName: Log_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt index 21a4e8a..d37badb 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt @@ -27,7 +27,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: BeginScope, + MethodName: Main, + LogScopeMethodName: BeginScope, Message: Hello world {arg1} {arg2}, Parameters: [ { @@ -49,5 +50,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: LogScope_FooTest_12_16 + GeneratedMethodName: LogScope_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt index 8f9e224..7869c69 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt @@ -27,7 +27,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: BeginScope, + MethodName: Main, + LogScopeMethodName: BeginScope, Message: Hello world {arg1} {arg2}, Parameters: [ { @@ -49,5 +50,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: LogScope_FooTest_12_16 + GeneratedMethodName: LogScope_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt index 90b47fa..621dc34 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt @@ -27,7 +27,8 @@ }, Namespace: Foo, ClassName: Test, - MethodName: BeginScope, + MethodName: Main, + LogScopeMethodName: BeginScope, Message: Hello world {arg1} {arg2}, Parameters: [ { @@ -49,5 +50,5 @@ HasPropertiesToLog: false } ], - GeneratedMethodName: LogScope_FooTest_12_16 + GeneratedMethodName: LogScope_Foo_Test_Main_12_16 } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_disabled.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_disabled.verified.txt index 99df045..d1a8aec 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_disabled.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_disabled.verified.txt @@ -4,9 +4,9 @@ { // : Guid_1 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Critical, Message = "Hello, World!", SkipEnabledCheck = false)] - internal static partial void Log_SomeNamespaceSomeClass_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); // : Guid_2 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Trace, Message = "Goodbye, World!", SkipEnabledCheck = false)] - internal static partial void Log_SomeNamespaceSomeClass_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); } } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_enabled.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_enabled.verified.txt index 6ebd768..2f8afc0 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_enabled.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_all_enabled.verified.txt @@ -4,9 +4,9 @@ { // : Guid_1 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Critical, Message = "Hello, World!", SkipEnabledCheck = true)] - internal static partial void Log_SomeNamespaceSomeClass_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeStruct @structParam); // : Guid_2 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Trace, Message = "Goodbye, World!", SkipEnabledCheck = true)] - internal static partial void Log_SomeNamespaceSomeClass_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = true, SkipNullProperties = true, Transitive = true)] SomeStruct @structParam); } } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_only_telemetry_enabled.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_only_telemetry_enabled.verified.txt index 782cfdd..27c83a7 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_only_telemetry_enabled.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_only_telemetry_enabled.verified.txt @@ -4,9 +4,9 @@ { // : Guid_1 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Critical, Message = "Hello, World!", SkipEnabledCheck = false)] - internal static partial void Log_SomeNamespaceSomeClass_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeStruct @structParam); // : Guid_2 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Trace, Message = "Goodbye, World!", SkipEnabledCheck = false)] - internal static partial void Log_SomeNamespaceSomeClass_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeClass @classParam, [Microsoft.Extensions.Logging.LogPropertiesAttribute(OmitReferenceName = false, SkipNullProperties = false)] SomeStruct @structParam); } } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_telemetry_disabled.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_telemetry_disabled.verified.txt index 9d3f72e..00ba7d1 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_telemetry_disabled.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithDifferentConfiguration_ShouldReturnLegitLoggerMessageDeclaration_telemetry_disabled.verified.txt @@ -4,9 +4,9 @@ { // : Guid_1 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Critical, Message = "Hello, World!", SkipEnabledCheck = true)] - internal static partial void Log_SomeNamespaceSomeClass_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_2_22(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); // : Guid_2 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Trace, Message = "Goodbye, World!", SkipEnabledCheck = true)] - internal static partial void Log_SomeNamespaceSomeClass_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); } } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithEscapeSequences_ShouldBuildAsItIs.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithEscapeSequences_ShouldBuildAsItIs.verified.txt index 8a13548..6b01c74 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithEscapeSequences_ShouldBuildAsItIs.verified.txt +++ b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.Build_WithEscapeSequences_ShouldBuildAsItIs.verified.txt @@ -4,6 +4,6 @@ { // : Guid_1 [Microsoft.Extensions.Logging.LoggerMessageAttribute(Level = Microsoft.Extensions.Logging.LogLevel.Trace, Message = "All characters should be passed as a string literal expression: \n\r\t", SkipEnabledCheck = false)] - internal static partial void Log_SomeNamespaceSomeClass_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); + internal static partial void Log_SomeNamespace_SomeClass_Method_3_33(Microsoft.Extensions.Logging.ILogger Logger, int @intParam, string @stringParam, bool @boolParam, SomeClass @classParam, SomeStruct @structParam); } } \ No newline at end of file diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.cs index f8f16c3..20dd4df 100644 --- a/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.cs +++ b/tests/AutoLoggerMessageGenerator.UnitTests/VirtualLoggerMessage/VirtualLoggerMessageClassBuilderTests.cs @@ -17,7 +17,8 @@ internal class VirtualLoggerMessageClassBuilderTests Character = 22 }, Message = "Hello, World!", - MethodName = "LogCall", + MethodName = "Method", + LogMethodName = "LogCall", Namespace = "SomeNamespace", ClassName = "SomeClass", LogLevel = "Critical",