Skip to content

Commit df62efb

Browse files
Fix code analysis
1 parent cebe58e commit df62efb

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Common/ApiVersion.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public override int GetHashCode()
393393
/// <param name="version2">The <see cref="ApiVersion"/> to compare against.</param>
394394
/// <returns>True if the objects are not equal; otherwise, false.</returns>
395395
public static bool operator !=( ApiVersion? version1, ApiVersion? version2 ) =>
396-
version1 is null ? version2 is object : !version1.Equals( version2 );
396+
version1 is null ? version2 is not null : !version1.Equals( version2 );
397397

398398
/// <summary>
399399
/// Overloads the less than operator.
@@ -402,7 +402,7 @@ public override int GetHashCode()
402402
/// <param name="version2">The <see cref="ApiVersion"/> to compare against.</param>
403403
/// <returns>True the first object is less than the second object; otherwise, false.</returns>
404404
public static bool operator <( ApiVersion? version1, ApiVersion? version2 ) =>
405-
version1 is null ? version2 is object : version1.CompareTo( version2 ) < 0;
405+
version1 is null ? version2 is not null : version1.CompareTo( version2 ) < 0;
406406

407407
/// <summary>
408408
/// Overloads the less than or equal to operator.

src/Microsoft.AspNetCore.Mvc.Versioning/Routing/ApiVersionMatcherPolicy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ bool IsRequestedApiVersionAmbiguous( HttpContext httpContext, out ApiVersion? ap
192192
}
193193
catch ( AmbiguousApiVersionException ex )
194194
{
195-
Logger.LogInformation( ex.Message );
195+
Logger.ApiVersionAmbiguous( ex );
196196
apiVersion = default;
197197

198-
var handlerContext = new RequestHandlerContext( Options.ErrorResponses )
198+
var handlerContext = new RequestHandlerContext( Options.ErrorResponses, ApiVersionReporter )
199199
{
200200
Code = AmbiguousApiVersion,
201201
Message = ex.Message,

src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ILoggerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal static void ConstraintMismatch( this ILogger logger, string actionName,
5151
internal static void ApiVersionAmbiguous( this ILogger logger, string[]? apiVersions ) => apiVersionAmbiguous( logger, apiVersions, null );
5252

5353
internal static void ApiVersionAmbiguous( this ILogger logger, AmbiguousApiVersionException exception ) =>
54-
logger.ApiVersionAmbiguous( exception.ApiVersions.Select( v => v.ToString() ).ToArray() );
54+
logger.ApiVersionAmbiguous( exception.ApiVersions.ToArray() );
5555

5656
internal static void NoActionsMatched( this ILogger logger, IDictionary<string, object?> routeValueDictionary )
5757
{

0 commit comments

Comments
 (0)