Why doesn't C# warn about unused methods?

Why doesn't C# warn about unused methods?

  • Comments 7

Q: Why doesn't C# warn on unused methods?

A: This is something that the C# compiler could do, subject to a few caveats:

  • Virtual functions would have to be excluded
  • Interface implementations wouldn have to be excluded
  • You would get false positives if you used reflection
  • You might get false positives if you used delegates (the compiler might be able to be smart here)

Other than that, it would be possible for us to do this, and we may do it in a future version.

 

 

[Author: Eric Gunnerson]

Leave a Comment
  • Please add 7 and 8 and type the answer here:
  • Post
Page 1 of 1 (7 items)