From a7d3facda840c25f34b7360f63cea9392c7bfcc0 Mon Sep 17 00:00:00 2001 From: Heather Cox Date: Mon, 11 Mar 2024 13:20:53 +1100 Subject: [PATCH 1/4] undo our changes to GetBoundingClientRect --- src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs index 0a9a7f96b..459456863 100644 --- a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs +++ b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs @@ -8,16 +8,9 @@ namespace Blazor.Diagrams.Extensions; public static class JSRuntimeExtensions { - public static async Task GetBoundingClientRect(this IJSRuntime jsRuntime, ElementReference element) + public static async Task GetBoundingClientRect(this IJSRuntime jsRuntime, ElementReference element) { - try - { - return await jsRuntime.InvokeAsync("ZBlazorDiagrams.getBoundingClientRect", element); - } - catch (TaskCanceledException) - { - return null; - } + return await jsRuntime.InvokeAsync("ZBlazorDiagrams.getBoundingClientRect", element); } public static async Task ObserveResizes(this IJSRuntime jsRuntime, ElementReference element, From ea9d86bbbdd7f799c5f19333a700c83e8e329196 Mon Sep 17 00:00:00 2001 From: Heather Cox Date: Mon, 11 Mar 2024 13:22:34 +1100 Subject: [PATCH 2/4] pass CancellationToken.None to jsRuntime.InvokeAsync --- src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs index 459456863..0e6cd2c70 100644 --- a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs +++ b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; using Blazor.Diagrams.Core.Geometry; using Microsoft.AspNetCore.Components; @@ -10,7 +11,7 @@ public static class JSRuntimeExtensions { public static async Task GetBoundingClientRect(this IJSRuntime jsRuntime, ElementReference element) { - return await jsRuntime.InvokeAsync("ZBlazorDiagrams.getBoundingClientRect", element); + return await jsRuntime.InvokeAsync("ZBlazorDiagrams.getBoundingClientRect", CancellationToken.None, element); } public static async Task ObserveResizes(this IJSRuntime jsRuntime, ElementReference element, From 37dddd93002aba52fb510a6a4995bb2d730a9249 Mon Sep 17 00:00:00 2001 From: Heather Cox Date: Wed, 3 Apr 2024 12:27:00 +1100 Subject: [PATCH 3/4] remove test, remove cancellation token --- .../Extensions/JSRuntimeExtensions.cs | 2 +- .../Extensions/JSRuntimeExtensionsTest.cs | 21 ------------------- 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 tests/Blazor.Diagrams.Tests/Extensions/JSRuntimeExtensionsTest.cs diff --git a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs index 0e6cd2c70..cdd43bdba 100644 --- a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs +++ b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs @@ -11,7 +11,7 @@ public static class JSRuntimeExtensions { public static async Task GetBoundingClientRect(this IJSRuntime jsRuntime, ElementReference element) { - return await jsRuntime.InvokeAsync("ZBlazorDiagrams.getBoundingClientRect", CancellationToken.None, element); + return await jsRuntime.InvokeAsync("ZBlazorDiagrams.getBoundingClientRect", element); } public static async Task ObserveResizes(this IJSRuntime jsRuntime, ElementReference element, diff --git a/tests/Blazor.Diagrams.Tests/Extensions/JSRuntimeExtensionsTest.cs b/tests/Blazor.Diagrams.Tests/Extensions/JSRuntimeExtensionsTest.cs deleted file mode 100644 index bd2596fe1..000000000 --- a/tests/Blazor.Diagrams.Tests/Extensions/JSRuntimeExtensionsTest.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Blazor.Diagrams.Core.Geometry; -using Microsoft.JSInterop; -using Moq; -using System.Threading.Tasks; -using Xunit; -using JSRuntimeExtensions = Blazor.Diagrams.Extensions.JSRuntimeExtensions; - -namespace Blazor.Diagrams.Tests.Extensions -{ - public class JSRuntimeExtensionsTest - { - [Fact] - public async Task TestGetBoundingClientRectDoesNotThrowOnTimeout() - { - var jsRuntime = new Mock(); - jsRuntime.Setup(j => j.InvokeAsync(It.IsAny(), It.IsAny())).ThrowsAsync(new TaskCanceledException()); - var result = await JSRuntimeExtensions.GetBoundingClientRect(jsRuntime.Object, default); - Assert.Null(result); - } - } -} From 8185b3718fb3b37872fc33193ee72dfb8073469c Mon Sep 17 00:00:00 2001 From: Heather Cox Date: Wed, 3 Apr 2024 13:26:35 +1100 Subject: [PATCH 4/4] remove using --- src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs index cdd43bdba..459456863 100644 --- a/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs +++ b/src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs @@ -1,5 +1,4 @@ using System; -using System.Threading; using System.Threading.Tasks; using Blazor.Diagrams.Core.Geometry; using Microsoft.AspNetCore.Components;