Skip to content

Support JsonStringEnumConverter. Fixes #19086 - #20446

Merged
SteveSandersonMS merged 2 commits into
blazor-wasmfrom
stevesa/fix-serializing-enums
Apr 2, 2020
Merged

SteveSandersonMS merged 2 commits into
blazor-wasmfrom
stevesa/fix-serializing-enums

Conversation

@SteveSandersonMS

Copy link
Copy Markdown
Member

It was a linker thing. See explanation in the code.

@SteveSandersonMS SteveSandersonMS added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Apr 2, 2020
statically. It's only JsonStringEnumConverter that currently isn't referenced statically.
The following is a workaround for https://github.com/dotnet/aspnetcore/issues/19086.
The underlying issue is reported in the runtime repo at https://github.com/dotnet/runtime/issues/34449 -->
<type fullname="System.Text.Json.Serialization.*Converter">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I see. The embedded linker config includes JsonConverterEnum<T>, but the not the string one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an embedded linker config in S.T.J? I didn't spot one.

AFAIK the way the other converters are avoiding having their constructors get culled is that they are referenced statically from some bits of code that cache instances.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, here's what it says:

<linker>
  <assembly fullname="System.Text.Json">
    <type fullname="System.Text.Json.JsonPropertyInfoNullable`2">
      <!-- Instantiated via reflection -->
      <method name=".ctor" />
    </type>
    <type fullname="System.Text.Json.Serialization.JsonPropertyInfoNotNullableContravariant`4">
      <!-- Instantiated via reflection -->
      <method name=".ctor" />
    </type>
    <type fullname="System.Text.Json.Serialization.Converters.JsonConverterEnum`1">
      <!-- Instantiated via reflection -->
      <method name=".ctor" />
    </type>
    <type fullname="System.Text.Json.Serialization.Converters.JsonKeyValuePairConverter`2">
      <!-- Instantiated via reflection -->
      <method name=".ctor" />
    </type>
  </assembly>
</linker>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants