[Mono-bugs] [Bug 509131] New: Reflection.EmitCall with optional parameter types not consistent with .net

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jun 2 11:21:19 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=509131


           Summary: Reflection.EmitCall with optional parameter types not
                    consistent with .net
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mail at tinco.nl
         QAContact: mono-bugs at lists.ximian.com
          Found By: Development


Description of Problem:
System.Reflection.EmitCall throws an error:

Unhandled Exception: System.InvalidOperationException: Method is not VarArgs
method and optional types were passed
  at System.Reflection.Emit.ILGenerator.EmitCall (OpCode opcode,
System.Reflection.MethodInfo methodInfo, System.Type[] optionalParameterTypes)
[0x00000] 
  at CodeGenerator.Main (System.String[] args) [0x00000] 

When called with optional types and the method is not a varargs method.

Steps to reproduce the problem:
1. Call EmitCall with optional types and a method that's not a varargs method.

Actual Results:
Unhandled Exception: System.InvalidOperationException: Method is not VarArgs
method and optional types were passed
  at System.Reflection.Emit.ILGenerator.EmitCall (OpCode opcode,
System.Reflection.MethodInfo methodInfo, System.Type[] optionalParameterTypes)
[0x00000] 
  at CodeGenerator.Main (System.String[] args) [0x00000] 

Expected Results:
No error at all. This is sort of a bug in MS.Net since we're not using the
method like it's supposed to be used. But .net does not throw an error.

How often does this happen? 
Always

Additional Information:
Example:

using System;
using System.Reflection;
using System.Reflection.Emit;

public class CodeGenerator {
    static void Main(string[] args) {
        AssemblyName asmN = new AssemblyName("generated");
            AppDomain appD = AppDomain.CurrentDomain;
            AssemblyBuilder asmB = appD.DefineDynamicAssembly(asmN,
AssemblyBuilderAccess.RunAndSave);
            ModuleBuilder modB = asmB.DefineDynamicModule(asmN.Name, asmN.Name
+ ".exe", true);
        var metB = modB.DefineGlobalMethod("main", MethodAttributes.Static,
null, null);
                var currentScope = metB.GetILGenerator();
                currentScope.BeginScope();
        currentScope.EmitCall(OpCodes.Call,
typeof(System.Type).GetMethod("GetTypeFromHandle"), new
Type[]{typeof(System.RuntimeTypeHandle)});
        currentScope.EndScope();
                modB.CreateGlobalFunctions();
                asmB.SetEntryPoint(metB, PEFileKinds.ConsoleApplication);
                asmB.Save(asmN.Name + ".exe");
    }
}

-- 
Configure bugmail: http://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