Bug 10858 - Extract Method should use return, not out
Summary: Extract Method should use return, not out
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: Trunk
Hardware: PC Windows
: Low normal
Target Milestone: 4.2.3 (from master)
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2013-03-03 15:42 UTC by Mikayla Hutchinson [MSFT]
Modified: 2014-02-12 06:18 UTC (History)
4 users (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:
VERIFIED FIXED

Description Mikayla Hutchinson [MSFT] 2013-03-03 15:42:53 UTC
Extract method extracted the following method:

static void GetDesignerFile (ProjectFile file, AspNetAppProject project, out ProjectFile designerFile)
{
	var dfName = project.LanguageBinding.GetFileName (file.FilePath.FileNameWithoutExtension + ".designer");
	designerFile = project.Files.GetFile (file.FilePath.ParentDirectory.Combine (dfName));
}

but I would expect:

static ProjectFile GetDesignerFile (ProjectFile file, AspNetAppProject project)
{
	var dfName = project.LanguageBinding.GetFileName (file.FilePath.FileNameWithoutExtension + ".designer");
	return project.Files.GetFile (file.FilePath.ParentDirectory.Combine (dfName));
}
Comment 1 Mike Krüger 2013-09-28 00:46:46 UTC
fixed
Comment 2 Atin 2014-01-13 12:51:27 UTC
I am trying to reproduce this issue, but not sure about the steps.
Could you please provide some test case or steps? So we can Verify this issue.
Comment 3 PJ 2014-02-11 17:46:14 UTC
You won't need to use the exact same method that Michael is using. You can see that the extract method tool now uses a return where applicable, for instance here: http://screencast.com/t/KgZvZYtwEIk

Here's the pre-extract source:

using System;

namespace ExampleExtract
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int i = 0, j = 1, k = 2, l;

			l = i + j + k;

		}
	}
}

1) Highlight the line that says 'l = i + j + k;'
2) Right click => Refactor => Extract Method
3) Navigate to where you want to extract the method and press enter

Expected:

The extracted method should return a value instead of using 'out' to change the value of a parameter.
Comment 4 Mohit Kheterpal 2014-02-12 06:18:43 UTC
Today we have checked this issue with following builds :

XS 4.2.4 (build 14)

Now extracted method return a value to change the value of a parameter.

Screencast : http://screencast.com/t/BYn70yO9c1x

Hence closing this issue.