Is there a way to disable build type specific warning behavior?

I'm using belt and suspenders type checking for potential  null object problems.  Resharper isn't playing nicely though.  In a  debug build it marks the if (button != null) check as always true and puts a warning marker in the sidebar.  In a release build it shades the Debug.Assert as never used code, although at least it's smart enough not to clutter the sidebar this time.

I don't want to disable the always true/false resharper warning  globally because it can indicate a problem in the code.  At the same  time having to clutter my code up with ReSharper disable/restore ConditionIsAlwaysTrueOrFalse comments every time I do a check is ugly.

Is there an option somewhere in ReSharper 5.1 to disable build type  contingent behavior so that the if isn't marked in debug builds, without  preventing the warning from being shown if an Assert isn't present?

//This should always work unless the columns are fiddled with.

LinkButton button = e.Row.Cells[5].FindControl( "linkButtonName" ) as LinkButton;

//if this isn't the case in a debug build have VS throw an error in the devs face

Debug.Assert(button != null);

//Don't let anything go boom in production if an error isn't caught in dev
if (button != null)
    button.Visible = ( schedule.CreatedBy == Authentification.GetLoggedInUser() );

Please sign in to leave a comment.