Bug 10672 - Auto-Fix of Generate Class to fill Generic params does not take in account constraints
Summary: Auto-Fix of Generate Class to fill Generic params does not take in account co...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: 4.0
Hardware: PC Windows
: Low normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2013-02-26 01:21 UTC by Ciprian Khlud
Modified: 2013-02-26 06:03 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 Ciprian Khlud 2013-02-26 01:21:53 UTC
Description of Problem:
Auto-Fix of Generate Class does give an incomplete class definition (does not care about the constraints)

Steps to reproduce the problem:
1. Create a console application
2. Paste this code as starting point:
using System;

namespace TestConsole
{
	public interface IBase
	{
	}
	public class Test 
	{
		public void Generate<T>() where T:IBase, new()
		{

		}
	}
	class MainClass
	{
		public static void Main (string[] args)
		{
			var testConsole = new Test ();
			testConsole.Generate<Data> ();
		}
	}
}
3. set the cursor to the word: Data; from the line: testConsole.Generate<Data> ();
4. Press Alt+Enter to show quick fixes
5. Select Generate Class (or Generate Nested Class)

Expected result:
Generated Data class should take care about the constraints:
 - here: new() meaning it has to define a default constructor; 
 - IBase, meaning it implements this interface.

So: there are 3 kinds of constraints that should be considered when generate Data class type:
new() = Default constructor
I ... and various names = base classes, interfaces
struct = the generated type has to be a struct type (non nullable type)

Actual result: 
public class Data
{
}
Comment 4 Mike Krüger 2013-02-26 05:36:00 UTC
fixed