question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IDE0052 is incorrectly reported for a member referenced by nameof(...)

See original GitHub issue

This issue has been moved from a ticket on Developer Community.


[severity:It’s more difficult to complete my work] [regression] [worked-in:17.3] Have this NUnit test class:

[TestFixture]
public class TestClass {
  private readonly int[] values; // IDE0052

  [Test]
  [TestCaseSource(nameof(values))]
  public void TestMethod(int[] values) {
     /// bla bla
  }
}

VS 17.4 reports that “values” is not referred and can be removed despite that nameof references it.


Original Comments

Feedback Bot on 11/8/2022, 04:55 PM:

(private comment, text removed)


Original Solutions

(no solutions)

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Youssef1313commented, Nov 14, 2022

@ssg Generators deal with the compiler API, so I guess nothing blocks them from knowing that info.

0reactions
ssgcommented, Nov 14, 2022

@Youssef1313 I’m not surprised that compiler knows about it, but do you know if, say, source generators also have access to that information?

Read more comments on GitHub >

github_iconTop Results From Across the Web

IDE0052 incorrectly suggested for entire property when ...
SetSource: yes, like I mentioned: It should not report IDE0052 on the whole property. If anything, it should be reported on just the...
Read more >
IDE0052: Remove unread private member - .NET
Remove unread private member (IDE0052)​​ This rule flags private fields and properties that have one or more write references but no read ...
Read more >
IDE0052 Incorrectly identifies private member as "can be ...
Create a class that contains the following private member: private static readonly Timer writerTimer = new Timer((state) => ProcessQueue(), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found