Skip to content

Commit a7e8bfc

Browse files
committed
fix: NRE with null returning function
1 parent d3e8c18 commit a7e8bfc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

code/src/NFluent/Extensions/ObjectExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ public static bool IsAwaitable<T>(this T instance, out Action waiter)
6969
waiter = () => ta.Wait();
7070
return true;
7171
}
72-
var awaiter= instance.GetType().GetMethod("GetAwaiter")?.ReturnType;
73-
if (awaiter != null
74-
&& awaiter.GetInterface("System.Runtime.CompilerServices.INotifyCompletion") != null
72+
var awaiter= instance?.GetType().GetMethod("GetAwaiter")?.ReturnType;
73+
if (awaiter?.GetInterface("System.Runtime.CompilerServices.INotifyCompletion") != null
7574
&& awaiter.GetProperty("IsCompleted")?.PropertyType != typeof(bool)
7675
&& awaiter.GetMethod("GetResult", Array.Empty<Type>())!=null)
7776
{

0 commit comments

Comments
 (0)