Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-271974: Convert if to switch may break semantics

$
0
0
Reporter Alexander Groß (alexandergross) Alexander Groß (alexandergross)
Created Jun 10, 2011 12:52:28 PM
Updated Mar 27, 2012 5:03:10 PM
Priority Critical
Type Bug
Fix versions 7.0
State Submitted
Assignee Alexey Kuptsov (alexey.kuptsov)
Subsystem Quick Fixes
Affected versions 5.1.3
Fixed in build No Fixed in build
I know that you have to review refactorings after applying them, but do you see an option of not suggesting if->switch when it alters semantics?

using System;

namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      var i = 3;

      for (var j = 0; j < i; j++)
      {
        if (Something() == TheEnum.Foo) // Convert if to switch
        {
          Another();
          break;
        }
        else
        {
          break;
        }
      }
    }

    static void Another()
    {
      Console.WriteLine("Another");
    }

    static TheEnum Something()
    {
      Console.WriteLine("Something");
      return TheEnum.Bar;
    }
  }

  internal enum TheEnum
  {
    Foo,
    Bar
  }
}


Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>