Add null check for DotNetObjectReference (dotnet/extensions#2372)
\n\nCommit migrated from 45776ac25c
This commit is contained in:
parent
ddde4faf4f
commit
5114f2f1a2
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.JSInterop
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -15,6 +17,11 @@ namespace Microsoft.JSInterop
|
|||
/// <returns>An instance of <see cref="DotNetObjectReference{TValue}" />.</returns>
|
||||
public static DotNetObjectReference<TValue> Create<TValue>(TValue value) where TValue : class
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
return new DotNetObjectReference<TValue>(value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue