Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MackinnonBuck committed Apr 17, 2024
1 parent d758ef8 commit 574694d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 43 deletions.
6 changes: 3 additions & 3 deletions src/Components/Shared/src/DefaultAntiforgeryStateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public DefaultAntiforgeryStateProvider(PersistentComponentState state)
{
var bytes = JsonSerializer.SerializeToUtf8Bytes(
GetAntiforgeryToken(),
DefaultAntiforgeryStateProviderSerializerContext.Default.AntiforgeryRequestToken);
DefaultAntiforgeryStateProviderJsonSerializerContext.Default.AntiforgeryRequestToken);
state.PersistAsJson(PersistenceKey, bytes);
return Task.CompletedTask;
}, RenderMode.InteractiveAuto);
Expand All @@ -37,7 +37,7 @@ public DefaultAntiforgeryStateProvider(PersistentComponentState state)
{
_currentToken = JsonSerializer.Deserialize(
bytes,
DefaultAntiforgeryStateProviderSerializerContext.Default.AntiforgeryRequestToken);
DefaultAntiforgeryStateProviderJsonSerializerContext.Default.AntiforgeryRequestToken);
}
}

Expand All @@ -49,4 +49,4 @@ public DefaultAntiforgeryStateProvider(PersistentComponentState state)
}

[JsonSerializable(typeof(AntiforgeryRequestToken))]
internal sealed partial class DefaultAntiforgeryStateProviderSerializerContext : JsonSerializerContext;
internal sealed partial class DefaultAntiforgeryStateProviderJsonSerializerContext : JsonSerializerContext;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal sealed partial class DefaultWebAssemblyJSRuntime : WebAssemblyJSRuntime
{
private static readonly JsonSerializerOptions _rootComponentSerializerOptions = new(WebAssemblyComponentSerializationSettings.JsonSerializationOptions)
{
TypeInfoResolver = DefaultWebAssemblyJSRuntimeSerializerContext.Default,
TypeInfoResolver = DefaultWebAssemblyJSRuntimeJsonSerializerContext.Default,
};

public static readonly DefaultWebAssemblyJSRuntime Instance = new();
Expand Down Expand Up @@ -172,4 +172,4 @@ protected override Task TransmitStreamAsync(long streamId, DotNetStreamReference
}

[JsonSerializable(typeof(RootComponentOperationBatch))]
internal sealed partial class DefaultWebAssemblyJSRuntimeSerializerContext : JsonSerializerContext;
internal sealed partial class DefaultWebAssemblyJSRuntimeJsonSerializerContext : JsonSerializerContext;
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@
});
}
},
configureRuntime: (builder) => {
builder.withConfig({
browserProfilerOptions: {},
});
},
},
}).then(() => {
const startedParagraph = document.createElement('p');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<StaticWebAssetBasePath>WasmMinimal</StaticWebAssetBasePath>

<WasmProfilers>browser;</WasmProfilers>
<WasmBuildNative>true</WasmBuildNative>
</PropertyGroup>

<ItemGroup>
Expand Down
30 changes: 0 additions & 30 deletions src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
using Microsoft.JSInterop.Infrastructure;
using static Microsoft.AspNetCore.Internal.LinkerFlags;

Expand Down Expand Up @@ -343,30 +340,3 @@ internal IDotNetObjectReference GetObjectReference(long dotNetObjectId)
/// </summary>
public void Dispose() => ByteArraysToBeRevived.Dispose();
}

[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "We enforce trimmer attributes for JSON deserialized types on InvokeAsync")]
internal sealed class FallbackTypeInfoResolver : IJsonTypeInfoResolver
{
private static readonly DefaultJsonTypeInfoResolver _defaultJsonTypeInfoResolver = new();

public static readonly FallbackTypeInfoResolver Instance = new();

public JsonTypeInfo? GetTypeInfo(Type type, JsonSerializerOptions options)
{
if (options.Converters.Any(c => c.CanConvert(type)))
{
// TODO: We should allow types with custom converters to be serialized without
// having to generate metadata for them.
// Question: Why do we even need a JsonTypeInfo if the type is going to be serialized
// with a custom converter anyway? We shouldn't need to perform any reflection here.
// Is it possible to generate a "minimal" JsonTypeInfo that just points to the correct
// converter?
return _defaultJsonTypeInfoResolver.GetTypeInfo(type, options);
}

return null;
}
}

[JsonSerializable(typeof(object[]))] // JS interop argument lists are always object arrays
internal sealed partial class JSRuntimeSerializerContext : JsonSerializerContext;

0 comments on commit 574694d

Please sign in to comment.