-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging Source Generator fails to compile when in
parameter modifier is present
#62644
Comments
Tagging subscribers to this area: @dotnet/area-extensions-logging Issue DetailsDescriptionThe logging source generator drops the See repro below for code, but essential is: [LoggerMessage(2, LogLevel.Information, "Foo: {my}")]
public static partial void LogSomething1(this ILogger logger, in MyReadOnlyStruct my); The generated code [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "6.0.5.2210")]
public static partial void LogSomething1(this global::Microsoft.Extensions.Logging.ILogger logger, global::MyReadOnlyStruct my)
{
if (logger.IsEnabled(global::Microsoft.Extensions.Logging.LogLevel.Information))
{
__LogSomething1Callback(logger, my, null);
}
} doesn't have the For completeness: the same occurs when Reproduction Stepsusing Microsoft.Extensions.Logging;
ILogger logger = null!; // will fail at runtime, but to keep the repro simple...
MyReadOnlyStruct my = new(3, 4, 5, 6);
logger.LogSomething(my);
logger.LogSomething1(my);
public static partial class LogExtensions
{
// This works as expected.
[LoggerMessage(1, LogLevel.Information, "Foo: {my}")]
public static partial void LogSomething(this ILogger logger, MyReadOnlyStruct my);
// This fails, as no defining declaration with the correct overload can be found.
[LoggerMessage(2, LogLevel.Information, "Foo: {my}")]
public static partial void LogSomething1(this ILogger logger, in MyReadOnlyStruct my);
}
public readonly record struct MyReadOnlyStruct(double X, double Y, double Z, double W); Expected behaviorBuild succeeds -- the correct definition of the method is generated, so Roslyn can bind to that method. Actual behaviorBuild fails.
Regression?No. Known WorkaroundsDon't use Configuration.NET SDK 6.0.100 Other informationNo response
|
- Supports usage of "in" modifier - Improves support for generic constraints Fixes dotnet#58550, dotnet#62644
Fixed in #64593 |
… / when dealing with constraints (dotnet#64593) * Fixes some logging source gen bugs: - Supports usage of "in" modifier - Improves support for generic constraints Fixes dotnet#58550, dotnet#62644 * Apply PR feedback * Add another test
Description
The logging source generator drops the
in
modifier, so the project fails to compile.See repro below for code, but essential is:
The generated code
doesn't have the
in
parameter modifier, so this defined method can't be found --> compilation fails.For completeness: the same occurs when
ref
modifier is used.Reproduction Steps
Expected behavior
Build succeeds -- the correct definition of the method is generated, so Roslyn can bind to that method.
Actual behavior
Build fails.
Regression?
No.
Known Workarounds
Don't use
in
orref
.Configuration
.NET SDK 6.0.100
Other information
No response
The text was updated successfully, but these errors were encountered: