R# 6.1.1 false-positive for HashAlgorithm.Create(string)

In the following code, R# 6.1.1 marks the "if (hash == null)" test as "always false", and the content of the if block as unreachable:

using (var hash = HashAlgorithm.Create(algorithmName))
{
   if (null == hash)
   {
      throw new ArgumentException("Invalid hash algorithm", "algorithmName");
   }
   ...


Looking at the
MSDN documentation for .NET 3.5 or higher:

Return Value
A new instance of the specified hash algorithm, or null if hashName is not a valid hash algorithm.


I appreciate this probably won't get fixed for v6, since v7 has now been released. Can anyone confirm whether this is fixed in v7?

1 comment
Comment actions Permalink

Hello Richard
     This problem hasn't been fixed in v7. I've logged this problem under http://youtrack.jetbrains.com/issue/RSRP-329200 with high priority and we will do our best to fix it. Thank you!

Andrey Serebryansky

Software Developer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

Please sign in to leave a comment.