Skip to content

Commit 7f42121

Browse files
committed
PR feedback
1 parent 0ce96b4 commit 7f42121

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

src/Components/Server/src/Circuits/CircuitHost.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,11 @@ public async Task DispatchEvent(string eventDescriptorJson, string eventArgsJson
402402
{
403403
// JsonSerializerOptions are tightly bound to the JsonContext. Cache it on first use using a copy
404404
// of the serializer settings.
405-
_jsonContext ??= new(new JsonSerializerOptions(JSRuntime.ReadJsonSerializerOptions()));
405+
if (_jsonContext is null)
406+
{
407+
_jsonContext = new(new JsonSerializerOptions(JSRuntime.ReadJsonSerializerOptions()));
408+
}
409+
406410
webEventData = WebEventData.Parse(Renderer, _jsonContext, eventDescriptorJson, eventArgsJson);
407411
}
408412
catch (Exception ex)

src/Components/Server/src/Microsoft.AspNetCore.Components.Server.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
<Reference Include="Microsoft.Extensions.FileProviders.Composite" />
2424
<Reference Include="Microsoft.Extensions.FileProviders.Embedded" />
2525
<Reference Include="Microsoft.Extensions.Logging" />
26-
2726
<!-- Required for S.T.J source generation -->
2827
<Reference Include="System.Text.Json" PrivateAssets="All" />
29-
28+
3029
<Compile Include="$(SharedSourceRoot)ValueStopwatch\*.cs" />
3130
<Compile Include="$(SharedSourceRoot)LinkerFlags.cs" LinkBase="Shared" />
3231

src/Components/Shared/src/WebEventJsonContext.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Components/Web/src/Microsoft.AspNetCore.Components.Web.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<Reference Include="Microsoft.Extensions.DependencyInjection" />
1717
<Reference Include="Microsoft.JSInterop" />
1818
<Reference Include="System.IO.Pipelines" />
19-
<Reference Include="System.Text.Json" PrivateAssets="All" />
2019
<Compile Include="$(SharedSourceRoot)LinkerFlags.cs" LinkBase="Shared" />
2120
</ItemGroup>
2221

src/Components/WebAssembly/WebAssembly/src/Infrastructure/JSInteropMethods.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ public static Task DispatchEvent(WebEventDescriptor eventDescriptor, string even
4141

4242
// JsonSerializerOptions are tightly bound to the JsonContext. Cache it on first use using a copy
4343
// of the serializer settings.
44-
_jsonContext ??= new(new JsonSerializerOptions(jsonSerializerOptions));
44+
if (_jsonContext is null)
45+
{
46+
_jsonContext = new(new JsonSerializerOptions(jsonSerializerOptions));
47+
}
4548

4649
var webEvent = WebEventData.Parse(renderer, _jsonContext, eventDescriptor, eventArgsJson);
4750
return renderer.DispatchEventAsync(

src/Components/WebView/WebView/src/IpcReceiver.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ private Task DispatchBrowserEventAsync(PageContext pageContext, string eventDesc
9393
var jsonSerializerOptions = pageContext.JSRuntime.ReadJsonSerializerOptions();
9494
// JsonSerializerOptions are tightly bound to the JsonContext. Cache it on first use using a copy
9595
// of the serializer settings.
96-
_jsonContext ??= new(new JsonSerializerOptions(jsonSerializerOptions));
96+
if (_jsonContext is null)
97+
{
98+
_jsonContext = new(new JsonSerializerOptions(jsonSerializerOptions));
99+
}
100+
97101
var webEventData = WebEventData.Parse(renderer, _jsonContext, eventDescriptor, eventArgs);
98102
return renderer.DispatchEventAsync(
99103
webEventData.EventHandlerId,

0 commit comments

Comments
 (0)