Bug 3888 - [newresolver] Extract Method throws an exception
Summary: [newresolver] Extract Method throws an exception
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Mike Krüger
Depends on:
Reported: 2012-03-13 17:12 UTC by Stephen Shaw
Modified: 2012-03-19 03:18 UTC (History)
1 user (show)

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:

Description Stephen Shaw 2012-03-13 17:12:08 UTC
If you highlight some code and right click refactor -> extract method monodevelop throws an exception.

Test Case:

Highlight 'i % 3 == 0' and try 'extract method'

using System;

namespace FizzBuzz
	public class Translator
		public static string Translate (int i)
			if (i % 3 == 0) return "Fizz";
			if (i % 5 == 0) return "Buzz";
			return i.ToString ();

System.NullReferenceException: Object reference not set to an instance of an object
  at MonoDevelop.CSharp.Refactoring.ExtractMethod.ExtractMethodRefactoring.Analyze (MonoDevelop.Refactoring.RefactoringOptions options, MonoDevelop.CSharp.Refactoring.ExtractMethod.ExtractMethodParameters param, Boolean fillParameter) [0x00167] in /home/sshaw/code/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs:285 
  at MonoDevelop.CSharp.Refactoring.ExtractMethod.ExtractMethodRefactoring.CreateParameters (MonoDevelop.Refactoring.RefactoringOptions options) [0x00078] in /home/sshaw/code/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs:126 
  at MonoDevelop.CSharp.Refactoring.ExtractMethod.ExtractMethodRefactoring.Run (MonoDevelop.Refactoring.RefactoringOptions options) [0x00000] in /home/sshaw/code/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs:96 
  at MonoDevelop.Refactoring.CurrentRefactoryOperationsHandler+RefactoringOperationWrapper.Operation () [0x00000] in /home/sshaw/code/monodevelop/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs:674 
  at MonoDevelop.Refactoring.CurrentRefactoryOperationsHandler.Run (System.Object data) [0x0000d] in /home/sshaw/code/monodevelop/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs:79 
  at MonoDevelop.Components.Commands.CommandHandler.InternalRun (System.Object dataItem) [0x00000] in /home/sshaw/code/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandHandler.cs:42 
  at MonoDevelop.Components.Commands.CommandManager.DefaultDispatchCommand (MonoDevelop.Components.Commands.ActionCommand cmd, MonoDevelop.Components.Commands.CommandInfo info, System.Object dataItem, System.Object target, CommandSource source) [0x00064] in /home/sshaw/code/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1055 
  at MonoDevelop.Components.Commands.CommandManager.DispatchCommand (System.Object commandId, System.Object dataItem, System.Object initialTarget, CommandSource source) [0x002d1] in /home/sshaw/code/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1026
Comment 1 Mike Krüger 2012-03-19 03:18:50 UTC
Fixed the exception, but extract method needs some more work.