在影响一个文件的代码修复中,在Task <solution>上返回Task <document>的优点是什么?

时间:2016-03-14 13:55:51

标签: c# roslyn

创建代码修复时,您可以选择返回Task<Document>Task<Solution>。显然,当您(可能)修改多个文档(例如Rename操作)时,应选择后者。

如果仅修改当前文档,是否有关于应该返回的内容的指南?返回Task<Document>似乎最合乎逻辑,但下一步又做了什么?如果它继续返回Task<Solution>而没有其他任何东西,我们也可以自己做。

1 个答案:

答案 0 :(得分:4)

如果您不覆盖 // Google Project API Credentials $clientId = '### removed by Billy, DO NOT INSERT PROPER CREDENTIALS'; $clientSecret = '### removed by Billy, DO NOT INSERT PROPER CREDENTIALS'; $redirectUrl = base_url() . 'user_authentication/'; // Google Client Configuration $gClient = new Google_Client(); $gClient->setApplicationName('hashtag'); $gClient->setClientId($clientId); $gClient->setClientSecret($clientSecret); $gClient->setRedirectUri($redirectUrl); $google_oauthV2 = new Google_Oauth2Service($gClient); if (isset($_REQUEST['code'])) { $gClient->authenticate(); $this->session->set_userdata('token',$gClient->getAccessToken()); redirect($redirectUrl); } $token = $this->session->userdata('token'); if (!empty($token)) { $gClient->setAccessToken($token); } if ($gClient->getAccessToken()) { $userProfile = $google_oauthV2->userinfo->get(); // Preparing data for database insertion $userData['oauth_provider'] = 'google'; $userData['oauth_uid'] = $userProfile['id']; $userData['first_name'] = $userProfile['given_name']; $userData['last_name'] = $userProfile['family_name']; $userData['email'] = $userProfile['email']; $userData['gender'] = $userProfile['gender']; $userData['locale'] = $userProfile['locale']; $userData['profile_url'] = $userProfile['link']; $userData['picture_url'] = $userProfile['picture']; // Insert or update user data $userID = $this->user->checkUser($userData); if(!empty($userID)){ $data['userData'] = $userData; $this->session->set_userdata('userData',$userData); } else { $data['userData'] = array(); } } else { $data['authUrl'] = $gClient->createAuthUrl(); } // $this->load->view('user_authentication/index',$data); echo $this->load->view($div,$data); } // -------- MODEL FUNCTION -------------- public function checkUser($data = array()){ $this->db->select($this->primaryKey); $this->db->from($this->tableName); $this->db->where(array('oauth_provider'=>$data['oauth_provider'],'oauth_uid'=>$data['oauth_uid'])); $prevQuery = $this->db->get(); $prevCheck = $prevQuery->num_rows(); if($prevCheck > 0){ $prevResult = $prevQuery->row_array(); $data['modified'] = date("Y-m-d H:i:s"); $update = $this->db->update($this->tableName,$data,array('id'=>$prevResult['id'])); $userID = $prevResult['id']; }else{ $data['created'] = date("Y-m-d H:i:s"); $data['modified'] = date("Y-m-d H:i:s"); $insert = $this->db->insert($this->tableName,$data); $userID = $this->db->insert_id(); } return $userID?$userID:FALSE; } base implementation只会从GetChangedSolutionAsync获得解决方案。

覆盖GetChangedDocumentAsync的目的只是让你编写更简单的代码。