diff --git a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.Approve_Public_Api.DotNet8_0.verified.txt b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.Approve_Public_Api.DotNet8_0.verified.txt
index 361a05d0b..63bdf7959 100644
--- a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.Approve_Public_Api.DotNet8_0.verified.txt
+++ b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.Approve_Public_Api.DotNet8_0.verified.txt
@@ -246,6 +246,8 @@ namespace Humanizer
}
public static class EnumDehumanizeExtensions
{
+ [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for the target enumeration might not be available at runtime.")]
+ [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The native code for the target enumeration might not be available at runtime.")]
public static System.Enum DehumanizeTo(this string input, System.Type targetEnum, Humanizer.OnNoMatch onNoMatch = 0) { }
public static TTargetEnum DehumanizeTo<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] TTargetEnum>(this string input)
where TTargetEnum : struct, System.Enum { }
diff --git a/src/Humanizer/EnumDehumanizeExtensions.cs b/src/Humanizer/EnumDehumanizeExtensions.cs
index f0dc79655..eceef2be3 100644
--- a/src/Humanizer/EnumDehumanizeExtensions.cs
+++ b/src/Humanizer/EnumDehumanizeExtensions.cs
@@ -38,6 +38,10 @@ public static class EnumDehumanizeExtensions
/// What to do when input is not matched to the enum.
/// Couldn't find any enum member that matches the string
/// If targetEnum is not an enum
+#if NET6_0_OR_GREATER
+ [RequiresDynamicCode("The native code for the target enumeration might not be available at runtime.")]
+ [RequiresUnreferencedCode("The native code for the target enumeration might not be available at runtime.")]
+#endif
public static Enum DehumanizeTo(this string input, Type targetEnum, OnNoMatch onNoMatch = OnNoMatch.ThrowsException)
{
var genericMethod = dehumanizeToMethod.MakeGenericMethod(targetEnum);
diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj
index 9db12b5a9..58fb6b2af 100644
--- a/src/Humanizer/Humanizer.csproj
+++ b/src/Humanizer/Humanizer.csproj
@@ -15,6 +15,9 @@
0024000004800000940000000602000000240000525341310004000001000100F9104F5F9BDB168AE140366EB1CD84C469B020EA3423D5D29996D5214CE2BD9B7C0BA3EAD1CA545C4399668AB8911E61CC1CC83C7DF6D50FD6B781365B467E65173F40A11C957D27C5AA0CB0F8DA9C91C988203CC8AEF1468C74A472839D0FD870DA8D13A4DC6B3AAFDAF0384D8E18E393C613D88BF02A64467A119902204FCC
true
+
+ true
+
diff --git a/src/Humanizer/TimeSpanHumanizeExtensions.cs b/src/Humanizer/TimeSpanHumanizeExtensions.cs
index 7919366af..b8bdd316f 100644
--- a/src/Humanizer/TimeSpanHumanizeExtensions.cs
+++ b/src/Humanizer/TimeSpanHumanizeExtensions.cs
@@ -10,8 +10,12 @@ public static class TimeSpanHumanizeExtensions
const double _daysInAMonth = _daysInAYear / 12;
static readonly TimeUnit[] _timeUnits = Enum
+#if NET6_0_OR_GREATER
+ .GetValues()
+#else
.GetValues(typeof(TimeUnit))
.Cast()
+#endif
.Reverse()
.ToArray();
@@ -214,4 +218,4 @@ static string ConcatenateTimeSpanParts(IEnumerable timeSpanParts, Cultu
return string.Join(collectionSeparator, timeSpanParts);
}
-}
\ No newline at end of file
+}