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

Regression in .NET 9 RC2: IDE0052 reports false positive with source-generated method #75483

Open
bart-vmware opened this issue Oct 11, 2024 · 0 comments
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@bart-vmware
Copy link

Version Used:
.NET 9 RC2

Steps to Reproduce:
After updating from .NET 8 to .NET 9 RC2, we're getting a false positive on this line:

internal sealed partial class DecryptionConfigurationProvider(
    IList<IConfigurationProvider> providers, ITextDecryptor? textDecryptor, ILoggerFactory loggerFactory)
    : CompositeConfigurationProvider(providers, loggerFactory)
{
#pragma warning disable IDE0052 // Remove unread private members
    private readonly ILogger<DecryptionConfigurationProvider> _logger = loggerFactory.CreateLogger<DecryptionConfigurationProvider>();
#pragma warning restore IDE0052 // Remove unread private members

    // ...

    [LoggerMessage(Level = LogLevel.Trace, Message = "Decrypted value '{CipherValue}' at key '{Key}' to '{PlainTextValue}'.")]
    private partial void LogDecrypt(string key, string? cipherValue, string? plainTextValue);
}

The private field is used by the source-generated LogDecrypt logger method, so the warning should not appear.

To reproduce, clone the repo at https://github.com/SteeltoeOSS/Steeltoe, check out branch try-net90, open src/Steeltoe.All.sln in Visual Studio 2022 v17.12 (latest preview) and build.

Diagnostic Id:
IDE0052

Expected Behavior:
No warning, which is the behavior in .NET 8.

Actual Behavior:
A warning appears during build.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 11, 2024
@bart-vmware bart-vmware changed the title Regression in IDE0052 Regression in .NET 9 RC2: IDE0052 reports false positive with source-generated method Oct 11, 2024
@CyrusNajmabadi CyrusNajmabadi added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 11, 2024
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

No branches or pull requests

2 participants