throw better error for missing InvokeAsync
MODIFY
src/Directory.Build.props
src/Directory.Build.props
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
- <Version>4.3.1</Version>
+ <Version>4.3.2</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Clipboard, Copy</PackageTags>
<Description>A cross platform package to copy text to the clipboard.</Description>

MODIFY
src/TextCopy/BlazorClipboard.cs
src/TextCopy/BlazorClipboard.cs
@@ -25,11 +25,14 @@ namespace TextCopy
public BlazorClipboard(object jsRuntime)
{
this.jsRuntime = jsRuntime;
- invokeAsync = jsRuntime.GetType()
- .GetMethod(
- "InvokeAsync",
- types: types)!;
- invokeAsync = invokeAsync.MakeGenericMethod(typeof(string));
+ var type = jsRuntime.GetType();
+ var method = type.GetMethod("InvokeAsync", types);
+ if (method == null)
+ {
+ throw new($"Unable to find InvokeAsync on {type.FullName}");
+ }
+
+ invokeAsync = method.MakeGenericMethod(typeof(string));
}
/// <inheritdoc />

throw better error for missing InvokeAsync