Skip to content

Commit

Permalink
Merge pull request #119 from Encamina/@hramos/FixWarnings/Encamina.En…
Browse files Browse the repository at this point in the history
…marcha.Email

Fixed some warnings in Encamina.Enmarcha.Email
  • Loading branch information
HugoRamosEs authored Jun 6, 2024
2 parents 52c0140 + 50ee4ac commit 66a2aec
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 21 deletions.
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
1 change: 1 addition & 0 deletions src/Encamina.Enmarcha.AI.OpenAI.Abstractions/ModelInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed class ModelInfo
{ @"gpt-4", new ModelInfo() { Id = @"gpt-4", MaxTokens = 8192, Encoding = @"cl100k_base", IsObsolete = false } },
{ @"gpt-4-32k", new ModelInfo() { Id = @"gpt-4", MaxTokens = 32768, Encoding = @"cl100k_base", IsObsolete = false } },
{ @"gpt-4-turbo", new ModelInfo() { Id = @"gpt-4", MaxTokens = 128000, Encoding = @"cl100k_base", IsObsolete = false } },
{ @"gpt-4o", new ModelInfo() { Id = @"gpt-4o", MaxTokens = 128000, Encoding = @"o200k_base", IsObsolete = false } },
{ @"text-davinci-001", new ModelInfo() { Id = @"text-davinci-001", MaxTokens = 2049, Encoding = @"r50k_base", IsObsolete = true } },
{ @"text-davinci-002", new ModelInfo() { Id = @"text-davinci-002", MaxTokens = 4097, Encoding = @"p50k_base", IsObsolete = true } },
{ @"text-davinci-003", new ModelInfo() { Id = @"text-davinci-003", MaxTokens = 4097, Encoding = @"p50k_base", IsObsolete = true } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class EmailAttachmentSpecification
/// <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
10 changes: 5 additions & 5 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 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

0 comments on commit 66a2aec

Please sign in to comment.