When use the LoggerMessage attribute with ILogger in primary constructors, compiler hint CS9107 if ILogger also pass to the base class. ILogger<T> does not affected.
Reproduction Steps
public class MyServiceTemplate(ILogger logger);
public partial class MyService1(ILogger logger) : MyServiceTemplate(logger) // CS9107
{
[LoggerMessage(LogLevel.Error, "Log")]
private partial void Log();
}
public partial class MyService2(ILogger<MyService2> logger) : MyServiceTemplate(logger)
{
[LoggerMessage(LogLevel.Error, "Log")]
private partial void Log();
}
Description
When use the
LoggerMessage
attribute withILogger
in primary constructors, compiler hint CS9107 ifILogger
also pass to the base class.ILogger<T>
does not affected.Reproduction Steps
Expected behavior
Both code will have same result: CS9107 or none.
Actual behavior
ILogger => CS9107 ILogger\<T> => None
Regression?
No response
Known Workarounds
No response
Configuration
SDK 9.0.100-rc.1.24452.12 MSBuild 17.12.0-preview-24422-09+d17ec720d macOS 15 Rider 2024.3 EAP 1
Other information
Generated code