Bug 12244 - Generate constructor fails for generic property
Summary: Generate constructor fails for generic property
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: Trunk
Hardware: PC Windows
: Normal normal
Target Milestone: 4.0.9 (from master)
Assignee: Mike Krüger
Depends on:
Reported: 2013-05-15 01:13 UTC by Lopatkin Ilja
Modified: 2013-09-25 01:14 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 Lopatkin Ilja 2013-05-15 01:13:35 UTC
We have a simple class like that:

class TestClass {
    public Func<bool> Predicate { get; private set; }

When trying to generate constructor with this property MD fails with exception:

System.InvalidOperationException: Cannot parameterize a type with type arguments from a different compilation.
   в ICSharpCode.NRefactory.TypeSystem.ParameterizedType..ctor(ITypeDefinition genericType, IEnumerable`1 typeArguments) в d:\MonoDevelop-src\main\external\nrefactory\ICSharpCode.NRefactory\TypeSystem\ParameterizedType.cs:строка 62
   в ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver.LookInCurrentUsingScope(String identifier, IList`1 typeArguments, Boolean isInUsingDeclaration, Boolean parameterizeResultType) в d:\MonoDevelop-src\main\external\nrefactory\ICSharpCode.NRefactory.CSharp\Resolver\CSharpResolver.cs:строка 1530
   в ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver.LookupSimpleNameOrTypeName(String identifier, IList`1 typeArguments, NameLookupMode lookupMode) в d:\MonoDevelop-src\main\external\nrefactory\ICSharpCode.NRefactory.CSharp\Resolver\CSharpResolver.cs:строка 1443
   в ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver.ResolveSimpleName(String identifier, IList`1 typeArguments, Boolean isInvocationTarget) в d:\MonoDevelop-src\main\external\nrefactory\ICSharpCode.NRefactory.CSharp\Resolver\CSharpResolver.cs:строка 1349
   в ICSharpCode.NRefactory.CSharp.Refactoring.TypeSystemAstBuilder.ConvertTypeHelper(ITypeDefinition typeDef, IList`1 typeArguments) в d:\MonoDevelop-src\main\external\nrefactory\ICSharpCode.NRefactory.CSharp\Refactoring\TypeSystemAstBuilder.cs:строка 263
   в ICSharpCode.NRefactory.CSharp.Refactoring.TypeSystemAstBuilder.ConvertTypeHelper(IType type) в d:\MonoDevelop-src\main\external\nrefactory\ICSharpCode.NRefactory.CSharp\Refactoring\TypeSystemAstBuilder.cs:строка 208
   в ICSharpCode.NRefactory.CSharp.Refactoring.TypeSystemAstBuilder.ConvertType(IType type) в d:\MonoDevelop-src\main\external\nrefactory\ICSharpCode.NRefactory.CSharp\Refactoring\TypeSystemAstBuilder.cs:строка 161
   в MonoDevelop.CodeGeneration.CodeGenerationOptions.CreateShortType(IType fullType) в d:\MonoDevelop-src\main\src\addins\CSharpBinding\MonoDevelop.CSharp.CodeGeneration\CodeGenerationOptions.cs:строка 143
   в MonoDevelop.CodeGeneration.CreateConstructorGenerator.CreateConstructor.<GenerateCode>d__a.MoveNext() в d:\MonoDevelop-src\main\src\addins\CSharpBinding\MonoDevelop.CSharp.CodeGeneration\CreateConstructorGenerator.cs:строка 110
   в MonoDevelop.CodeGeneration.AbstractGenerateAction.GenerateCode() в d:\MonoDevelop-src\main\src\addins\CSharpBinding\MonoDevelop.CSharp.CodeGeneration\AbstractGenerateAction.cs:строка 145
   в MonoDevelop.CodeGeneration.GenerateCodeWindow.<.ctor>b__3(Object param0, EventArgs param1) в d:\MonoDevelop-src\main\src\addins\CSharpBinding\MonoDevelop.CSharp.CodeGeneration\GenerateCodeWindow.cs:строка 100
   в MonoDevelop.CodeGeneration.GenerateCodeWindow.CustomTreeView.OnSubmit(EventArgs e) в d:\MonoDevelop-src\main\src\addins\CSharpBinding\MonoDevelop.CSharp.CodeGeneration\GenerateCodeWindow.cs:строка 60
   в MonoDevelop.CodeGeneration.GenerateCodeWindow.CustomTreeView.OnKeyPressEvent(EventKey evnt) в d:\MonoDevelop-src\main\src\addins\CSharpBinding\MonoDevelop.CSharp.CodeGeneration\GenerateCodeWindow.cs:строка 47
   в Gtk.Widget.keypressevent_cb(IntPtr widget, IntPtr evnt)
Comment 1 Mike Krüger 2013-05-15 10:23:31 UTC
Works for me with master - maybe you just got an unlucky push :/
Comment 2 Lopatkin Ilja 2013-05-16 00:21:44 UTC
Well, that's strange. The official buid of XamarinStudio works just fine. But that can't be just an unlucky push because that problem is bothering me for several months.
P.S. Just found out. In fact, it does work if I open code generation window, then just close it and then open again.
Comment 3 PJ 2013-06-24 16:18:38 UTC
This bug was marked as fixed for Xamarin Studio 4.0.9, which is currently in the beta channel. Try it out!
Comment 4 Lopatkin Ilja 2013-09-25 00:49:48 UTC
No, it's still broken. Moreover, now it crashes in both official build and trunk version.
Comment 5 Mike Krüger 2013-09-25 01:10:18 UTC
Ok now I could verify it - the 2nd time it fails for me as well.

Comment 6 Lopatkin Ilja 2013-09-25 01:14:18 UTC
Great, thanks! It was really annoying. :)