Reporter | Simon (simonl1980) |
---|---|
Created | Mar 13, 2012 7:28:54 PM |
Updated | Mar 13, 2012 7:28:54 PM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Evgeny Pasynkov (pasynkov) |
Subsystem | Code Analysis - Control Flow |
Affected versions | 6.1, 6.1.1 |
Fixed in build | No Fixed in build |
Using the following code in a console app:
JetBrains ReSharper 6.1 Full Edition (Build 6.1.1000.82 on 2012-02-15T16:14:48) incorrectly marks the return statement as redundant. However, if I then apply the 'Inline Method' refactoring to ClassTwo.AnotherMethod(), then the return ISN'T marked as redundant, despite the fact that the code is functionally equivalent.
Without the return though, the extra Console.WriteLine() is executed, changing the program flow.
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { if (args.Length == 1) { Console.WriteLine("1"); return; //****This return is flagged as not required } new ClassTwo().AnotherMethod(); } } public class ClassTwo { public void AnotherMethod() { Console.WriteLine("2"); } } }
JetBrains ReSharper 6.1 Full Edition (Build 6.1.1000.82 on 2012-02-15T16:14:48) incorrectly marks the return statement as redundant. However, if I then apply the 'Inline Method' refactoring to ClassTwo.AnotherMethod(), then the return ISN'T marked as redundant, despite the fact that the code is functionally equivalent.
Without the return though, the extra Console.WriteLine() is executed, changing the program flow.