-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 generator - for enumerable input argument, add missing helper method #51965
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
dotnet-issue-labeler
bot
added
the
untriaged
New issue has not been triaged by the area owner
label
Apr 27, 2021
Tagging subscribers to this area: @maryamariyan Issue DetailsIf an argument is
For the tests I used <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0-preview.4.21216.3" /> Repro: internal static partial class TestWithMoreThan6Params
{
[LoggerMessage(EventId = 8, Level = LogLevel.Error, Message = "M9 {p1} {p2} {p3} {p4} {p5} {p6} {p7}")]
public static partial void Method9(ILogger logger, int p1, int p2, int p3, int p4, int p5, int p6, System.Collections.Generic.IEnumerable<int> p7);
} Generated code// <auto-generated/>
#nullable enable
namespace ConsoleApp66
{
partial class TestWithMoreThan6Params
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "6.0.0.0")]
private readonly struct __Method9Struct : global::System.Collections.Generic.IReadOnlyList<global::System.Collections.Generic.KeyValuePair<string, object?>>
{
private readonly global::System.Int32 _p1;
private readonly global::System.Int32 _p2;
private readonly global::System.Int32 _p3;
private readonly global::System.Int32 _p4;
private readonly global::System.Int32 _p5;
private readonly global::System.Int32 _p6;
private readonly global::System.Collections.Generic.IEnumerable<global::System.Int32> _p7;
public __Method9Struct(global::System.Int32 p1, global::System.Int32 p2, global::System.Int32 p3, global::System.Int32 p4, global::System.Int32 p5, global::System.Int32 p6, global::System.Collections.Generic.IEnumerable<global::System.Int32> p7)
{
this._p1 = p1;
this._p2 = p2;
this._p3 = p3;
this._p4 = p4;
this._p5 = p5;
this._p6 = p6;
this._p7 = p7;
}
public override string ToString()
{
var p1 = this._p1;
var p2 = this._p2;
var p3 = this._p3;
var p4 = this._p4;
var p5 = this._p5;
var p6 = this._p6;
var p7 = __Enumerate((global::System.Collections.IEnumerable ?)this._p7);
return $"M9 {p1} {p2} {p3} {p4} {p5} {p6} {p7}";
}
public static string Format(__Method9Struct state, global::System.Exception? ex) => state.ToString();
public int Count => 8;
public global::System.Collections.Generic.KeyValuePair<string, object?> this[int index]
{
get => index switch
{
0 => new global::System.Collections.Generic.KeyValuePair<string, object?>("p1", this._p1),
1 => new global::System.Collections.Generic.KeyValuePair<string, object?>("p2", this._p2),
2 => new global::System.Collections.Generic.KeyValuePair<string, object?>("p3", this._p3),
3 => new global::System.Collections.Generic.KeyValuePair<string, object?>("p4", this._p4),
4 => new global::System.Collections.Generic.KeyValuePair<string, object?>("p5", this._p5),
5 => new global::System.Collections.Generic.KeyValuePair<string, object?>("p6", this._p6),
6 => new global::System.Collections.Generic.KeyValuePair<string, object?>("p7", this._p7),
7 => new global::System.Collections.Generic.KeyValuePair<string, object?>("{OriginalFormat}", "M9 {p1} {p2} {p3} {p4} {p5} {p6} {p7}"),
_ => throw new global::System.IndexOutOfRangeException(nameof(index)), // return the same exception LoggerMessage.Define returns in this case
};
}
public global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<string, object?>> GetEnumerator()
{
for (int i = 0; i < 8; i++)
{
yield return this[i];
}
}
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Logging.Generators", "6.0.0.0")]
public static partial void Method9(global::Microsoft.Extensions.Logging.ILogger logger, global::System.Int32 p1, global::System.Int32 p2, global::System.Int32 p3, global::System.Int32 p4, global::System.Int32 p5, global::System.Int32 p6, global::System.Collections.Generic.IEnumerable<global::System.Int32> p7)
{
if (logger.IsEnabled(global::Microsoft.Extensions.Logging.LogLevel.Error))
{
logger.Log(
global::Microsoft.Extensions.Logging.LogLevel.Error,
new global::Microsoft.Extensions.Logging.EventId(8, nameof(Method9)),
new __Method9Struct(p1, p2, p3, p4, p5, p6, p7),
null,
__Method9Struct.Format);
}
}
}
}
|
maryamariyan
removed
the
untriaged
New issue has not been triaged by the area owner
label
Apr 27, 2021
Fixed in #51963 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If an argument is
IEnumerable
, we get error:For the tests I used
Repro:
Generated code
The text was updated successfully, but these errors were encountered: