Disable code inspection for compiler warnings?

Is it possible to disable Re# warnings for what it believes to be compiler warnings?

My real issue is disabling the warning about unused method parameters. Resharper seems to think it's a compiler warning and offers to issue a "#pragma disable warning 168", which hides the Re# warning. There is no compiler warning however (using highest warning levels with treat warnings as errors). There is seemingly no option to disable this code inspection, which annoys me to death.

I don't want to remove the parameters in question for various reasons (planned features incl. delegate use and some consistency issues) and since it's more or less an open source project which doesn't officially use Resharper, I'd rather not clutter my code to hide Resharper warnings. I'm pretty sure Re# 3 allowed me to disable these warnings, but not 4.1? Yes, it may very well be that I'm using bad practice and what not, but I still wish to disable that warning, at least for now.

Also, the NullReferenceException inspection was alot nicer in Re# 3, even if the new one is smarter in some ways..

SomeRefClass cls;

void InitCls()


     cls = new SomeRefClass();


void OtherFunc()


     if(cls == null)


     cls.DoSomething(); // Possible NRE in 4.1, not in 3.1


Now I do see why this happens, but it's still annoying like hell. In 3.1 the NRE inspection helped me catch several misstakes, in 4.1 I have to disable it due to things like these.

Thank you for your time.


I was looking for an answer for this, too, but did not find one. I don't want to disable the null checking, but there are certain types of method calls that I would want to turn off this warning, if there is any way. We use these often enough that it would be worthwhile to me to go through some trouble to do this.

1) I notice that if we do this:

if (!s.IsNullOrEmpty){



it does not trigger the warning. ReSharper seems to know that we have checked for null. But if I try the same with our home made static method

if (!StringUtil.IsNullOrWhiteSpaces(s)){



then I get the warning. I would like to have a way to tell it to treat our method the same as it treats String.IsNullOrEmpty.

Harder is this: We have a class that does run time asserts. I would also like to tell it that I don't want the warning if I do this:

Dbc.Assert(s != null);



You can do this using the JetBrains annotations for your home-spun functions.  Look in the ReSharper help file under Code Analysis > External Annotations.  This page will tell you the two different ways to include the annotations in your project.  Once you've done that, you can mark the StringUtil.IsNullOrWhitespaces method like this:


public static bool IsNullOrWhitespaces([AssertionCondition(AssertionConditionType.IS_NOT_NULL)] string s) { ... }
then you won't get the ReSharper warning on a string after you call the method.  For your Dbg.Assert method, I would suggest adding an AssertNotNull method with the appropriate attributes instead of using Dbg.Assert(o != null).


Please sign in to leave a comment.