7

I want to treat resharper 5.0 error "Possible NullReference Exception" as MSVS 2010 compile error. Is it possible?

1 Answers1

4

Update, since it seems people are still finding this answer:

This, or something very much like it, is possible today with e.g. StyleCop Analyzers. There's a whole bunch of analyzer tools which you can plug into the .NET compiler platform - I recommend checking out the DotNetAnalyzers GitHub org, as well as (of course) the home of the .NET compiler platform itself.


Original answer:

You can edit the type of warning that will be issued by R# under ReSharper/Options/Code Inspection/Inspection Severity.

However, this will not necessary mean that the compiler throws errors - R# isn't responsible for actually compiling the code when you hit "Build" in your project.

Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
  • Yes, I've already done that and found the same thing. But I thought maybe there's a kinda hack to somehow tune the compiler. – type_mismatch Jul 29 '10 at 10:36
  • @type: I doubt it - in that case, msbuild.exe probably would already emmit warnings about that. – Tomas Aschan Jul 29 '10 at 10:48
  • This doesn't answer the question. I'd also like to know if there is a way to get resharper errors to "break" the build. We would like 100% compliance with our Resharper rules. – m1m1k Aug 05 '13 at 22:00
  • @m1m1k: It does answer the original question: *"is it possible?"* Unfortunately, the answer is "no, not to my knowledge and not without some heavy reconfiguring of the build hooks in Visual Studio". It is highly possible that you could make it work if you use a different build tool such as Ant or Maven, but eventually you'll still have to run msbuild.exe on your code, and if msbuild.exe doesn't respect your R# settings you're pretty much out of luck. – Tomas Aschan Aug 05 '13 at 23:06
  • This sounds like a great idea for a custom plugin. Throw compile errors when you write bad code that is new. – ColacX Feb 18 '16 at 10:47
  • @ColacX: That plugin already exists, now under the name Stylecop.Analyzers: https://github.com/DotNetAnalyzers/StyleCopAnalyzers (a lot has happened since August -13...) – Tomas Aschan Feb 18 '16 at 15:09