Bug 5830 - Extract method generates broken out parameters instead of return values
Summary: Extract method generates broken out parameters instead of return values
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: Trunk
Hardware: PC Mac OS
: Low normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2012-06-22 16:25 UTC by Mikayla Hutchinson [MSFT]
Modified: 2012-07-16 09:25 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] 2012-06-22 16:25:29 UTC
It also seems to create an out parameter that assigns to a nonexistsenwhen there's a single return value.

For example:

void Foo ()
{
	var button = new Button ();
	var w = new Window (WindowType.Toplevel);
	w.Add (button, false, false, 0);
	w.Show ()
}

The middle two lines get extracted as:

void Foo ()
{
	var button = new Button ();
	NewMethod (out w, ref button);
	w.Show ()
}

static void NewMethod (out Window w, ref Button button)
{
	var w = new Window (WindowType.Toplevel);
	w.Add (button, false, false, 0);
}

This is broken. In NewMethod, w is defined twice. In foo, it is not defined. Button does not need to be ref. And w could be a return value, not an out parameter.

I would expect:

void Foo ()
{
	var button = new Button ();
	var w = NewMethod (button);
	w.Show ()
}

static Window NewMethod (Button button)
{
	var w = new Window (WindowType.Toplevel);
	w.Add (button, false, false, 0);
	return w;
}
Comment 1 Mike Krüger 2012-06-22 17:03:17 UTC
Extract method is atm broken - the da analysis unfortunately solves the extract method problem - a state is missing.

Without it I can't do the parameters correctly - around 50% of the extract method tests  I currently have does fail for that reason.
Comment 2 Mike Krüger 2012-07-16 09:25:57 UTC
fixed.