Bug 6762 - Refactor -> Create class generates invalid class
Summary: Refactor -> Create class generates invalid class
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: Trunk
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2012-08-30 08:50 UTC by ventsislav mladenov
Modified: 2012-08-31 04:14 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 ventsislav mladenov 2012-08-30 08:50:19 UTC
Refactor -> Create class generate class with structure:

namespace NAMESPACE
{
    private readonly class CLASS_NAME
{
}

}

It should be:

namespace NAMESPACE
{
    (internal) class CLASS_NAME
    {
        //Maybe parameterless constructor ?
    }
}
Comment 1 Mike Krüger 2012-08-31 02:08:24 UTC
namespace Test {
	class A
	{
		string F ()
		{
			var Foo = new FooBar (4, 5, 6);
		}
	}
}

Creates:


namespace Test
{
	class FooBar
	{
		public FooBar (int i, int i2, int i3)
		{
			throw new System.NotImplementedException ();
		}
	}
}

Without params the constructor is missing - how did you get the "private readonly" modifiers ?
Which version of monodevelop are you using ?
Comment 2 ventsislav mladenov 2012-08-31 02:56:56 UTC
Hi Mike, thanks for fast response. 

Runtime:
	Mono 2.11.3 (tarball Mon Aug 27 10:16:24 UTC 2012) (64-bit)
	GTK 2.24.7
	GTK# (2.12.0.0)
Build information:
	Git revision: 097de72fd94d30698fe5b10e57ac79b9a60a32dd
	Build date: 2012-08-27 07:11:52+0000
Operating System:
	Linux
	Linux 3.4.4-31-desktop #1 SMP PREEMPT Mon Jun 25 12:51:13 UTC 2012 (c6214ee) x86_64 x86_64 x86_64 GNU/Linux

Test case:

Source:

public class A 
{
	private readonly Foo _foo;
}
right click on Foo, Refactor -> Create class.
This creates new file and class Foo :

namespace Test
{
	private readonly class Foo
{
}

}
-----------------------------------

public class A 
{
	private Foo _foo;
}
-->
namespace Test
{
	private class Foo
{
}

}

Which is still invalid. Obviously the Refactor takes field modifiers and creates class with same modifiers.
Comment 3 ventsislav mladenov 2012-08-31 03:08:30 UTC
BTW :
Your example is working.

Here two more things:
	class MainClass
	{
		private readonly FooBar _foo;

		public static void Main (string[] args)
		{
			_foo = new FooBar (4, 5, 6);
		}
	}
WORKING.
	class MainClass
	{
		private readonly FooBar _foo = new FooBar (4, 5, 6);

		public static void Main (string[] args)
		{
		}
	}
NOT WORKING.
Comment 4 Mike Krüger 2012-08-31 04:14:39 UTC
Fixed that one.

Didn't thought about this case :/