Skip to content
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

[LogProperties(Transitive = true)] generates uncompilable code if property is of List<T> type #5207

Closed
wasker opened this issue Jun 7, 2024 · 2 comments · Fixed by #5210
Closed
Assignees
Labels
area-telemetry bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@wasker
Copy link

wasker commented Jun 7, 2024

Description

[LogProperties(Transitive = true)] will result in generating uncompilable code, if object's property is of List<T> type.

Reproduction Steps

using System.Collections.Generic;
using Microsoft.Extensions.Logging;

namespace LoggerMessageCodeGen;
#pragma warning disable EXTEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

internal partial class Program
{
    static void Main(string[] args)
    {
    }

    internal partial class Log
    {
        [LoggerMessage(EventId = 1, EventName = "Test", Level = LogLevel.Information)]
        public static partial void Test(ILogger logger, [LogProperties(Transitive = true)] Test obj);
    }
}

public sealed class Test
{
    // This property will generate bad code when LogProperties.Transitive = true.
    public List<string> Blah { get; set; }
}

Expected behavior

Generated code should be compilable.

Actual behavior

Generated code doesn't compile.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@tarekgh tarekgh transferred this issue from dotnet/runtime Jun 7, 2024
@tarekgh
Copy link
Member

tarekgh commented Jun 7, 2024

CC @geeknoid @xakep139

@xakep139 xakep139 self-assigned this Jun 10, 2024
@xakep139 xakep139 added bug This issue describes a behavior which is not expected - a bug. and removed untriaged labels Jun 10, 2024
xakep139 added a commit that referenced this issue Jun 10, 2024
geeknoid pushed a commit that referenced this issue Jun 10, 2024
@xakep139 xakep139 added this to the 8.7 milestone Jun 10, 2024
@xakep139
Copy link
Contributor

@wasker thank you for reporting this!

@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-telemetry bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants