Browse Source
Merge pull request #1333 from SixLabors/sp/guard-codegen-improvement
Improved codegen in ImageSharp.Guard
pull/1337/head
James Jackson-South
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
10 additions and
2 deletions
-
src/ImageSharp/Common/Helpers/Guard.cs
|
|
|
@ -2,7 +2,9 @@ |
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
#if NETSTANDARD1_3
|
|
|
|
using System.Reflection; |
|
|
|
#endif
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using SixLabors.ImageSharp; |
|
|
|
|
|
|
|
@ -20,10 +22,16 @@ namespace SixLabors |
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public static void MustBeValueType<TValue>(TValue value, string parameterName) |
|
|
|
{ |
|
|
|
if (!value.GetType().GetTypeInfo().IsValueType) |
|
|
|
if (value.GetType() |
|
|
|
#if NETSTANDARD1_3
|
|
|
|
.GetTypeInfo() |
|
|
|
#endif
|
|
|
|
.IsValueType) |
|
|
|
{ |
|
|
|
ThrowHelper.ThrowArgumentException("Type must be a struct.", parameterName); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ThrowHelper.ThrowArgumentException("Type must be a struct.", parameterName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|