Skip to content

Commit fd05204

Browse files
Merge pull request #1333 from SixLabors/sp/guard-codegen-improvement
Improved codegen in ImageSharp.Guard
2 parents ade5ba5 + e7e4c8d commit fd05204

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ImageSharp/Common/Helpers/Guard.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
5+
#if NETSTANDARD1_3
56
using System.Reflection;
7+
#endif
68
using System.Runtime.CompilerServices;
79
using SixLabors.ImageSharp;
810

@@ -20,10 +22,16 @@ internal static partial class Guard
2022
[MethodImpl(InliningOptions.ShortMethod)]
2123
public static void MustBeValueType<TValue>(TValue value, string parameterName)
2224
{
23-
if (!value.GetType().GetTypeInfo().IsValueType)
25+
if (value.GetType()
26+
#if NETSTANDARD1_3
27+
.GetTypeInfo()
28+
#endif
29+
.IsValueType)
2430
{
25-
ThrowHelper.ThrowArgumentException("Type must be a struct.", parameterName);
31+
return;
2632
}
33+
34+
ThrowHelper.ThrowArgumentException("Type must be a struct.", parameterName);
2735
}
2836
}
2937
}

0 commit comments

Comments
 (0)