Bug 14154 - "replace with return" fix creates redundant code
Summary: "replace with return" fix creates redundant code
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: Trunk
Hardware: PC Mac OS
: Normal normal
Target Milestone: master
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2013-08-21 13:21 UTC by Mikayla Hutchinson [MSFT]
Modified: 2013-08-22 08:55 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mikayla Hutchinson [MSFT] 2013-08-21 13:21:57 UTC
if (region.Contains (x, y))
	return true;
return false;


converts to:

return region.Contains (x, y) ? true : false;

But it should be

return region.Contains (x, y);
Comment 1 Mike Krüger 2013-08-21 15:28:44 UTC
the next one should be recognized by another issue - I've a redundant conditional operator for exactly this case.

I don't know if it's worth putting the logic in the replace with return fix - I'll look what r# does in that case :)
Comment 2 Mikayla Hutchinson [MSFT] 2013-08-21 16:37:04 UTC
Yeah, the other issue did show up, it just seemed strange that the first issue created such obviously redundant code.
Comment 3 Mike Krüger 2013-08-22 08:55:05 UTC
Implemented.

But generally I don't think it's a good idea to let the code issues optimize the code to the end because I don't want that the user loses track of what's going on. Therefore it's often better to let it do step by step.

However in that special case I don't see any reason to generate the cond ? true : false branch. I hope nobody gets confused by this very simple case :)