Skip to content

NativeAOT-LLVM for .NET 8 has issues with the JsonSerializerContext Case Insensitivity #5568

Description

@rekhoff

If your C# module contains a JsonSerializerContext partial class and attempt to add the [JsonSourceGenerationOptions(PropertyNameCaseInsensitive = true)] attribute to it, this will work with .NET 8 JIT, but will return an error under .NET 8 AOT

The error received is not useful, reading something like:

EXEC : error : Object reference not set to an instance of an object. [path\SpacetimeDB-Serv
er\StdbModule.csproj]
path\.nuget\packages\microsoft.dotnet.ilcompiler.llvm\8.0.0-preview.7.23503.1\build\Microsoft.NETCore.Native.t
argets(328,5): error MSB3073: The command ""path\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler.l
lvm\8.0.0-preview.7.23503.1\tools\\ilc" @"obj\Release\net8.0\wasi-wasm\native\StdbModule.ilc.rsp"" exited with code 1.
[path\SpacetimeDB-Server\StdbModule.csproj]

A work around is to add the JsonSerializerOptions.PropertyNameCaseInsensitive Property each time you are performing actions like using JsonSerializer.Deserialize

Example:

var result = JsonSerializer.Deserialize<T>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });

We should either

  • Find a solution to this bug.
  • Provide a better warning for the error with directions on how to resolve it.
  • Update our documentation providing details on the error and how to work around it.

Additional actions needed:

  • Test this behavior against a NativeAOT .NET 10 module.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions