Skip to content

Commit 5114f2f

Browse files
authored
Add null check for DotNetObjectReference (dotnet/extensions#2372)
\n\nCommit migrated from dotnet/extensions@45776ac
1 parent ddde4fa commit 5114f2f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/JSInterop/Microsoft.JSInterop/src/DotNetObjectReference.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
5+
46
namespace Microsoft.JSInterop
57
{
68
/// <summary>
@@ -15,6 +17,11 @@ public static class DotNetObjectReference
1517
/// <returns>An instance of <see cref="DotNetObjectReference{TValue}" />.</returns>
1618
public static DotNetObjectReference<TValue> Create<TValue>(TValue value) where TValue : class
1719
{
20+
if (value is null)
21+
{
22+
throw new ArgumentNullException(nameof(value));
23+
}
24+
1825
return new DotNetObjectReference<TValue>(value);
1926
}
2027
}

0 commit comments

Comments
 (0)