Skip to content

Add explicity JsonConverters to all enums, so they are always serialized as strings#897

Merged
KevinJump merged 1 commit intov17/mainfrom
v17/explicit-enum-conversions
Feb 25, 2026
Merged

Add explicity JsonConverters to all enums, so they are always serialized as strings#897
KevinJump merged 1 commit intov17/mainfrom
v17/explicit-enum-conversions

Conversation

@KevinJump
Copy link
Owner

Not sure if this is the issue, but some reports that one of the enums in the ActionViews is returning to the user as a number not a string.

It's likely there is some global setting at play, but as with Newtonsoft, we can probibly overcome that by being explict with what to do with the enums.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds explicit JsonStringEnumConverter attributes to all public enum declarations throughout the uSync codebase to ensure they are consistently serialized as strings (not numbers) when used in JSON API responses and SignalR messages. This addresses a reported issue where enums in ActionViews were being returned as numbers instead of strings to the client.

Changes:

  • Added JsonStringEnumConverter<T> attributes to 11 enum types across the codebase
  • Added necessary using System.Text.Json.Serialization; imports to affected files
  • Ensures consistent string serialization for enums used in API models like uSyncActionView, which contains several of these enum types

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
uSync.Core/uSyncContentState.cs Added JsonConverter to uSyncContentState enum
uSync.Core/Tracking/SyncXmlTracker.cs Added JsonConverter to TrackingDirection enum
uSync.Core/SyncActionType.cs Added JsonConverter to SyncActionType enum
uSync.Core/Sync/SyncTreeType.cs Added JsonConverter to SyncTreeType enum
uSync.Core/Models/uSyncChange.cs Added JsonConverter to ChangeDetailType enum
uSync.Core/Dependency/uSyncDependency.cs Added JsonConverter to DependencyMode enum
uSync.Core/ChangeType.cs Added JsonConverter to ChangeType enum (used in API responses)
uSync.BackOffice/SyncHandlers/Models/HandlerActionNames.cs Added JsonConverter to HandlerActions enum
uSync.BackOffice/Configuration/uSyncSettings.cs Added JsonConverter to SyncFolderMode and SyncProcessingMode enums
Comments suppressed due to low confidence (1)

uSync.Core/uSyncContentState.cs:6

  • Spelling error in comment: "thing" should be "think".
///  the state we thing a culture / content item should be in.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KevinJump KevinJump merged commit 9776384 into v17/main Feb 25, 2026
8 checks passed
@KevinJump KevinJump deleted the v17/explicit-enum-conversions branch February 25, 2026 10:58
alexsee pushed a commit to alexsee/umbraco-container that referenced this pull request Mar 7, 2026
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Updated [uSync](https://github.com/KevinJump/uSync) from 17.0.2 to
17.0.4.

<details>
<summary>Release notes</summary>

_Sourced from [uSync's
releases](https://github.com/KevinJump/uSync/releases)._

## 17.0.3

This is a patch release of uSync for Umbraco v17 - it contains some
fixes for reported issues.

> [!NOTE]
> This version supports all versions of Umbraco v17.*

## What's Changed
* ⭐ Add IgnoreStopIfOnceExists setting for write-only deployments by
@​Copilot in KevinJump/uSync#879
* ⭐ Add cleanup in DocumentUrl tables when the content key changes. by
@​KevinJump in KevinJump/uSync#869
* ⭐ refresh the trees in settings when uSync finishes an import by
@​KevinJump in KevinJump/uSync#892
* ⭐ V17/extension example by @​KevinJump in
KevinJump/uSync#888
* Ensure we don't build the extend examples unless we are in debug. by
@​KevinJump in KevinJump/uSync#889
* 🐛 Fix - when descriptions are blank, they get filled with 'null' by
@​KevinJump in KevinJump/uSync#890
* 🐛 Fix - don't save 'null' in property type description name by
@​KevinJump in KevinJump/uSync#891
* ⬆️ update readme by @​KevinJump in
KevinJump/uSync#893
* ⬆️ move to centralised package management by @​KevinJump in
KevinJump/uSync#894
* ⬆️ update dependencies by @​KevinJump in
KevinJump/uSync#895
* ⬆️ add explicity JsonConverters to all enums, so they are always
serialized as strings by @​KevinJump in
KevinJump/uSync#897
* 🆙 V17/last synced date by @​KevinJump in
KevinJump/uSync#898
* ⬆️ V17/object property extensions by @​KevinJump in
KevinJump/uSync#896

**Full Changelog**:
KevinJump/uSync@v17.0.2...v17.0.4

Commits viewable in [compare
view](https://github.com/KevinJump/uSync/commits).
</details>

Updated [uSync.Complete](https://jumoo.co.uk/uSync/complete) from 17.0.1
to 17.1.1.

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants