Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/in-depth/client/advanced/maui-aot.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Create a new partial class that inherits from `JsonSerializerContext`. It shoul
AllowTrailingCommas = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
Converters = [
typeof(JsonStringEnumConverter),
typeof(DateTimeConverter),
typeof(DateTimeOffsetConverter),
typeof(TimeOnlyConverter),
Expand All @@ -86,6 +85,17 @@ Create a new partial class that inherits from `JsonSerializerContext`. It shoul
{
}

Enumerations (enum) are transmitted as strings. If you use an enum in any of your models, you will additionally have to add `typeof(JsonStringEnumConverter<TEnum>)` to the list of converters, where `TEnum` is the type of the enum you are using. Repeat this for each enum you are using. For example, let's say you have multiple models. One of your models is using the enum `CategoryType` and another model is using `CustomerType`, your Converters section would look like this:

Converters = [
typeof(JsonStringEnumConverter<CategoryType>)
typeof(JsonStringEnumConverter<CustomerType>)
typeof(DateTimeConverter),
typeof(DateTimeOffsetConverter),
typeof(TimeOnlyConverter),
typeof(SpatialGeoJsonConverter)
]

Add a `JsonSerializable` attribute for each entity that is stored in your `DbContext` similar to the ones in the example above. Finally, install the modified `JsonSerializerContext` in the `MauiProgram.cs` as the second statment in the `CreateMauiApp` function:

DatasyncSerializer.JsonSerializerOptions.TypeInfoResolver = MySerializerContext.Default;
Expand All @@ -105,5 +115,4 @@ The property group should look something like the following:

## Having problems?

Unfortunately, the development team does not have much experience with releasing iOS applications, so is of limited help. While you can [add a discussion](https://github.com/CommunityToolkit/Datasync/discussions), you will probably get more assistance in the [MAUI](https://github.com/dotnet/maui) and [Entity Framework Core](https://github.com/dotnet/efcore) projects.

Unfortunately, the development team does not have much experience with releasing with Native AOT, so is of limited help. While you can [add a discussion](https://github.com/CommunityToolkit/Datasync/discussions), you will probably get more assistance in the [MAUI](https://github.com/dotnet/maui) and [Entity Framework Core](https://github.com/dotnet/efcore) projects.