Disable "Suppress nullable warning with '!'" context action

Hi,

I would like to disable the above action but I cannot find the option to do so. It doesn't appear to exist in the list of Context Actions in the settings.

Cheers,

Andrew

5 comments
Comment actions Permalink

Hello Andrew,

 

Sorry for the delayed response.

Could you please provide a code sample where the specified quick-fix appears?

Most probably, it's caused by compiler warning that cannot be disabled through ReSharper options. You can disable it by Alt+Enter | Compiler warning | Disable with #pragma.

Thank you.

0
Comment actions Permalink

Hi,

The following code causes the Quick Fix to be suggested:

#nullable enable

namespace ResharperSuppressNullableWarning
{
  class Program
  {
    static void Main(string[] args)
    {
      object obj = null;
    }
  }
}

I want to disable the Quick Fix as I would like people to fix the issue that causes the warning (i.e. handle nulls appropriately), not suppress it. Disabling the warning through other means defeats this purpose.

Regards,

Andrew

0
Comment actions Permalink

Thank you for the reply, Andrew.

 

So as it's compiler warning there's no option to change severity level for this inspection.

Could you please specify why you don't consider applying quick-fix for fixing the issue instead of disabling it?

Thank you.

0
Comment actions Permalink

Hi,

My problem is that the quick fix (suppressing the warning) is rarely the best way to fix the issue. When that "fix" is so easily available developers are likely to just apply it instead of properly handling the potential null value. The ! operator should be used with extreme caution as you are telling the compiler that you know, in all circumstances, that value will never be null.

Within a couple of days of enabling nullable reference types in a project a NullReferenceException bug was introduced because of a developer applying this "fix" when it wasn't appropriate.

Hence the need to disable this quick fix.

Regards,

Andrew

0
Comment actions Permalink

Hi,

Is there any update on how this Quick Fix can be disabled?

Or maybe a way to disable all Suppression "fixes".

Cheers,

Andrew

0

Please sign in to leave a comment.