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

Fixed some warnings in Encamina.Enmarcha.Email #119

Merged
merged 13 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Previous classification is not required if changes are simple or all belong to t
- `Encamina.Enmarcha.Bot`
- `Encamina.Enmarcha.Core`
- `Encamina.Enmarcha.Data`
- `Encamina.Enmarcha.Email`
- Corrected a typo in the Spanish error message in `ResponseMessages.es.resx` from "ha encontrar" to "ha encontrado".

## [8.1.5]
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<PropertyGroup>
<VersionPrefix>8.1.7</VersionPrefix>
<VersionSuffix>preview-03</VersionSuffix>
<VersionSuffix>preview-04</VersionSuffix>
</PropertyGroup>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public class EmailAttachmentSpecification
/// <summary>
/// Gets the file name of the attachment in this specification.
/// </summary>
public string FileName { get; init; }
public string? FileName { get; init; }
HugoRamosEs marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Gets the <see cref="ContentType">content type</see> of the attachment in this specification.
/// </summary>
public ContentType ContentType { get; init; }
public ContentType? ContentType { get; init; }

/// <summary>
/// Gets the binary data of the attachment in this specification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class EmailSpecification
/// <summary>
/// Gets or sets the e-mail body.
/// </summary>
public string Body { get; set; }
public string? Body { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the <see cref="Body">body</see> of the e-mail is an HTML or not.
Expand Down
10 changes: 5 additions & 5 deletions src/Encamina.Enmarcha.Email.Abstractions/IEmailBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Net.Mime;
#pragma warning disable S2360 // Optional parameters should not be used

using System.Net.Mime;
using System.Text;

namespace Encamina.Enmarcha.Email.Abstractions;

#pragma warning disable S2360 // Optional parameters should not be used

/// <summary>
/// Represents a builder that allows creating and sending a new e-mail.
/// </summary>
Expand Down Expand Up @@ -38,7 +38,7 @@ public interface IEmailBuilder
/// </summary>
/// <param name="senderName">Optional (custom) sender name.</param>
/// <returns>The <see cref="IEmailBuilder"/> so that additional calls can be chained.</returns>
IEmailBuilder SetDefaultSender(string senderName = null);
IEmailBuilder SetDefaultSender(string? senderName = null);

/// <summary>
/// Adds an attachment.
Expand Down Expand Up @@ -73,7 +73,7 @@ public interface IEmailBuilder
/// <param name="recipientName">The recipient's name. Defaults to <see langword="null"/>.</param>
/// <param name="recipientType">The type of recipient (like 'to', 'cc', or 'bcc'). Defaults to <see cref="EmailRecipientType.TO"/>.</param>
/// <returns>The <see cref="IEmailBuilder"/> so that additional calls can be chained.</returns>
IEmailBuilder AddRecipient(string emailAddress, string recipientName = null, EmailRecipientType recipientType = EmailRecipientType.TO);
IEmailBuilder AddRecipient(string emailAddress, string? recipientName = null, EmailRecipientType recipientType = EmailRecipientType.TO);

/// <summary>
/// Sets the e-mail's subject.
Expand Down
4 changes: 2 additions & 2 deletions src/Encamina.Enmarcha.Email.Abstractions/SmtpClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
namespace Encamina.Enmarcha.Email.Abstractions;

/// <summary>
/// Represent's common SMTP configuration parameters or options.
/// Represents common SMTP configuration parameters or options.
/// </summary>
public class SmtpClientOptions : INameable
{
private string name = null;
private string? name = null;

/// <summary>
/// Gets or sets the host name of the SMTP service.
Expand Down
12 changes: 6 additions & 6 deletions src/Encamina.Enmarcha.Email.MailKit/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IEmailBuilder AddAttachment(string fileName, byte[] data, string contentT
=> AddAttachment(fileName, data, string.IsNullOrWhiteSpace(contentTypeValue) ? null : new ContentType(contentTypeValue));

/// <inheritdoc/>
public IEmailBuilder AddAttachment(string fileName, byte[] data, ContentType contentType)
public IEmailBuilder AddAttachment(string fileName, byte[] data, ContentType? contentType)
{
Specification.Attachments.Add(new EmailAttachmentSpecification()
{
Expand All @@ -63,7 +63,7 @@ public IEmailBuilder AddAttachment(string fileName, byte[] data, ContentType con
}

/// <inheritdoc/>
public IEmailBuilder AddRecipient(string emailAddress, string recipientName = null, EmailRecipientType recipientType = EmailRecipientType.TO)
public IEmailBuilder AddRecipient(string emailAddress, string? recipientName = null, EmailRecipientType recipientType = EmailRecipientType.TO)
{
Guard.IsNotNullOrWhiteSpace(emailAddress);

Expand Down Expand Up @@ -114,7 +114,7 @@ public async Task SendAsync(CancellationToken cancellationToken)
}

/// <inheritdoc/>
public IEmailBuilder SetBody(string body, bool isHtml = false)
public IEmailBuilder SetBody(string? body, bool isHtml = false)
{
Specification.Body = body;
Specification.IsHtmlBody = isHtml;
Expand All @@ -128,7 +128,7 @@ public IEmailBuilder SetBody(string body, bool isHtml = false)
public IEmailBuilder SetSender(string emailAddress) => SetSender(emailAddress, null);

/// <inheritdoc/>
public IEmailBuilder SetSender(string emailAddress, string senderName)
public IEmailBuilder SetSender(string emailAddress, string? senderName)
{
Guard.IsNotNullOrWhiteSpace(emailAddress);
Guard.IsTrue(emailAddress.IsValidEmail(), nameof(emailAddress), @"Parameter is not a valid e-mail format!");
Expand All @@ -143,7 +143,7 @@ public IEmailBuilder SetSender(string emailAddress, string senderName)
}

/// <inheritdoc/>
public IEmailBuilder SetDefaultSender(string senderName = null) => SetSender(SmtpClientOptions.User, senderName);
public IEmailBuilder SetDefaultSender(string? senderName = null) => SetSender(SmtpClientOptions.User, senderName);

/// <inheritdoc/>
/// <remarks>This implementation does not allows the subject to be <see langword="null"/>.</remarks>
Expand All @@ -156,7 +156,7 @@ public IEmailBuilder SetSubject(string subject)
return this;
}

private static SmtpClientOptions ValidateOptions(SmtpClientOptions smtpClientOptions)
private static SmtpClientOptions ValidateOptions(SmtpClientOptions? smtpClientOptions)
HugoRamosEs marked this conversation as resolved.
Show resolved Hide resolved
{
#pragma warning disable S3236 // Caller information arguments should not be provided explicitly
Guard.IsNotNull(smtpClientOptions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Encamina.Enmarcha.Email.Abstractions;
#pragma warning disable S2360 // Optional parameters should not be used

using Encamina.Enmarcha.Email.Abstractions;
using Encamina.Enmarcha.Email.MailKit;

using Microsoft.Extensions.Configuration;
Expand All @@ -7,8 +9,6 @@

namespace Microsoft.Extensions.DependencyInjection;

#pragma warning disable S2360 // Optional parameters should not be used

/// <summary>
/// Extension methods for configuring common and required services e-mail management using <see href="https://github.com/jstedfast/MailKit">MailKit.</see>.
/// </summary>
Expand All @@ -22,7 +22,7 @@ public static class IServiceCollectionExtensions
/// <remarks>Adds the <see cref="IEmailProviderFactory"/> to retrieve instances of <see cref="IEmailProvider"/> in the given <paramref name="serviceLifetime">service lifetime</paramref>.</remarks>
/// <param name="services"> The <see cref="IServiceCollection"/> to add services to.</param>
/// <param name="configuration">The current set of key-value application configuration parameters.</param>
/// <param name="serviceLifetime">The lifetime for the e-mail proider service. By default it is <see cref="ServiceLifetime.Singleton"/>.</param>
/// <param name="serviceLifetime">The lifetime for the e-mail provider service. By default it is <see cref="ServiceLifetime.Singleton"/>.</param>
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
/// <seealso href="http://www.mimekit.net/"/>
public static IServiceCollection AddMailKitEmailProvider(this IServiceCollection services, IConfiguration configuration, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton)
Expand All @@ -38,7 +38,7 @@ public static IServiceCollection AddMailKitEmailProvider(this IServiceCollection
/// <remarks>Adds the <see cref="IEmailProviderFactory"/> to retrieve instances of <see cref="IEmailProvider"/> in the given <paramref name="serviceLifetime">service lifetime</paramref>.</remarks>
/// <param name="services"> The <see cref="IServiceCollection"/> to add services to.</param>
/// <param name="options">Action to configure options for the email provider.</param>
/// <param name="serviceLifetime">The lifetime for the e-mail proider service. By default it is <see cref="ServiceLifetime.Singleton"/>.</param>
/// <param name="serviceLifetime">The lifetime for the e-mail provider service. By default it is <see cref="ServiceLifetime.Singleton"/>.</param>
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
/// <seealso href="http://www.mimekit.net/"/>
public static IServiceCollection AddMailKitEmailProvider(this IServiceCollection services, Action<SmtpClientOptions> options, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton)
Expand All @@ -55,7 +55,7 @@ public static IServiceCollection AddMailKitEmailProvider(this IServiceCollection
/// <param name="services"> The <see cref="IServiceCollection"/> to add services to.</param>
/// <param name="configuration">The current set of key-value application configuration parameters.</param>
/// <param name="options">Action to configure options for the email provider.</param>
/// <param name="serviceLifetime">The lifetime for the e-mail proider service. By default it is <see cref="ServiceLifetime.Singleton"/>.</param>
/// <param name="serviceLifetime">The lifetime for the e-mail provider service. By default it is <see cref="ServiceLifetime.Singleton"/>.</param>
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
/// <seealso href="http://www.mimekit.net/"/>
public static IServiceCollection AddMailKitEmailProvider(this IServiceCollection services, IConfiguration configuration, Action<SmtpClientOptions> options, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton)
Expand Down
Loading