[Mono-bugs] [Bug 642130] New: Activator.CreateInstance Method (Type, Object[]) does not work with compiler service (Mono.CSharp)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Sep 27 16:05:31 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=642130

https://bugzilla.novell.com/show_bug.cgi?id=642130#c0


           Summary: Activator.CreateInstance Method (Type, Object[]) does
                    not work with compiler service (Mono.CSharp)
    Classification: Mono
           Product: Mono: Compilers
           Version: SVN
          Platform: x86
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: Tomasz.Kubacki at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3
(KHTML, like Gecko) Chrome/6.0.472.53 Safari/534.3

following code does NOT work in mono 2.8 master from today when executing with
Mono.Csharp compiler service. It DOES work in mono 2.6.7, so it seems like
regression. It's easy to reproduce error with csharp repl.

var logicians = new[] { new { Name = "Alfred", Surname = "Tarski", Age = 33 }, 
                new { Name = "Gotlob", Surname = "Frege", Age = 42 }, 
                new { Name = "Kurt", Surname = "Gödel", Age = 22 }, 
                new { Name = "Unknown ", Surname = "Logican", Age = 33 }, 
                new { Name = "Józef", Surname = "Bocheński", Age = 22 }, 
                new { Name = "Stanisław", Surname = "Leśniewski", Age = 79 }, 
                new { Name = "Saul", Surname = "Kripke", Age = 40 }, 
                new { Name = "George", Surname = "Boolos", Age = 79 } };
var elementType = logicians.GetType().GetElementType(); 
Type genericType = typeof(List<>);      

var targetType = genericType.MakeGenericType(new Type[]{elementType}); 
Activator.CreateInstance(targetType,2);
-----------------------------------------------
System.NotSupportedException: Operation is not supported.
  at System.Reflection.MonoGenericClass.GetConstructors (BindingFlags bf)
[0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, BindingFlags
bindingAttr, System.Reflection.Binder binder, System.Object[] args,
System.Globalization.CultureInfo culture, System.Object[] activationAttributes)
[0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args,
System.Object[] activationAttributes) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args)
[0x00000] in <filename unknown>:0 
  at Class11.Host (System.Object& $retval) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object&
result, System.Boolean& result_set) [0x00000] in <filename unknown>:0 
  at Mono.CSharpShell.Evaluate (System.String input) [0x00000] in <filename
unknown>:0 



Reproducible: Always

Steps to Reproduce:
1.open csharp (from master 2.8 27th sep)
2.paste example code
var logicians = new[] { new { Name = "Alfred", Surname = "Tarski", Age = 33 }, 
                new { Name = "Gotlob", Surname = "Frege", Age = 42 }, 
                new { Name = "Kurt", Surname = "Gödel", Age = 22 }, 
                new { Name = "Unknown ", Surname = "Logican", Age = 33 }, 
                new { Name = "Józef", Surname = "Bocheński", Age = 22 }, 
                new { Name = "Stanisław", Surname = "Leśniewski", Age = 79 }, 
                new { Name = "Saul", Surname = "Kripke", Age = 40 }, 
                new { Name = "George", Surname = "Boolos", Age = 79 } };
var elementType = logicians.GetType().GetElementType(); 
Type genericType = typeof(List<>);      

var targetType = genericType.MakeGenericType(new Type[]{elementType}); 
Activator.CreateInstance(targetType,2);

3. press enter :)
Actual Results:  
System.NotSupportedException: Operation is not supported.
  at System.Reflection.MonoGenericClass.GetConstructors (BindingFlags bf)
[0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, BindingFlags
bindingAttr, System.Reflection.Binder binder, System.Object[] args,
System.Globalization.CultureInfo culture, System.Object[] activationAttributes)
[0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args,
System.Object[] activationAttributes) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args)
[0x00000] in <filename unknown>:0 
  at Class11.Host (System.Object& $retval) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object&
result, System.Boolean& result_set) [0x00000] in <filename unknown>:0 
  at Mono.CSharpShell.Evaluate (System.String input) [0x00000] in <filename
unknown>:0 


Expected Results:  
creation of empty generic list of anonymous class

code DOES work when you compile and run it as normal program code in 2.8 or
2.6.7 (without using Mono.CSharp), so it seems like Mono.CShapr error

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list