/// <summary>
        /// Creates a pull request comment.
        /// </summary>
        /// <param name="pullRequest">The <see cref="GitHubPullRequest"/> to comment on.</param>
        /// <param name="file">The <see cref="GitHubPullRequestFile"/> to comment on.</param>
        /// <param name="analyzer">The <see cref="ICodeAnalyzer"/> to use for finding violations.</param>
        /// <param name="physicalFilePath">The physical path of the file stored locally.</param>
        /// <returns>
        /// A <see cref="Task{TResult}"/> of <see cref="IEnumerable{T}"/> of <see cref="PullRequestReviewComment"/>
        /// representing the commenting operation.
        /// </returns>
        public override async Task<IEnumerable<PullRequestReviewComment>> Create(GitHubPullRequest pullRequest, GitHubPullRequestFile file, ICodeAnalyzer analyzer, string physicalFilePath)
        {
            if (pullRequest == null)
            {
                throw new ArgumentNullException("pullRequest");
            }

            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            var comments = new List<PullRequestReviewComment>();

            if (file.Changes > 0)
            {
                var comment = new PullRequestReviewCommentCreate(
                    "Renamed files not supported.",
                    pullRequest.LastCommitId,
                    file.FileName,
                    1);

                var addedComment = await this.Create(comment, pullRequest.Number);

                comments.Add(addedComment);
            }

            return comments;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a pull request comment.
 /// </summary>
 /// <param name="pullRequest">The <see cref="GitHubPullRequest"/> to comment on.</param>
 /// <param name="file">The <see cref="GitHubPullRequestFile"/> to comment on.</param>
 /// <param name="analyzer">The <see cref="ICodeAnalyzer"/> to use for finding violations.</param>
 /// <param name="physicalFilePath">The physical path of the file stored locally.</param>
 /// <returns>
 /// A <see cref="Task{TResult}"/> of <see cref="IEnumerable{T}"/> of <see cref="PullRequestReviewComment"/>
 /// representing the commenting operation.
 /// </returns>
 public abstract Task<IEnumerable<PullRequestReviewComment>> Create(
     GitHubPullRequest pullRequest,
     GitHubPullRequestFile file,
     ICodeAnalyzer analyzer,
     string physicalFilePath);
Ejemplo n.º 3
0
 /// <summary>
 /// Does not do anything.
 /// </summary>
 /// <param name="pullRequest">The <see cref="GitHubPullRequest"/> to comment on.</param>
 /// <param name="file">The <see cref="GitHubPullRequestFile"/> to comment on.</param>
 /// <param name="analyzer">The <see cref="ICodeAnalyzer"/> to use for finding violations.</param>
 /// <param name="physicalFilePath">The physical path of the file stored locally.</param>
 /// <returns>
 /// A <see cref="Task{TResult}"/> of <see cref="IEnumerable{T}"/> of <see cref="PullRequestReviewComment"/>
 /// representing the commenting operation.
 /// </returns>
 /// <remarks>
 /// The result of <see cref="Task{TResult}"/> of <see cref="IEnumerable{T}"/> of <see cref="PullRequestReviewComment"/>
 /// will always be an empty enumeration.
 /// </remarks>
 public override Task<IEnumerable<PullRequestReviewComment>> Create(
     GitHubPullRequest pullRequest,
     GitHubPullRequestFile file,
     ICodeAnalyzer analyzer,
     string physicalFilePath)
 {
     using (
         var task =
             new Task<IEnumerable<PullRequestReviewComment>>(() => new List<PullRequestReviewComment>()))
     {
         task.RunSynchronously();
         return task;
     }
 }