Add null check for DotNetObjectReference (dotnet/extensions#2372)

\n\nCommit migrated from 45776ac25c
This commit is contained in:
Pranav K 2019-09-23 09:42:48 -07:00 committed by GitHub
parent ddde4faf4f
commit 5114f2f1a2
1 changed files with 7 additions and 0 deletions

View File

@ -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);
}
}