-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
WalkthroughThis 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
Assessment against linked issues
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesYou may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation Footnotes
|
There was a problem hiding this 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
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 forSendMessage
, are well-implemented and align with best practices for asynchronous programming.- 23-30: The implementation of the
SendMessage
method in theSendGridSender
class correctly uses asynchronous operations withSendGridClient
, 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
andSendGrid
packages inNetCore.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 useawait
appropriately within the method body for true asynchronous execution.
|
||
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. |
There was a problem hiding this comment.
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
if (tokens != null) | ||
foreach (var item in tokens) | ||
bodyHtml = bodyHtml.Replace(item.Key, item.Value); |
There was a problem hiding this comment.
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.
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); | |
} | |
} |
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)); |
There was a problem hiding this comment.
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.
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)); |
Summary by CodeRabbit