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

RSRP-216475: Quick-fix for flags enum bit-test inserts dead code

$
0
0
Reporter William Dean (willdean) William Dean (willdean)
Created Feb 19, 2011 2:00:39 AM
Updated Feb 9, 2012 9:11:38 PM
Priority Normal
Type Bug
Fix versions Mirabile Futurum
State Submitted
Assignee Alexey Kuptsov (alexey.kuptsov)
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
The following code:

    class Test
    {
        [Flags]
        enum TestEnum
        {
            a = 0x01,
            b = 0x02,
        }

        void MyMethod()
        {
            TestEnum val = TestEnum.a;

            if(val & TestEnum.a)
            {
                ;
            }
        }
    }


Contains an error at "val & TestEnum.a"
R# offers a quick-fix "Compare with default value", which converts the if to:

 if((val & TestEnum.a) != (TestEnum)0) 


The (TestEnum) cast is redundant and so, after a short pause, is marked as dead code, requiring a reposition and another quick-fix to get a clean line.

It would be better if the first quick-fix could insert the clean code to start with.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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