Skip to content

Commit

Permalink
Compiler errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierjohn committed Nov 22, 2023
1 parent 8cddaa2 commit 0a7e777
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ protected internal ApiVersion(
/// <param name="other">The instance to derive from.</param>
protected ApiVersion( ApiVersion other )
{
#if NETSTANDARD
if ( other == null )
{
throw new ArgumentNullException( nameof( other ) );
}
#else
ArgumentNullException.ThrowIfNull( other );
#endif

hashCode = other.hashCode;
GroupVersion = other.GroupVersion;
Expand Down Expand Up @@ -355,7 +359,8 @@ public virtual string ToString( string? format, IFormatProvider? formatProvider
return status;
}

var message = string.Format( CultureInfo.CurrentCulture, SR.ApiVersionBadStatus, status );
var format = SR.ApiVersionBadStatus;
var message = string.Format( CultureInfo.CurrentCulture, format, status );
throw new ArgumentException( message, nameof( status ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,18 @@ public virtual bool TryParse( Text text, [MaybeNullWhen( false )] out ApiVersion
private static FormatException InvalidFormat() => new( SR.ApiVersionInvalidFormat );

[MethodImpl( MethodImplOptions.AggressiveInlining )]
private static FormatException InvalidGroupVersion( string value ) =>
new( string.Format( CultureInfo.CurrentCulture, SR.ApiVersionBadGroupVersion, value ) );
private static FormatException InvalidGroupVersion( string value )
{
var format = SR.ApiVersionBadStatus;
return new( string.Format( CultureInfo.CurrentCulture, format, value ) );
}

[MethodImpl( MethodImplOptions.AggressiveInlining )]
private static FormatException InvalidStatus( string value ) =>
new( string.Format( CultureInfo.CurrentCulture, SR.ApiVersionBadStatus, value ) );
private static FormatException InvalidStatus( string value )
{
var format = SR.ApiVersionBadStatus;
return new( string.Format( CultureInfo.CurrentCulture, format, value ) );
}

private static bool IsDateLike( Text value )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,14 @@ public static T AdvertisesApiVersions<T>( this T builder, IEnumerable<ApiVersion
public static T AdvertisesDeprecatedApiVersions<T>( this T builder, IEnumerable<ApiVersion> apiVersions )
where T : notnull, IDeclareApiVersionConventionBuilder
{
#if NETSTANDARD
if ( apiVersions == null )
{
throw new ArgumentNullException( nameof( apiVersions ) );
}
#else
ArgumentNullException.ThrowIfNull( apiVersions );
#endif

foreach ( var apiVersion in apiVersions )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public partial class AmbiguousApiVersionException : Exception
/// </summary>
/// <param name="info">The <see cref="SerializationInfo">serialization info</see> the exception is being deserialized with.</param>
/// <param name="context">The <see cref="StreamingContext">streaming context</see> the exception is being deserialized from.</param>
#if NET8_0
[Obsolete( "This API supports obsolete formatter-based serialization. It should not be called or extended by application code." )]
#endif
protected AmbiguousApiVersionException( SerializationInfo info, StreamingContext context )
: base( info, context ) => apiVersions = (string[]) info.GetValue( nameof( apiVersions ), typeof( string[] ) )!;

Expand All @@ -23,6 +26,9 @@ protected AmbiguousApiVersionException( SerializationInfo info, StreamingContext
/// </summary>
/// <param name="info">The <see cref="SerializationInfo">serialization info</see> the exception is being serialized with.</param>
/// <param name="context">The <see cref="StreamingContext">streaming context</see> the exception is being serialized in.</param>
#if NET8_0
[Obsolete( "GetObjectData is obsolete" )]
#endif
public override void GetObjectData( SerializationInfo info, StreamingContext context )
{
base.GetObjectData( info, context );
Expand Down

0 comments on commit 0a7e777

Please sign in to comment.