From 1e9a75fb804e693d9fe0f7d4fd979396beb55bb7 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 10 Mar 2026 17:04:30 +0000
Subject: [PATCH 1/2] Initial plan
From 3708bc9209ef6be9df64cc5874b753472b9a6c06 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 10 Mar 2026 17:10:14 +0000
Subject: [PATCH 2/2] Remove unused _sourceShapes field from DrawingManager to
reduce memory overhead
Co-authored-by: arnaudleclerc <9578038+arnaudleclerc@users.noreply.github.com>
---
.../Drawing/DrawingManager.cs | 13 --------
.../Drawing/DrawingManager.cs | 32 ++-----------------
2 files changed, 2 insertions(+), 43 deletions(-)
diff --git a/src/AzureMapsControl.Components/Drawing/DrawingManager.cs b/src/AzureMapsControl.Components/Drawing/DrawingManager.cs
index 1fe6879..f94b719 100644
--- a/src/AzureMapsControl.Components/Drawing/DrawingManager.cs
+++ b/src/AzureMapsControl.Components/Drawing/DrawingManager.cs
@@ -20,11 +20,6 @@ public sealed class DrawingManager
internal ILogger Logger { get; set; }
public bool Disposed { get; private set; }
- ///
- /// List of shapes added to the data source
- ///
- private List _sourceShapes;
-
///
/// Add shapes to the drawing manager data source
///
@@ -42,11 +37,6 @@ public async ValueTask AddShapesAsync(IEnumerable shapes)
EnsureJsRuntimeExists();
EnsureNotDisposed();
- if (_sourceShapes == null)
- {
- _sourceShapes = new List();
- }
-
var lineStrings = shapes.OfType>();
if (lineStrings.Any())
{
@@ -95,8 +85,6 @@ public async ValueTask AddShapesAsync(IEnumerable shapes)
Logger?.LogAzureMapsControlDebug(AzureMapLogEvent.Source_AddAsync, $"{routePoints.Count()} route points will be added");
await JSRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Source.AddShapes.ToDrawingNamespace(), routePoints);
}
-
- _sourceShapes.AddRange(shapes);
}
///
@@ -112,7 +100,6 @@ public async ValueTask ClearAsync()
EnsureJsRuntimeExists();
EnsureNotDisposed();
- _sourceShapes = null;
await JSRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Source.Clear.ToDrawingNamespace());
}
diff --git a/tests/AzureMapsControl.Components.Tests/Drawing/DrawingManager.cs b/tests/AzureMapsControl.Components.Tests/Drawing/DrawingManager.cs
index f6eab30..3eaccf9 100644
--- a/tests/AzureMapsControl.Components.Tests/Drawing/DrawingManager.cs
+++ b/tests/AzureMapsControl.Components.Tests/Drawing/DrawingManager.cs
@@ -2,7 +2,6 @@
{
using System.Collections.Generic;
using System.Linq;
- using System.Reflection;
using System.Threading.Tasks;
using AzureMapsControl.Components.Atlas;
@@ -176,13 +175,6 @@ public async Task Should_AccumulateShapes_InInternalState_Async()
await drawingManager.AddShapesAsync(secondBatch);
await drawingManager.AddShapesAsync(thirdBatch);
- // Verify internal state accumulates all shapes
- var sourceShapes = GetInternalSourceShapes(drawingManager);
- Assert.Equal(3, sourceShapes.Count);
- Assert.Contains(firstBatch[0], sourceShapes);
- Assert.Contains(secondBatch[0], sourceShapes);
- Assert.Contains(thirdBatch[0], sourceShapes);
-
// Verify correct number of JS calls
_jsRuntimeMock.Verify(runtime => runtime.InvokeVoidAsync(
Constants.JsConstants.Methods.Source.AddShapes.ToDrawingNamespace(),
@@ -195,22 +187,12 @@ public async Task Should_ClearInternalState_WhenCleared_Async()
var drawingManager = CreateInitializedDrawingManager();
var shapes = new List { new Shape(new Point()) };
- // Add shapes to initialize and populate internal state
+ // Add shapes then clear
await drawingManager.AddShapesAsync(shapes);
- var sourceShapes = GetInternalSourceShapes(drawingManager);
- Assert.NotNull(sourceShapes);
- Assert.Single(sourceShapes);
-
- // Clear should reset internal state
await drawingManager.ClearAsync();
- sourceShapes = GetInternalSourceShapes(drawingManager);
- Assert.Null(sourceShapes);
- // Adding again should reinitialize state
+ // Adding again should work without errors
await drawingManager.AddShapesAsync(shapes);
- sourceShapes = GetInternalSourceShapes(drawingManager);
- Assert.NotNull(sourceShapes);
- Assert.Single(sourceShapes);
_jsRuntimeMock.Verify(runtime => runtime.InvokeVoidAsync(Constants.JsConstants.Methods.Source.AddShapes.ToDrawingNamespace(), It.IsAny