Skip to content

Dynamicproxy defaultvalue issue #45

@hikalkan

Description

@hikalkan

Hi,

I've a simple class:

public class MyClass
{
    public virtual void MyMethod(string str = null)
    {
        Console.WriteLine(str);
    }
}

When I check

typeof(MyClass).GetMethod("MyMethod").GetParameters()[0].DefaultValue

it's null (as expected). But if I create a dynamicproxy

var gen = new ProxyGenerator(new DefaultProxyBuilder());
var proxy = gen.CreateClassProxy<MyClass>();

Then I check

proxy.GetType().GetMethod("MyMethod").GetParameters()[0].DefaultValue

It is not null, it is System.Reflection.Missing

This causes a problem when I proxy an ASP.NET MVC Controller with a method which has a default parameter as null such which is defined as:

public virtual ActionResult Login(string returnUrl = "/", string loginMessage = null)

I use proxy since I want to intercept the method call.

Is this a bug or known situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions