It is official, the debugger hates me

time to read 10 min | 1995 words

And I thought that we are friends...

(Image from clipboard).png

For completeness sake, this is 100% repreducable, and happens when I and trying to debug a not hard to follow code, it can't enter this method...

/// <summary>

/// Close the generic type, using parameters from the invocation

/// </summary>

public static Type CloseGenericType(IInvocation invocation, Type type)

{

       if(type.IsGenericType==false)

              return type;

       if(type.IsGenericTypeDefinition)

              return type.MakeGenericType(invocation.GetType().GetGenericArguments());

       bool shouldMakeType = false;

       List<Type> arguments = new List<Type>();

       foreach (Type argument in type.GetGenericArguments())

       {

              Type madeArgument = argument;// CloseGenericType(invocation, argument);

              arguments.Add(madeArgument);

              if(madeArgument!=argument)

                     shouldMakeType = true;

       }

       if(!shouldMakeType)

              return type;

       return type.MakeGenericType(arguments.ToArray());

}

Update: Looks like this is the issue, but I still don't know why:

type.MakeGenericType(invocation.GetType().GetGenericArguments())