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

RSRP-123124: 'Invert if' - give better result

$
0
0
Reporter Vladimir Reshetnikov (nikov) Vladimir Reshetnikov (nikov)
Created Sep 30, 2009 12:40:40 AM
Updated Apr 26, 2012 2:44:10 AM
Priority Major
Type Feature
Fix versions Mirabile Futurum
State Open
Assignee Alexey Kuptsov (alexey.kuptsov)
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
static int Foo(string s, DayOfWeek d)
{
	int result = 0;
	if (s != null) // Invert if
	{
		result = int.Parse(s);
		switch (d)
		{
			case DayOfWeek.Sunday:
				return result;
			default:
				return -result;
		}
	}

	Debug.WriteLine("null");
	return result;
}


Actual result:

static int Foo(string s, DayOfWeek d)
{
	int result = 0;
	if (s == null)
	{ // Grr!
	}
	else
	{
		result = int.Parse(s);
		switch (d)
		{
			case DayOfWeek.Sunday:
				return result;
			default:
				return -result;
		}
	}

	Debug.WriteLine("null");
	return result;
}


Expected result:

static int Foo(string s, DayOfWeek d)
{
	int result = 0;
	if (s == null)
	{
		Debug.WriteLine("null");
		return result;
	}
	
	result = int.Parse(s);
	switch (d)
	{
		case DayOfWeek.Sunday:
			return result;
		default:
			return -result;
	}
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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