Skip to content

Commit e740fb6

Browse files
committed
Improved Guard.MustBeValueType<T> codegen
Can now be JITted to a constant on .NET 5, see dotnet/runtime#1157
1 parent 53ddb0f commit e740fb6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/ImageSharp/Common/Helpers/Guard.cs

Lines changed: 7 additions & 1 deletion
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,7 +22,11 @@ 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
{
2531
return;
2632
}

0 commit comments

Comments
 (0)