Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted project to use Async Properly Fixes #28 #29

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

mitchelsellers
Copy link
Contributor

@mitchelsellers mitchelsellers commented Mar 21, 2024

Summary by CodeRabbit

  • New Features
    • Transitioned all methods to Async for enhanced functionality and performance.
    • Updated email sending features to support asynchronous operations.
  • Documentation
    • Added method documentation and updated package versions in project files.
  • Refactor
    • Refactored the interface and class implementations for email sending to accommodate asynchronous methods.
  • Chores
    • Updated package references for improved stability and performance.
    • Increased version numbers in preparation for a new release.
  • Continuous Integration
    • Improved CI workflows by adding steps for code coverage collection and package restoration.

Copy link

coderabbitai bot commented Mar 21, 2024

Walkthrough

This update marks a significant transition towards asynchronous operations across the project, particularly focusing on email sending functionalities. It introduces changes to enhance performance and adapt to modern programming practices by updating method signatures, refining control flows, and ensuring compatibility with the latest package versions. The modifications span across testing, package restoration, and method implementations, collectively aiming to streamline operations and improve code maintainability.

Changes

File(s) Change Summary
.github/workflows/ci-build.yml
.github/workflows/release-build.yml
CI/CD pipeline enhancements including XPlat Code Coverage collection and a new step for package restoration.
README.md Documentation update to reflect breaking changes in version 7.0, transitioning to asynchronous methods.
src/.../NetCore.Utilities.Email.SendGrid.Tests.csproj
src/.../NetCore.Utilities.Email.SendGrid.csproj
Package updates and version incrementation for better compatibility and functionality.
src/.../SmtpServiceTests.cs
src/.../SendGridSender.cs
src/.../SendGridService.cs
Refactoring to asynchronous methods for email sending, including method renaming, signature adjustments, and logic refinements for improved email operations.

Assessment against linked issues

Objective Addressed Explanation
Update to Async for All Sending (#28)

Poem

🐇 Oh, in the land of code and byte,

🚀 Where async calls take flight,

We've tweaked and tuned with might,

💻 For efficiency, our sight.

📧 Emails fly, both day and night,

In async harmony, oh what a sight!

🌟 To version seven, we alight.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 412fb571 71.43%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (412fb57) Report Missing Report Missing Report Missing
Head commit (ab6e020) 120 59 49.17%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#29) 56 40 71.43%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@kenny-sellers kenny-sellers merged commit 663baad into develop Mar 21, 2024
2 of 3 checks passed
@kenny-sellers kenny-sellers deleted the feature/async branch March 21, 2024 04:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 412fb57 and ab6e020.
Files selected for processing (8)
  • .github/workflows/ci-build.yml (1 hunks)
  • .github/workflows/release-build.yml (1 hunks)
  • README.md (1 hunks)
  • src/NetCore.Utilities.Email.SendGrid.Tests/NetCore.Utilities.Email.SendGrid.Tests.csproj (1 hunks)
  • src/NetCore.Utilities.Email.SendGrid.Tests/SmtpServiceTests.cs (8 hunks)
  • src/NetCore.Utilities.Email.SendGrid/NetCore.Utilities.Email.SendGrid.csproj (2 hunks)
  • src/NetCore.Utilities.Email.SendGrid/SendGridSender.cs (1 hunks)
  • src/NetCore.Utilities.Email.SendGrid/SendGridService.cs (1 hunks)
Additional comments: 9
src/NetCore.Utilities.Email.SendGrid/SendGridSender.cs (2)
  • 7-20: The adjustments to the ISendGridSender interface, including the addition of method documentation and the transition to an asynchronous method signature for SendMessage, are well-implemented and align with best practices for asynchronous programming.
  • 23-30: The implementation of the SendMessage method in the SendGridSender class correctly uses asynchronous operations with SendGridClient, adhering to best practices for async programming.
.github/workflows/release-build.yml (1)
  • 36-36: Adding a step for restoring packages before the build process is a good practice, ensuring all dependencies are correctly resolved before building the project.
src/NetCore.Utilities.Email.SendGrid.Tests/NetCore.Utilities.Email.SendGrid.Tests.csproj (1)
  • 10-20: Updating package references to newer versions in NetCore.Utilities.Email.SendGrid.Tests.csproj is a good practice, ensuring the project benefits from the latest bug fixes, performance improvements, and features.
.github/workflows/ci-build.yml (1)
  • 40-50: The addition of steps for collecting XPlat Code Coverage and pushing coverage data to Codacy in the CI build workflow is commendable. These steps enhance the project's quality by ensuring thorough test coverage analysis and integration with Codacy for code quality monitoring.
src/NetCore.Utilities.Email.SendGrid/NetCore.Utilities.Email.SendGrid.csproj (1)
  • 34-40: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [37-47]

Updating the versions of the icg.netcore.utilities.email and SendGrid packages in NetCore.Utilities.Email.SendGrid.csproj introduces potential improvements and new features. Ensure compatibility with the project's existing codebase and functionality.

README.md (1)
  • 11-13: The update to the README.md file accurately reflects the breaking change in version 7.0 related to transitioning to async methods. This is crucial for ensuring users are aware of significant changes that might affect their use of the library.
src/NetCore.Utilities.Email.SendGrid/SendGridService.cs (1)
  • 173-173: Consider using method overloading instead of optional parameters for SendMessageWithAttachmentAsync to enhance clarity and maintainability.
src/NetCore.Utilities.Email.SendGrid.Tests/SmtpServiceTests.cs (1)
  • 87-94: Renaming methods to include "Async" in their names aligns with best practices for asynchronous operations. However, ensure that the method signatures include the async keyword and use await appropriately within the method body for true asynchronous execution.

Comment on lines 8 to 16

This package depends on the ICG.NetCore.Utilities.Email project for template implementation

## SonarCloud Analysis

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=IowaComputerGurus_netcore.utilities.email.sendgrid&metric=alert_status)](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.sendgrid)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=IowaComputerGurus_netcore.utilities.email.sendgrid&metric=coverage)](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.sendgrid)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=IowaComputerGurus_netcore.utilities.email.sendgrid&metric=security_rating)](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.sendgrid)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=IowaComputerGurus_netcore.utilities.email.sendgrid&metric=sqale_index)](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.sendgrid)
## Breaking Changes

Version 7.0 has a breaking change transitioning to Async for all methods!

## Dependencies
The following additional NuGet packages are installed with this extension.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [24-24]

Consider rephrasing "Standard installation via HuGet Package Manager" to "Standard installation via NuGet Package Manager" to correct the typo.

- Standard installation via HuGet Package Manager
+ Standard installation via NuGet Package Manager

Comment on lines +85 to +87
if (tokens != null)
foreach (var item in tokens)
bodyHtml = bodyHtml.Replace(item.Key, item.Value);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding curly braces around the nested statement(s) in this if block and the foreach block for consistency and improved readability.

if (tokens != null)
+{
    foreach (var item in tokens)
+    {
        bodyHtml = bodyHtml.Replace(item.Key, item.Value);
+    }
+}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (tokens != null)
foreach (var item in tokens)
bodyHtml = bodyHtml.Replace(item.Key, item.Value);
if (tokens != null)
{
foreach (var item in tokens)
{
bodyHtml = bodyHtml.Replace(item.Key, item.Value);
}
}

Comment on lines +194 to +202
public async void SendWithReplyToAsync_ShouldThrowArgumentException_WhenReplyToMissing()
{
//Arrange
var to = "tester@test.com";
var subject = "test";
var message = "message";

//Act/Assert
Assert.Throws<ArgumentNullException>(() => _service.SendWithReplyTo("", "", to, subject, message));
var result = await Assert.ThrowsAsync<ArgumentNullException>(() => _service.SendWithReplyToAsync("", "", to, subject, message));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods intended to be asynchronous should return Task or Task<T> instead of void. Also, remove the unused local variable result to clean up the code.

- public async void SendWithReplyToAsync_ShouldThrowArgumentException_WhenReplyToMissing()
+ public async Task SendWithReplyToAsync_ShouldThrowArgumentException_WhenReplyToMissing()
{
    //Arrange
    var to = "tester@test.com";
    var subject = "test";
    var message = "message";

    //Act/Assert
-   var result = await Assert.ThrowsAsync<ArgumentNullException>(() => _service.SendWithReplyToAsync("", "", to, subject, message));
+   await Assert.ThrowsAsync<ArgumentNullException>(() => _service.SendWithReplyToAsync("", "", to, subject, message));
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
public async void SendWithReplyToAsync_ShouldThrowArgumentException_WhenReplyToMissing()
{
//Arrange
var to = "tester@test.com";
var subject = "test";
var message = "message";
//Act/Assert
Assert.Throws<ArgumentNullException>(() => _service.SendWithReplyTo("", "", to, subject, message));
var result = await Assert.ThrowsAsync<ArgumentNullException>(() => _service.SendWithReplyToAsync("", "", to, subject, message));
public async Task SendWithReplyToAsync_ShouldThrowArgumentException_WhenReplyToMissing()
{
//Arrange
var to = "tester@test.com";
var subject = "test";
var message = "message";
//Act/Assert
await Assert.ThrowsAsync<ArgumentNullException>(() => _service.SendWithReplyToAsync("", "", to, subject, message));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to Async for All Sending
2 participants