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.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.JSInterop
|
namespace Microsoft.JSInterop
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -15,6 +17,11 @@ namespace Microsoft.JSInterop
|
||||||
/// <returns>An instance of <see cref="DotNetObjectReference{TValue}" />.</returns>
|
/// <returns>An instance of <see cref="DotNetObjectReference{TValue}" />.</returns>
|
||||||
public static DotNetObjectReference<TValue> Create<TValue>(TValue value) where TValue : class
|
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);
|
return new DotNetObjectReference<TValue>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue