private static void UnboxIfNeeded(Type type, ILGenerator generator) { if (type.IsValueType) { generator.Emit(OpCodes.Unbox_Any, type); } }