0

C# allows this. How do I get Visual Studio to warn me when I do this?

BTW, Resharper doesn't warn about this either.

Stackoverflow Question about this in Eclipse

Another Question about this in Eclipse

I need to do this now because: We run nightly code analysis that picks this up as an issue and my team agrees that it is a real issue.

EDIT: I've started work on a ReSharper™ plugin to do this.

Community
  • 1
  • 1
SalamiArmy
  • 413
  • 1
  • 5
  • 14
  • Can't you get your team and CI system to run the code analysis more often? (As an aside, you could also use Roslyn to write a custom diagnostic.) Do you have code reviews in your team? If not, this would be a good time to start :) – Jon Skeet Dec 11 '14 at 13:34
  • There would be no way to avoid getting the issue against your name. You wouldn't know you had done it until after you had committed your code. That's not good enough for me and my team. But thanks for helping, The last time I asked this I was completely ignored. And I see I've managed a down vote and a comment this time. I'll get there eventually :D – SalamiArmy Dec 11 '14 at 13:42
  • "There would be no way to avoid getting the issue against your name." Both pre-commit code review and running the code analysis yourself before committing would avoid this, surely? – Jon Skeet Dec 11 '14 at 13:49
  • Instead of moving our entire code review process onto every developers machine so it can run before they commit (or into our gated process) I'm just gonna write a Resharper plugin for it, that way the entire internet benefits! – SalamiArmy Dec 11 '14 at 14:00
  • But then you've got two different processes judging the code - wouldn't you be happier with one consistent one? I would. – Jon Skeet Dec 11 '14 at 14:03
  • OK, here's the thing. We use SONAR nightly but only for the pretty reports and graphs, it re-uses the same Resharper ruleset that are installed on every team members Visual Studio. SONAR can pick this up, but its to clunky to be in our gate or on our machines. This issue is the only inconsistency, the only SONAR rule we have turned on. – SalamiArmy Dec 12 '14 at 05:44
  • It's not clear what is too clunky to be "in your gate" (whatever that means) - the R# ruleset? Do you agree that it feels unfortunate not to be able to check your code *before* check-in (whether locally or some other way) in the same way that it's going to be tested *after* check-in? It's like not being able to run your unit tests until the CI machine gets it... – Jon Skeet Dec 12 '14 at 06:45
  • `SONAR can pick this up, but its to clunky to be in our gate or on our machines.` - SONAR is the subject of this sentence. When I say "Its too clunky" what I mean to say is "SONAR is too clunky". Sorry for not being clearer there. I cannot be clear enough, thank you for pointing this out. – SalamiArmy Dec 12 '14 at 07:12
  • Okay, so if you're *only* using SONAR for reports and graphs, why is it performing code diagnostics? Basically if I were you, I'd look at deciding whether or not you want those code diagnostics: if you do, make them avaiable pre-check-in somehow; if you don't, ditch them. At this point, however, I think we should stop with comments - it's a bit too chatty for SO. – Jon Skeet Dec 12 '14 at 07:15
  • I'm writing the R# plugin for it right now because, from what I'm hearing from you, it is the only way to get Visual Studio to detect this. – SalamiArmy Dec 12 '14 at 07:39
  • I don't see where you got that from. For example, you may be able to write an FxCop rule, even if one doesn't already exist. All I've really said is that you should be able to run the same code checks before committing as after. – Jon Skeet Dec 12 '14 at 08:11
  • LOL @ 'should' be able. P 'should' be equal NP in complexity theory. That doesn't make P=NP. That's a very good suggestion though, thank you. – SalamiArmy Dec 12 '14 at 08:20

0 Answers0