From 3e64f2014e7cd1293a375c2ee3d0c1652ff522c4 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 1 Apr 2021 16:36:14 -0500 Subject: [PATCH 1/2] Change Router _emptyParametersDictionary to a regular Dictionary This allows for ReadOnlyDictionary to be trimmed in a default Blazor WASM app. Saving roughly 3 KB .br compressed. Contributes to #30098 --- src/Components/Components/src/Routing/Router.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/Components/src/Routing/Router.cs b/src/Components/Components/src/Routing/Router.cs index d2dc133ff1ea..d8bad189e558 100644 --- a/src/Components/Components/src/Routing/Router.cs +++ b/src/Components/Components/src/Routing/Router.cs @@ -23,8 +23,8 @@ namespace Microsoft.AspNetCore.Components.Routing public class Router : IComponent, IHandleAfterRender, IDisposable { static readonly char[] _queryOrHashStartChar = new[] { '?', '#' }; - static readonly ReadOnlyDictionary _emptyParametersDictionary - = new ReadOnlyDictionary(new Dictionary()); + static readonly IReadOnlyDictionary _emptyParametersDictionary + = new Dictionary(); RenderHandle _renderHandle; string _baseUri; From 0cc98e0ddcfaf5f3c35bf0038d3f5a94265a8d45 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sat, 3 Apr 2021 16:59:10 +1300 Subject: [PATCH 2/2] Update src/Components/Components/src/Routing/Router.cs --- src/Components/Components/src/Routing/Router.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/Components/src/Routing/Router.cs b/src/Components/Components/src/Routing/Router.cs index d8bad189e558..ff8cd2483161 100644 --- a/src/Components/Components/src/Routing/Router.cs +++ b/src/Components/Components/src/Routing/Router.cs @@ -23,6 +23,7 @@ namespace Microsoft.AspNetCore.Components.Routing public class Router : IComponent, IHandleAfterRender, IDisposable { static readonly char[] _queryOrHashStartChar = new[] { '?', '#' }; + // Dictionary is intentionally used instead of ReadOnlyDictionary to reduce Blazor size static readonly IReadOnlyDictionary _emptyParametersDictionary = new Dictionary();