Skip to content

Commit 90eddde

Browse files
committed
Apply performances recommendations
1 parent 094b8ae commit 90eddde

20 files changed

+165
-257
lines changed

src/AzureMapsControl.Components/Animations/AnimationService.cs

Lines changed: 96 additions & 106 deletions
Large diffs are not rendered by default.

src/AzureMapsControl.Components/Data/DataSourceEventArgs.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace AzureMapsControl.Components.Data;
88
[ExcludeFromCodeCoverage]
9-
internal class DataSourceEventArgs
9+
internal record DataSourceEventArgs
1010
{
11-
public string Id { get; set; }
12-
public IEnumerable<Shape<Geometry>> Shapes { get; set; }
13-
public string Type { get; set; }
11+
public string Id { get; init; }
12+
public IEnumerable<Shape<Geometry>> Shapes { get; init; }
13+
public string Type { get; init; }
1414
}

src/AzureMapsControl.Components/Data/DataSourceEventInvokeHelper.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,4 @@
55
using AzureMapsControl.Components.Events;
66

77
namespace AzureMapsControl.Components.Data;
8-
internal class DataSourceEventInvokeHelper : EventInvokeHelper<DataSourceEventArgs>
9-
{
10-
public DataSourceEventInvokeHelper(Func<DataSourceEventArgs, ValueTask> callback) : base(callback)
11-
{
12-
}
13-
}
8+
internal sealed class DataSourceEventInvokeHelper(Func<DataSourceEventArgs, ValueTask> callback) : EventInvokeHelper<DataSourceEventArgs>(callback);

src/AzureMapsControl.Components/Drawing/DrawingToolbarEventInvokeHelper.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@
77

88
namespace AzureMapsControl.Components.Drawing;
99
[ExcludeFromCodeCoverage]
10-
internal class DrawingToolbarEventInvokeHelper : EventInvokeHelper<DrawingToolbarJsEventArgs>
11-
{
12-
public DrawingToolbarEventInvokeHelper(Func<DrawingToolbarJsEventArgs, ValueTask> callback) : base(callback) { }
13-
}
10+
internal sealed class DrawingToolbarEventInvokeHelper(Func<DrawingToolbarJsEventArgs, ValueTask> callback) : EventInvokeHelper<DrawingToolbarJsEventArgs>(callback);

src/AzureMapsControl.Components/Drawing/DrawingToolbarJsEventArgs.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace AzureMapsControl.Components.Drawing;
77
[ExcludeFromCodeCoverage]
8-
internal class DrawingToolbarJsEventArgs
8+
internal record DrawingToolbarJsEventArgs
99
{
10-
public string Type { get; set; }
11-
public string NewMode { get; set; }
12-
public Feature<Geometry> Data { get; set; }
10+
public string Type { get; init; }
11+
public string NewMode { get; init; }
12+
public Feature<Geometry> Data { get; init; }
1313
}

src/AzureMapsControl.Components/FullScreen/FullScreenEventInvokeHelper.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,4 @@
55
using AzureMapsControl.Components.Events;
66

77
namespace AzureMapsControl.Components.FullScreen;
8-
internal class FullScreenEventInvokeHelper : EventInvokeHelper<bool>
9-
{
10-
public FullScreenEventInvokeHelper(Func<bool, ValueTask> callback) : base(callback)
11-
{
12-
}
13-
}
8+
internal sealed class FullScreenEventInvokeHelper(Func<bool, ValueTask> callback) : EventInvokeHelper<bool>(callback);

src/AzureMapsControl.Components/FullScreen/FullScreenService.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@
77
using Microsoft.Extensions.Logging;
88

99
namespace AzureMapsControl.Components.FullScreen;
10-
internal class FullScreenService : IFullScreenService
10+
internal sealed class FullScreenService(IMapJsRuntime jsRuntime, ILogger<FullScreenService> logger) : IFullScreenService
1111
{
12-
private readonly IMapJsRuntime _jsRuntime;
13-
private readonly ILogger<FullScreenService> _logger;
14-
15-
public FullScreenService(IMapJsRuntime jsRuntime, ILogger<FullScreenService> logger)
16-
{
17-
_jsRuntime = jsRuntime;
18-
_logger = logger;
19-
}
20-
2112
public async ValueTask<bool> IsSupportedAsync()
2213
{
23-
_logger?.LogAzureMapsControlInfo(AzureMapLogEvent.FullScreenService_IsFullScreenSupportedAsync, "FullScreenService - IsSupportedAsync");
24-
return await _jsRuntime.InvokeAsync<bool>(Constants.JsConstants.Methods.FullScreenControl.IsFullScreenSupported.ToFullScreenControlNamespace()).ConfigureAwait(false);
14+
logger?.LogAzureMapsControlInfo(AzureMapLogEvent.FullScreenService_IsFullScreenSupportedAsync, "FullScreenService - IsSupportedAsync");
15+
return await jsRuntime.InvokeAsync<bool>(Constants.JsConstants.Methods.FullScreenControl.IsFullScreenSupported.ToFullScreenControlNamespace()).ConfigureAwait(false);
2516
}
2617
}

src/AzureMapsControl.Components/Geolocation/GeolocationEventInvokeHelper.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,4 @@
55
using AzureMapsControl.Components.Events;
66

77
namespace AzureMapsControl.Components.Geolocation;
8-
internal class GeolocationEventInvokeHelper : EventInvokeHelper<GeolocationJsEventArgs>
9-
{
10-
public GeolocationEventInvokeHelper(Func<GeolocationJsEventArgs, ValueTask> callback) : base(callback)
11-
{
12-
}
13-
}
8+
internal sealed class GeolocationEventInvokeHelper(Func<GeolocationJsEventArgs, ValueTask> callback) : EventInvokeHelper<GeolocationJsEventArgs>(callback);

src/AzureMapsControl.Components/Geolocation/GeolocationJsEventArgs.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
namespace AzureMapsControl.Components.Geolocation;
77
[ExcludeFromCodeCoverage]
8-
internal class GeolocationJsEventArgs
8+
internal record GeolocationJsEventArgs
99
{
10-
public int? Code { get; set; }
11-
public string Message { get; set; }
12-
public Feature<Point> Feature { get; set; }
13-
public string Type { get; set; }
10+
public int? Code { get; init; }
11+
public string Message { get; init; }
12+
public Feature<Point> Feature { get; init; }
13+
public string Type { get; init; }
1414
}

src/AzureMapsControl.Components/Geolocation/GeolocationService.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,15 @@
77
using Microsoft.Extensions.Logging;
88

99
namespace AzureMapsControl.Components.Geolocation;
10-
internal class GeolocationService : IGeolocationService
10+
internal sealed class GeolocationService(IMapJsRuntime mapJsRuntime, ILogger<GeolocationService> logger) : IGeolocationService
1111
{
12-
private readonly IMapJsRuntime _mapJsRuntime;
13-
private readonly ILogger<GeolocationService> _logger;
14-
15-
public GeolocationService(IMapJsRuntime mapJsRuntime, ILogger<GeolocationService> logger)
16-
{
17-
_mapJsRuntime = mapJsRuntime;
18-
_logger = logger;
19-
}
20-
2112
/// <summary>
2213
/// Checks to see if the geolocation API is supported in the browser.
2314
/// </summary>
2415
/// <returns>True if the geolocation API is supported in the browser, otherwise false</returns>
2516
public async ValueTask<bool> IsGeolocationSupportedAsync()
2617
{
27-
_logger?.LogAzureMapsControlInfo(AzureMapLogEvent.GeolocationService_IsGeolocationSupportedAsync, "GeolocationService - IsGeolocationSupportedAsync");
28-
return await _mapJsRuntime.InvokeAsync<bool>(Constants.JsConstants.Methods.GeolocationControl.IsGeolocationSupported.ToGeolocationControlNamespace()).ConfigureAwait(false);
18+
logger?.LogAzureMapsControlInfo(AzureMapLogEvent.GeolocationService_IsGeolocationSupportedAsync, "GeolocationService - IsGeolocationSupportedAsync");
19+
return await mapJsRuntime.InvokeAsync<bool>(Constants.JsConstants.Methods.GeolocationControl.IsGeolocationSupported.ToGeolocationControlNamespace()).ConfigureAwait(false);
2920
}
3021
}

0 commit comments

Comments
 (0)