-
-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #855 from SmRiley/release/6.x
Use NullabilityInfoContext to replace Type's nullable detection in release 6.x
- Loading branch information
Showing
3 changed files
with
10 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
using System.Reflection; | ||
using System.Reflection; | ||
|
||
namespace MagicOnion; | ||
|
||
internal static class Utils | ||
{ | ||
private static readonly NullabilityInfoContext nullabilityInfoContext = new(); | ||
public static bool IsNullable(this ParameterInfo type) | ||
{ | ||
return nullabilityInfoContext.Create(type).WriteState == NullabilityState.Nullable; | ||
} | ||
|
||
public static bool IsNullable(this Type type) | ||
{ | ||
return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); | ||
} | ||
} | ||
} |