diff --git a/AutoLoggerMessage.slnx b/AutoLoggerMessage.slnx
index c5114f8..3732b09 100644
--- a/AutoLoggerMessage.slnx
+++ b/AutoLoggerMessage.slnx
@@ -7,11 +7,13 @@
+
+
diff --git a/src/AutoLoggerMessageGenerator.BuildOutput/AutoLoggerMessageGenerator.BuildOutput.csproj b/src/AutoLoggerMessageGenerator.BuildOutput/AutoLoggerMessageGenerator.BuildOutput.csproj
index 42b7307..9af4586 100644
--- a/src/AutoLoggerMessageGenerator.BuildOutput/AutoLoggerMessageGenerator.BuildOutput.csproj
+++ b/src/AutoLoggerMessageGenerator.BuildOutput/AutoLoggerMessageGenerator.BuildOutput.csproj
@@ -4,6 +4,10 @@
netstandard2.0
+
+ $(DefineConstants);JETBRAINS_ANNOTATIONS
+
+
diff --git a/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Build.targets b/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Build.targets
index 8fb2115..c60a779 100644
--- a/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Build.targets
+++ b/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Build.targets
@@ -54,6 +54,9 @@
<_Parameter1>$(AssemblyName).UnitTests.Roslyn4_11
+
+ <_Parameter1>$(AssemblyName).UnitTests.Roslyn4_14
+
<_Parameter1>$(AssemblyName).IntegrationTests
diff --git a/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Pack.csproj b/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Pack.csproj
index e7f1830..017a349 100644
--- a/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Pack.csproj
+++ b/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Pack.csproj
@@ -7,9 +7,14 @@
+
+ $(DefineConstants);JETBRAINS_ANNOTATIONS
+
+
-
+
+
@@ -18,6 +23,8 @@
Pack="true" PackagePath="analyzers/dotnet/roslyn4.8/cs" Visible="false" />
+
diff --git a/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Roslyn4_14.csproj b/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Roslyn4_14.csproj
new file mode 100644
index 0000000..4a33bdb
--- /dev/null
+++ b/src/AutoLoggerMessageGenerator/AutoLoggerMessageGenerator.Roslyn4_14.csproj
@@ -0,0 +1,20 @@
+
+
+
+ netstandard2.0
+ 4.14.0
+ $(DefineConstants);HASH_BASED_INTERCEPTORS;EMBEDDED
+ false
+
+
+
+
+ AutoLoggerMessageGenerator.cs
+
+
+ AutoLoggerMessageGenerator.cs
+
+
+
+
+
diff --git a/src/AutoLoggerMessageGenerator/Constants.cs b/src/AutoLoggerMessageGenerator/Constants.cs
index c83c556..a3f4b7b 100644
--- a/src/AutoLoggerMessageGenerator/Constants.cs
+++ b/src/AutoLoggerMessageGenerator/Constants.cs
@@ -49,6 +49,8 @@ internal static class Constants
$"[global::System.CodeDom.Compiler.GeneratedCodeAttribute(" +
$"\"{typeof(Generators.AutoLoggerMessageGenerator).Assembly.GetName().Name}\", " +
$"\"{typeof(Generators.AutoLoggerMessageGenerator).Assembly.GetName().Version}\")]";
+
+ public const string EmbeddedAttribute = "[global::Microsoft.CodeAnalysis.EmbeddedAttribute]";
public const string EditorNotBrowsableAttribute = "[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]";
public const string GeneratedFileHeader = """
diff --git a/src/AutoLoggerMessageGenerator/Emitters/InterceptorAttributeEmitter.cs b/src/AutoLoggerMessageGenerator/Emitters/InterceptorAttributeEmitter.cs
index 22dfe5b..c556b42 100644
--- a/src/AutoLoggerMessageGenerator/Emitters/InterceptorAttributeEmitter.cs
+++ b/src/AutoLoggerMessageGenerator/Emitters/InterceptorAttributeEmitter.cs
@@ -15,6 +15,10 @@ public static string Emit()
sb.WriteLine('{');
sb.Indent++;
+ #if EMBEDDED
+ sb.WriteLine(Constants.EmbeddedAttribute);
+ #endif
+
sb.WriteLine(Constants.GeneratedCodeAttribute);
sb.WriteLine(Constants.EditorNotBrowsableAttribute);
sb.WriteLine("[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]");
diff --git a/src/AutoLoggerMessageGenerator/Emitters/LoggerInterceptorsEmitter.cs b/src/AutoLoggerMessageGenerator/Emitters/LoggerInterceptorsEmitter.cs
index a851944..1641ea4 100644
--- a/src/AutoLoggerMessageGenerator/Emitters/LoggerInterceptorsEmitter.cs
+++ b/src/AutoLoggerMessageGenerator/Emitters/LoggerInterceptorsEmitter.cs
@@ -16,6 +16,10 @@ public static string Emit(IEnumerable logCalls)
sb.WriteLine('{');
sb.Indent++;
+ #if EMBEDDED
+ sb.WriteLine(Constants.EmbeddedAttribute);
+ #endif
+
sb.WriteLine(Constants.GeneratedCodeAttribute);
sb.WriteLine(Constants.EditorNotBrowsableAttribute);
sb.WriteLine(Constants.ExcludeFromCoverageAttribute);
diff --git a/src/AutoLoggerMessageGenerator/Emitters/LoggerScopeInterceptorsEmitter.cs b/src/AutoLoggerMessageGenerator/Emitters/LoggerScopeInterceptorsEmitter.cs
index 9707721..6601ffb 100644
--- a/src/AutoLoggerMessageGenerator/Emitters/LoggerScopeInterceptorsEmitter.cs
+++ b/src/AutoLoggerMessageGenerator/Emitters/LoggerScopeInterceptorsEmitter.cs
@@ -16,6 +16,10 @@ public static string Emit(IEnumerable loggerScopes)
sb.WriteLine('{');
sb.Indent++;
+ #if EMBEDDED
+ sb.WriteLine(Constants.EmbeddedAttribute);
+ #endif
+
sb.WriteLine(Constants.GeneratedCodeAttribute);
sb.WriteLine(Constants.EditorNotBrowsableAttribute);
sb.WriteLine(Constants.ExcludeFromCoverageAttribute);
diff --git a/src/AutoLoggerMessageGenerator/Emitters/LoggerScopesEmitter.cs b/src/AutoLoggerMessageGenerator/Emitters/LoggerScopesEmitter.cs
index a5b09b5..c44f0a2 100644
--- a/src/AutoLoggerMessageGenerator/Emitters/LoggerScopesEmitter.cs
+++ b/src/AutoLoggerMessageGenerator/Emitters/LoggerScopesEmitter.cs
@@ -18,9 +18,13 @@ public static string Emit(ImmutableArray loggerScopes)
sb.WriteLine('{');
sb.Indent++;
+ #if EMBEDDED
+ sb.WriteLine(EmbeddedAttribute);
+ #endif
+
sb.WriteLine(Constants.GeneratedCodeAttribute);
sb.WriteLine(EditorNotBrowsableAttribute);
- sb.WriteLine($"public static class {LoggerScopesGeneratorName}");
+ sb.WriteLine($"internal static class {LoggerScopesGeneratorName}");
sb.WriteLine('{');
sb.Indent++;
diff --git a/src/AutoLoggerMessageGenerator/Generators/AutoLoggerMessageGenerator.cs b/src/AutoLoggerMessageGenerator/Generators/AutoLoggerMessageGenerator.cs
index 3feb67f..1a4b470 100644
--- a/src/AutoLoggerMessageGenerator/Generators/AutoLoggerMessageGenerator.cs
+++ b/src/AutoLoggerMessageGenerator/Generators/AutoLoggerMessageGenerator.cs
@@ -24,9 +24,17 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
GenerateInterceptorAttribute(context, configuration);
}
- private static void GenerateInterceptorAttribute(IncrementalGeneratorInitializationContext context,
+ private static void GenerateInterceptorAttribute(
+ IncrementalGeneratorInitializationContext context,
IncrementalValueProvider configuration)
{
+ #if EMBEDDED
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ ctx.AddEmbeddedAttributeDefinition();
+ });
+ #endif
+
context.RegisterImplementationSourceOutput(configuration, static (ctx, configuration) =>
{
if (configuration.GenerateInterceptorAttribute)
diff --git a/src/AutoLoggerMessageGenerator/Import/Microsoft.Extensions.Telemetry.LoggerMessage/Shared/GeneratorUtilities.cs b/src/AutoLoggerMessageGenerator/Import/Microsoft.Extensions.Telemetry.LoggerMessage/Shared/GeneratorUtilities.cs
index b6a46de..b653907 100644
--- a/src/AutoLoggerMessageGenerator/Import/Microsoft.Extensions.Telemetry.LoggerMessage/Shared/GeneratorUtilities.cs
+++ b/src/AutoLoggerMessageGenerator/Import/Microsoft.Extensions.Telemetry.LoggerMessage/Shared/GeneratorUtilities.cs
@@ -135,12 +135,16 @@ static string GetAttributeDisplayName(INamedTypeSymbol attributeType)
/// 2.
/// Reading MSBuild Properties in Source Generators.
///
+#pragma warning disable RS1035
/// .
+#pragma warning restore RS1035
/// The name of the MSBuild property that determines whether to produce a report.
/// bool value to indicate if reports should be generated.
public static bool ShouldGenerateReport(GeneratorExecutionContext context, string msBuildProperty)
{
+#pragma warning disable RS1035
_ = context.AnalyzerConfigOptions.GlobalOptions.TryGetValue(msBuildProperty, out var generateFiles);
+#pragma warning restore RS1035
return string.Equals(generateFiles, bool.TrueString, StringComparison.OrdinalIgnoreCase);
}
diff --git a/src/AutoLoggerMessageGenerator/PostProcessing/LoggerMessageResultAdjuster.cs b/src/AutoLoggerMessageGenerator/PostProcessing/LoggerMessageResultAdjuster.cs
index 00964a7..ee6ffb9 100644
--- a/src/AutoLoggerMessageGenerator/PostProcessing/LoggerMessageResultAdjuster.cs
+++ b/src/AutoLoggerMessageGenerator/PostProcessing/LoggerMessageResultAdjuster.cs
@@ -1,10 +1,23 @@
+using System.Text;
+
namespace AutoLoggerMessageGenerator.PostProcessing;
internal static class LoggerMessageResultAdjuster
{
- public static string? Adjust(string? generatedCode) =>
- generatedCode?.Replace(
- $"static partial void {Constants.LogMethodPrefix}",
+ public static string? Adjust(string? generatedCode)
+ {
+ var builder = new StringBuilder(generatedCode).Replace(
+ $"static partial void {Constants.LogMethodPrefix}",
$"static void {Constants.LogMethodPrefix}"
);
+
+ #if EMBEDDED
+ builder = builder.Replace(
+ $"partial class {Constants.LoggerClassName}",
+ $"{Constants.EmbeddedAttribute} partial class {Constants.LoggerClassName}"
+ );
+ #endif
+
+ return builder.ToString();
+ }
}
diff --git a/tests/.editorconfig b/tests/.editorconfig
new file mode 100644
index 0000000..819627a
--- /dev/null
+++ b/tests/.editorconfig
@@ -0,0 +1,8 @@
+[*.{received,verified}.{json,txt,xml}]
+charset = utf-8-bom
+end_of_line = lf
+indent_size = unset
+indent_style = unset
+insert_final_newline = false
+tab_width = unset
+trim_trailing_whitespace = false
diff --git a/tests/AutoLoggerMessageGenerator.IntegrationTests/AutoLoggerMessageGenerator.IntegrationTests.csproj b/tests/AutoLoggerMessageGenerator.IntegrationTests/AutoLoggerMessageGenerator.IntegrationTests.csproj
index 302de68..45f303d 100644
--- a/tests/AutoLoggerMessageGenerator.IntegrationTests/AutoLoggerMessageGenerator.IntegrationTests.csproj
+++ b/tests/AutoLoggerMessageGenerator.IntegrationTests/AutoLoggerMessageGenerator.IntegrationTests.csproj
@@ -1,26 +1,25 @@
- net8.0
+ net8.0;net9.0
false
+
+ 4_8
+
+
+
+ 4_11
+
+
- true
+ 4_14
-
-
-
-
-
-
-
-
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Build.targets b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Build.targets
index 8d9e28b..075b200 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Build.targets
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Build.targets
@@ -5,11 +5,11 @@
-
+
-
-
+
+
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_11.csproj b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_11.csproj
index a7b3310..d257116 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_11.csproj
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_11.csproj
@@ -2,7 +2,7 @@
4.11.0
- $(DefineConstants);HASH_BASED_INTERCEPTORS
+ $(DefineConstants);HASH_BASED_INTERCEPTORS;Roslyn411
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_14.csproj b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_14.csproj
new file mode 100644
index 0000000..6191364
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_14.csproj
@@ -0,0 +1,15 @@
+
+
+
+
+ net9.0
+ enable
+ 4.14.0
+ $(DefineConstants);HASH_BASED_INTERCEPTORS;EMBEDDED;Roslyn414
+
+
+
+
+
+
+
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_8.csproj b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_8.csproj
index bb6384a..77cd694 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_8.csproj
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/AutoLoggerMessageGenerator.UnitTests.Roslyn4_8.csproj
@@ -2,7 +2,7 @@
4.8.0
- $(DefineConstants);PATH_BASED_INTERCEPTORS
+ $(DefineConstants);PATH_BASED_INTERCEPTORS;Roslyn408
@@ -11,4 +11,5 @@
+
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_HashBasedInterceptor.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_HashBasedInterceptor_Roslyn_4_11.verified.txt
similarity index 100%
rename from tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_HashBasedInterceptor.verified.txt
rename to tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_HashBasedInterceptor_Roslyn_4_11.verified.txt
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_HashBasedInterceptor_Roslyn_4_14.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_HashBasedInterceptor_Roslyn_4_14.verified.txt
new file mode 100644
index 0000000..1b8f419
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_HashBasedInterceptor_Roslyn_4_14.verified.txt
@@ -0,0 +1,16 @@
+//
+#nullable enable
+
+using System;
+
+namespace System.Runtime.CompilerServices
+{
+ [global::Microsoft.CodeAnalysis.EmbeddedAttribute]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+ internal sealed class InterceptsLocationAttribute : Attribute
+ {
+ public InterceptsLocationAttribute(int version, string data) {}
+ }
+}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_PathBasedInterceptor_Rosyln_4_08.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_PathBasedInterceptor_Rosyln_4_08.verified.txt
new file mode 100644
index 0000000..f5797ec
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.Emit_ShouldGenerateValidInterceptorAttribute_PathBasedInterceptor_Rosyln_4_08.verified.txt
@@ -0,0 +1,15 @@
+//
+#nullable enable
+
+using System;
+
+namespace System.Runtime.CompilerServices
+{
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+ internal sealed class InterceptsLocationAttribute : Attribute
+ {
+ public InterceptsLocationAttribute(string filePath, int line, int character) {}
+ }
+}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.cs
index c524038..b55b797 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.cs
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/InterceptorAttributeEmitterTests.cs
@@ -11,9 +11,10 @@ public async Task Emit_ShouldGenerateValidInterceptorAttribute()
{
var sourceCode = InterceptorAttributeEmitter.Emit();
var configuration = InterceptorConfigurationUtilities.GetInterceptorConfiguration();
+ var roslynVersion = RoslynConfigurationUtilities.GetRoslynVersion();
await Verify(sourceCode)
- .UseTextForParameters(configuration)
+ .UseTextForParameters($"{configuration}_{roslynVersion}")
.AddCodeGeneratedAttributeScrubber();
}
}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_11.verified.txt
similarity index 98%
rename from tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute.verified.txt
rename to tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_11.verified.txt
index f0f3065..0416127 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute.verified.txt
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_11.verified.txt
@@ -1,4 +1,4 @@
-//
+//
#nullable enable
using System;
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
new file mode 100644
index 0000000..54975f6
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Roslyn_4_14.verified.txt
@@ -0,0 +1,34 @@
+//
+#nullable enable
+
+using System;
+
+namespace Microsoft.Extensions.Logging.AutoLoggerMessage
+{
+ [global::Microsoft.CodeAnalysis.EmbeddedAttribute]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [System.Diagnostics.DebuggerStepThrough]
+ internal static class LoggerInterceptors
+ {
+ [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")]
+ public static void Log_namespace1class1_1_11(this ILogger @logger, string @message)
+ {
+ Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1class1_1_11(@logger);
+ }
+
+ [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")]
+ public static void Log_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam)
+ {
+ Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2class2_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)
+ {
+ Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3class3_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
new file mode 100644
index 0000000..0416127
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.Emit_ShouldGenerateValidLoggingExtensionsAttribute_Rosyln_4_08.verified.txt
@@ -0,0 +1,33 @@
+//
+#nullable enable
+
+using System;
+
+namespace Microsoft.Extensions.Logging.AutoLoggerMessage
+{
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [System.Diagnostics.DebuggerStepThrough]
+ internal static class LoggerInterceptors
+ {
+ [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")]
+ public static void Log_namespace1class1_1_11(this ILogger @logger, string @message)
+ {
+ Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace1class1_1_11(@logger);
+ }
+
+ [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")]
+ public static void Log_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam)
+ {
+ Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace2class2_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)
+ {
+ Microsoft.Extensions.Logging.AutoLoggerMessage.AutoLoggerMessage.Log_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam);
+ }
+
+ }
+}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs
index c0aee98..68bbab5 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerInterceptorsEmitterTests.cs
@@ -2,6 +2,7 @@
using AutoLoggerMessageGenerator.Emitters;
using AutoLoggerMessageGenerator.Models;
using AutoLoggerMessageGenerator.UnitTests.Scrubbers;
+using AutoLoggerMessageGenerator.UnitTests.Utilities;
using static AutoLoggerMessageGenerator.Constants;
namespace AutoLoggerMessageGenerator.UnitTests.Emitters;
@@ -54,6 +55,7 @@ public async Task Emit_ShouldGenerateValidLoggingExtensionsAttribute()
];
var sourceCode = LoggerInterceptorsEmitter.Emit(logCalls);
- await Verify(sourceCode).AddCodeGeneratedAttributeScrubber();
+ await Verify(sourceCode).AddCodeGeneratedAttributeScrubber()
+ .UseTextForParameters(RoslynConfigurationUtilities.GetRoslynVersion());
}
}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_11.verified.txt
similarity index 100%
rename from tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors.verified.txt
rename to tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_11.verified.txt
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
new file mode 100644
index 0000000..9f24b49
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Roslyn_4_14.verified.txt
@@ -0,0 +1,34 @@
+//
+#nullable enable
+
+using System;
+
+namespace Microsoft.Extensions.Logging.AutoLoggerMessage
+{
+ [global::Microsoft.CodeAnalysis.EmbeddedAttribute]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [System.Diagnostics.DebuggerStepThrough]
+ internal static class LoggerScopeInterceptors
+ {
+ [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")]
+ public static IDisposable? LogScope_namespace1class1_1_11(this ILogger @logger, string @message)
+ {
+ return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1class1_1_11(@logger);
+ }
+
+ [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")]
+ public static IDisposable? LogScope_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam)
+ {
+ return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2class2_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)
+ {
+ return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3class3_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
new file mode 100644
index 0000000..405a2af
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInterceptors_Rosyln_4_08.verified.txt
@@ -0,0 +1,33 @@
+//
+#nullable enable
+
+using System;
+
+namespace Microsoft.Extensions.Logging.AutoLoggerMessage
+{
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [System.Diagnostics.DebuggerStepThrough]
+ internal static class LoggerScopeInterceptors
+ {
+ [FakeInterceptableLocation(-1, "ZmlsZSgxLDExKQ==")]
+ public static IDisposable? LogScope_namespace1class1_1_11(this ILogger @logger, string @message)
+ {
+ return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace1class1_1_11(@logger);
+ }
+
+ [FakeInterceptableLocation(-1, "ZmlsZTIoMiwyMik=")]
+ public static IDisposable? LogScope_namespace2class2_2_22(this ILogger @logger, string @message, int @intParam)
+ {
+ return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace2class2_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)
+ {
+ return Microsoft.Extensions.Logging.AutoLoggerMessage.LoggerScopes.LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam);
+ }
+
+ }
+}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs
index 3c7ed98..f1c7099 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopeInterceptorsEmitterTests.cs
@@ -2,6 +2,7 @@
using AutoLoggerMessageGenerator.Emitters;
using AutoLoggerMessageGenerator.Models;
using AutoLoggerMessageGenerator.UnitTests.Scrubbers;
+using AutoLoggerMessageGenerator.UnitTests.Utilities;
using static AutoLoggerMessageGenerator.Constants;
namespace AutoLoggerMessageGenerator.UnitTests.Emitters;
@@ -48,6 +49,7 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerScopeInte
];
var sourceCode = LoggerScopeInterceptorsEmitter.Emit(loggerScopes);
- await Verify(sourceCode).AddCodeGeneratedAttributeScrubber();
+ await Verify(sourceCode).AddCodeGeneratedAttributeScrubber()
+ .UseTextForParameters(RoslynConfigurationUtilities.GetRoslynVersion());
}
}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_11.verified.txt
similarity index 97%
rename from tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors.verified.txt
rename to tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_11.verified.txt
index 6da4792..0e1804d 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors.verified.txt
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_11.verified.txt
@@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging.AutoLoggerMessage
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
- public static class LoggerScopes
+ internal static class LoggerScopes
{
private static readonly Func _LogScope_namespace1class1_1_11 = LoggerMessage.DefineScope("Message1");
public static IDisposable? LogScope_namespace1class1_1_11(ILogger @logger)
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
new file mode 100644
index 0000000..f8bf99c
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Roslyn_4_14.verified.txt
@@ -0,0 +1,32 @@
+//
+#nullable enable
+
+using System;
+
+namespace Microsoft.Extensions.Logging.AutoLoggerMessage
+{
+ [global::Microsoft.CodeAnalysis.EmbeddedAttribute]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [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)
+ {
+ return _LogScope_namespace1class1_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)
+ {
+ return _LogScope_namespace2class2_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)
+ {
+ return _LogScope_namespace3class3_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
new file mode 100644
index 0000000..0e1804d
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineScopedFunctors_Rosyln_4_08.verified.txt
@@ -0,0 +1,31 @@
+//
+#nullable enable
+
+using System;
+
+namespace Microsoft.Extensions.Logging.AutoLoggerMessage
+{
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("AutoLoggerMessageGenerator", "1.2.3.4")]
+ [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)
+ {
+ return _LogScope_namespace1class1_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)
+ {
+ return _LogScope_namespace2class2_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)
+ {
+ return _LogScope_namespace3class3_3_33(@logger, @intParam, @boolParam, @objectParam);
+ }
+
+ }
+}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs
index 1680793..1654a33 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Emitters/LoggerScopesEmitterTests.cs
@@ -2,6 +2,7 @@
using AutoLoggerMessageGenerator.Emitters;
using AutoLoggerMessageGenerator.Models;
using AutoLoggerMessageGenerator.UnitTests.Scrubbers;
+using AutoLoggerMessageGenerator.UnitTests.Utilities;
using static AutoLoggerMessageGenerator.Constants;
namespace AutoLoggerMessageGenerator.UnitTests.Emitters;
@@ -48,6 +49,7 @@ public async Task Emit_WithGivenConfiguration_ShouldGenerateValidLoggerDefineSco
];
var sourceCode = LoggerScopesEmitter.Emit(loggerScopes);
- await Verify(sourceCode).AddCodeGeneratedAttributeScrubber();
+ await Verify(sourceCode).AddCodeGeneratedAttributeScrubber()
+ .UseTextForParameters(RoslynConfigurationUtilities.GetRoslynVersion());
}
}
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt
similarity index 100%
rename from tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor.verified.txt
rename to tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt
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
new file mode 100644
index 0000000..935e87f
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt
@@ -0,0 +1,55 @@
+{
+ Id: Guid_1,
+ Location: {
+ FilePath: path/testFile.cs,
+ Line: 12,
+ Character: 16,
+ InterceptableLocationSyntax: [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(1, "bg8SAsBDKqh7V1TqOZu8tZkAAAB0ZXN0RmlsZS5jcw==")],
+ Context: {
+ Kind: SourceFile,
+ SourceSpan: {
+ Start: 146,
+ Length: 59
+ },
+ SourceTree: {
+ FilePath: path/testFile.cs,
+ Length: 214,
+ HasCompilationUnitRoot: true,
+ Options: {
+ LanguageVersion: CSharp13,
+ Language: C#,
+ DocumentationMode: Parse,
+ Errors: null
+ }
+ },
+ IsInSource: true,
+ IsInMetadata: false
+ }
+ },
+ Namespace: Foo,
+ ClassName: Test,
+ MethodName: LogInformation,
+ LogLevel: Information,
+ Message: Hello world {arg1} {arg2},
+ Parameters: [
+ {
+ NativeType: global::System.String,
+ Name: @message,
+ Type: Message,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Int32,
+ Name: @arg1,
+ Type: Others,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Boolean,
+ Name: @arg2,
+ Type: Others,
+ HasPropertiesToLog: false
+ }
+ ],
+ GeneratedMethodName: Log_FooTest_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
new file mode 100644
index 0000000..29c586b
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt
@@ -0,0 +1,55 @@
+{
+ Id: Guid_1,
+ Location: {
+ FilePath: path/testFile.cs,
+ Line: 12,
+ Character: 16,
+ InterceptableLocationSyntax: [System.Runtime.CompilerServices.InterceptsLocationAttribute(filePath: @"path/testFile.cs", line: 12, character: 16)],
+ Context: {
+ Kind: SourceFile,
+ SourceSpan: {
+ Start: 146,
+ Length: 59
+ },
+ SourceTree: {
+ FilePath: path/testFile.cs,
+ Length: 214,
+ HasCompilationUnitRoot: true,
+ Options: {
+ LanguageVersion: CSharp12,
+ Language: C#,
+ DocumentationMode: Parse,
+ Errors: null
+ }
+ },
+ IsInSource: true,
+ IsInMetadata: false
+ }
+ },
+ Namespace: Foo,
+ ClassName: Test,
+ MethodName: LogInformation,
+ LogLevel: Information,
+ Message: Hello world {arg1} {arg2},
+ Parameters: [
+ {
+ NativeType: global::System.String,
+ Name: @message,
+ Type: Message,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Int32,
+ Name: @arg1,
+ Type: Others,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Boolean,
+ Name: @arg2,
+ Type: Others,
+ HasPropertiesToLog: false
+ }
+ ],
+ GeneratedMethodName: Log_FooTest_12_16
+}
\ No newline at end of file
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt
similarity index 100%
rename from tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor.verified.txt
rename to tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt
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
new file mode 100644
index 0000000..9f1185a
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt
@@ -0,0 +1,43 @@
+{
+ Id: Guid_1,
+ Location: {
+ FilePath: path/testFile.cs,
+ Line: 12,
+ Character: 16,
+ InterceptableLocationSyntax: [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(1, "VSNN9b1ciRV2FhFsas3dUJkAAAB0ZXN0RmlsZS5jcw==")],
+ Context: {
+ Kind: SourceFile,
+ SourceSpan: {
+ Start: 146,
+ Length: 36
+ },
+ SourceTree: {
+ FilePath: path/testFile.cs,
+ Length: 191,
+ HasCompilationUnitRoot: true,
+ Options: {
+ LanguageVersion: CSharp13,
+ Language: C#,
+ DocumentationMode: Parse,
+ Errors: null
+ }
+ },
+ IsInSource: true,
+ IsInMetadata: false
+ }
+ },
+ Namespace: Foo,
+ ClassName: Test,
+ MethodName: LogInformation,
+ LogLevel: Information,
+ Message: Hello world,
+ Parameters: [
+ {
+ NativeType: global::System.String,
+ Name: @message,
+ Type: Message,
+ HasPropertiesToLog: false
+ }
+ ],
+ GeneratedMethodName: Log_FooTest_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
new file mode 100644
index 0000000..3ff25d2
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLogCallObject_description=without parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt
@@ -0,0 +1,43 @@
+{
+ Id: Guid_1,
+ Location: {
+ FilePath: path/testFile.cs,
+ Line: 12,
+ Character: 16,
+ InterceptableLocationSyntax: [System.Runtime.CompilerServices.InterceptsLocationAttribute(filePath: @"path/testFile.cs", line: 12, character: 16)],
+ Context: {
+ Kind: SourceFile,
+ SourceSpan: {
+ Start: 146,
+ Length: 36
+ },
+ SourceTree: {
+ FilePath: path/testFile.cs,
+ Length: 191,
+ HasCompilationUnitRoot: true,
+ Options: {
+ LanguageVersion: CSharp12,
+ Language: C#,
+ DocumentationMode: Parse,
+ Errors: null
+ }
+ },
+ IsInSource: true,
+ IsInMetadata: false
+ }
+ },
+ Namespace: Foo,
+ ClassName: Test,
+ MethodName: LogInformation,
+ LogLevel: Information,
+ Message: Hello world,
+ Parameters: [
+ {
+ NativeType: global::System.String,
+ Name: @message,
+ Type: Message,
+ HasPropertiesToLog: false
+ }
+ ],
+ GeneratedMethodName: Log_FooTest_12_16
+}
\ No newline at end of file
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.cs
index 010fedb..5742ca4 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.cs
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LogCallExtractorTests.cs
@@ -20,7 +20,8 @@ public async Task Extract_WithLogMethodInvocationCode_ShouldTransformThemIntoLog
if (isValidCall)
{
var configuration = InterceptorConfigurationUtilities.GetInterceptorConfiguration();
- await Verify(logCall).UseParameters(description, configuration);
+ var roslynVersion = RoslynConfigurationUtilities.GetRoslynVersion();
+ await Verify(logCall).UseParameters(description, configuration, roslynVersion);
}
else
{
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor.verified.txt b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt
similarity index 100%
rename from tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor.verified.txt
rename to tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_11.verified.txt
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
new file mode 100644
index 0000000..8f9e224
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=HashBasedInterceptor_isValidCall=Roslyn_4_14.verified.txt
@@ -0,0 +1,53 @@
+{
+ Location: {
+ FilePath: path/testFile.cs,
+ Line: 12,
+ Character: 16,
+ InterceptableLocationSyntax: [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(1, "nedh6WI/ifg2J0oGdnNJkZkAAAB0ZXN0RmlsZS5jcw==")],
+ Context: {
+ Kind: SourceFile,
+ SourceSpan: {
+ Start: 146,
+ Length: 55
+ },
+ SourceTree: {
+ FilePath: path/testFile.cs,
+ Length: 210,
+ HasCompilationUnitRoot: true,
+ Options: {
+ LanguageVersion: CSharp13,
+ Language: C#,
+ DocumentationMode: Parse,
+ Errors: null
+ }
+ },
+ IsInSource: true,
+ IsInMetadata: false
+ }
+ },
+ Namespace: Foo,
+ ClassName: Test,
+ MethodName: BeginScope,
+ Message: Hello world {arg1} {arg2},
+ Parameters: [
+ {
+ NativeType: global::System.String,
+ Name: @message,
+ Type: Message,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Int32,
+ Name: @arg1,
+ Type: Others,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Boolean,
+ Name: @arg2,
+ Type: Others,
+ HasPropertiesToLog: false
+ }
+ ],
+ GeneratedMethodName: LogScope_FooTest_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
new file mode 100644
index 0000000..90b47fa
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCallObject_description=with parameters_sourceCode=PathBasedInterceptor_isValidCall=Rosyln_4_08.verified.txt
@@ -0,0 +1,53 @@
+{
+ Location: {
+ FilePath: path/testFile.cs,
+ Line: 12,
+ Character: 16,
+ InterceptableLocationSyntax: [System.Runtime.CompilerServices.InterceptsLocationAttribute(filePath: @"path/testFile.cs", line: 12, character: 16)],
+ Context: {
+ Kind: SourceFile,
+ SourceSpan: {
+ Start: 146,
+ Length: 55
+ },
+ SourceTree: {
+ FilePath: path/testFile.cs,
+ Length: 210,
+ HasCompilationUnitRoot: true,
+ Options: {
+ LanguageVersion: CSharp12,
+ Language: C#,
+ DocumentationMode: Parse,
+ Errors: null
+ }
+ },
+ IsInSource: true,
+ IsInMetadata: false
+ }
+ },
+ Namespace: Foo,
+ ClassName: Test,
+ MethodName: BeginScope,
+ Message: Hello world {arg1} {arg2},
+ Parameters: [
+ {
+ NativeType: global::System.String,
+ Name: @message,
+ Type: Message,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Int32,
+ Name: @arg1,
+ Type: Others,
+ HasPropertiesToLog: false
+ },
+ {
+ NativeType: global::System.Boolean,
+ Name: @arg2,
+ Type: Others,
+ HasPropertiesToLog: false
+ }
+ ],
+ GeneratedMethodName: LogScope_FooTest_12_16
+}
\ No newline at end of file
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.cs
index 3e5d25a..9225a76 100644
--- a/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.cs
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Extractors/LoggerScopeCallExtractorTests.cs
@@ -19,7 +19,8 @@ public async Task Extract_WithGivenLoggerScope_ShouldTransformIntoLoggerScopeCal
if (isValidCall)
{
var configuration = InterceptorConfigurationUtilities.GetInterceptorConfiguration();
- await Verify(loggerScope).UseParameters(description, configuration);
+ var roslynVersion = RoslynConfigurationUtilities.GetRoslynVersion();
+ await Verify(loggerScope).UseParameters(description, configuration, roslynVersion);
}
else
{
diff --git a/tests/AutoLoggerMessageGenerator.UnitTests/Utilities/RoslynConfigurationUtilities.cs b/tests/AutoLoggerMessageGenerator.UnitTests/Utilities/RoslynConfigurationUtilities.cs
new file mode 100644
index 0000000..a55ea9a
--- /dev/null
+++ b/tests/AutoLoggerMessageGenerator.UnitTests/Utilities/RoslynConfigurationUtilities.cs
@@ -0,0 +1,17 @@
+namespace AutoLoggerMessageGenerator.UnitTests.Utilities;
+
+public static class RoslynConfigurationUtilities
+{
+ public static string GetRoslynVersion()
+ {
+ #if Roslyn408
+ return "Rosyln_4_08";
+ #elif Roslyn411
+ return "Roslyn_4_11";
+ #elif Roslyn414
+ return "Roslyn_4_14";
+ #endif
+
+ throw new ArgumentOutOfRangeException("Unsupported roslyn version");
+ }
+}