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 warnings CS8603 and CS8625 in Encamina.Enmarcha.AspNet #112

Merged
merged 9 commits into from
May 2, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Previous classification is not required if changes are simple or all belong to t
- Added `RequiredIfAttribute` to validate properties based on the value of another property.
- Fixed warnings CS8603 and CS8025 in:
- `Encamina.Enmarcha.AI`.
- `Encamina.Enmarcha.AspNet`

## [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.6</VersionPrefix>
<VersionSuffix>preview-07</VersionSuffix>
<VersionSuffix>preview-08</VersionSuffix>
</PropertyGroup>

<!--
Expand Down
2 changes: 1 addition & 1 deletion src/Encamina.Enmarcha.AI.OpenAI.Abstractions/ModelInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ public sealed class ModelInfo
/// </summary>
/// <param name="id">The model's unique identifier. For example <c>text-embedding-ada-002</c> or <c>gpt-4</c>.</param>
/// <returns>A models information from the given unique identifier, or <see langword="null"/> if it is not found.</returns>
public static ModelInfo GetById(string id) => ModelInfoById.TryGetValue(id, out var modelInfo) ? modelInfo : null;
public static ModelInfo? GetById(string id) => ModelInfoById.TryGetValue(id, out var modelInfo) ? modelInfo : null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ private async Task<object> ReadStreamAsync(Type type, Stream stream)
return array;
}

return list;
return list!;
}
}
2 changes: 1 addition & 1 deletion src/Encamina.Enmarcha.AspNet.Mvc.Formatters/Csv/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static string GetDisplayName(PropertyInfo property)
return string.IsNullOrWhiteSpace(attrName) ? property.Name : attrName;
}

internal static string GetAttributeDisplayName(PropertyInfo property)
internal static string? GetAttributeDisplayName(PropertyInfo property)
{
var atts = property.GetCustomAttributes(typeof(DisplayNameAttribute), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static IMvcBuilder AddPdfOutputFormatter(this IMvcBuilder builder)
return builder;
}

private static IMvcBuilder AddCsvFormatters(IMvcBuilder builder, CsvFormatterOptions csvFormatterOptions, bool addInputFormater, bool addOutputFormater)
private static IMvcBuilder AddCsvFormatters(IMvcBuilder builder, CsvFormatterOptions? csvFormatterOptions, bool addInputFormater, bool addOutputFormater)
{
Guard.IsNotNull(builder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
return Task.CompletedTask;
}

private static DateTime? ParseDateTime(string dateToParse, string[] formats = null)
private static DateTime? ParseDateTime(string dateToParse, string[]? formats = null)
{
if (formats == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CustomDateTimeModelBinderProvider : IModelBinderProvider
/// <summary>
/// Initializes a new instance of the <see cref="CustomDateTimeModelBinderProvider"/> class.
/// </summary>
public CustomDateTimeModelBinderProvider() : this(null)
public CustomDateTimeModelBinderProvider() : this(null!)
HugoRamosEs marked this conversation as resolved.
Show resolved Hide resolved
{
}

Expand All @@ -27,10 +27,10 @@ public CustomDateTimeModelBinderProvider(string customDateTimeFormat)
}

/// <inheritdoc/>
public virtual IModelBinder GetBinder(ModelBinderProviderContext context)
public virtual IModelBinder? GetBinder(ModelBinderProviderContext context)
{
return CustomDateTimeModelBinder.SupportedDateTimeTypes.Contains(context.Metadata.ModelType)
? new CustomDateTimeModelBinder(customDateTimeFormat)
: (IModelBinder)null;
: (IModelBinder?)null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static IMvcBuilder AddApiKeyAuthorizationFilter(this IMvcBuilder builder)
return builder.AddApiKeyAuthorizationFilter(setupOptions: null);
}

private static IMvcBuilder AddApiKeyAuthorizationFilter(this IMvcBuilder builder, Action<Options.OptionsBuilder<ApiKeyAuthorizationFilterOptions>> setupOptions)
private static IMvcBuilder AddApiKeyAuthorizationFilter(this IMvcBuilder builder, Action<Options.OptionsBuilder<ApiKeyAuthorizationFilterOptions>>? setupOptions)
{
var options = builder.Services.AddOptions<ApiKeyAuthorizationFilterOptions>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
context.Result = new UnauthorizedResult();
}

private static string GetApiKeyName(ActionDescriptor descriptor)
private static string? GetApiKeyName(ActionDescriptor descriptor)
{
return descriptor is ControllerActionDescriptor controllerActionDescriptor
? GetApiKeyName(controllerActionDescriptor.MethodInfo) ?? GetApiKeyName(controllerActionDescriptor.ControllerTypeInfo)
: null;
}

private static string GetApiKeyName(MemberInfo memberInfo)
private static string? GetApiKeyName(MemberInfo memberInfo)
{
return memberInfo?.GetCustomAttribute<ApiKeyAttribute>(true)?.ApiKeyName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static IServiceCollection AddVersionSwaggerGenConfigureOptions(this IServ
return services.AddVersionSwaggerGenConfigureOptions(setupOptions: null);
}

private static IServiceCollection AddVersionSwaggerGenConfigureOptions(this IServiceCollection services, Action<OptionsBuilder<VersionSwaggerGenOptions>> setupOptions)
private static IServiceCollection AddVersionSwaggerGenConfigureOptions(this IServiceCollection services, Action<OptionsBuilder<VersionSwaggerGenOptions>>? setupOptions)
{
var options = services.AddOptions<VersionSwaggerGenOptions>();

Expand Down
Loading