Skip to content

feat: Newtonsoft.Json → System.Text.Json + .NET 10 Upgrade on contentstack-model-generator#49

Merged
naman-contentstack merged 30 commits into
masterfrom
enhc/beta
Jul 13, 2026
Merged

feat: Newtonsoft.Json → System.Text.Json + .NET 10 Upgrade on contentstack-model-generator#49
naman-contentstack merged 30 commits into
masterfrom
enhc/beta

Conversation

@OMpawar-21

Copy link
Copy Markdown
Contributor
Breaking Changes:
  • Removed the Newtonsoft.Json dependency entirely. Both the tool's internals and the models/converters it generates now use System.Text.Json.
  • Generated model files now use [JsonPropertyName] instead of [JsonProperty], and reference System.Text.Json / System.Text.Json.Nodes / System.Text.Json.Serialization instead of Newtonsoft.Json.
  • Generated embedded-object and modular-block converters now inherit System.Text.Json.Serialization.JsonConverter<T> (Read/Write) instead of Newtonsoft's JsonConverter<T> (ReadJson/WriteJson). Regenerating models against an existing project will change these attributes and converters - update consuming code accordingly.
  • Requires .NET 10.0 or later (previously .NET 7.0).
  • ContentstackException no longer supports legacy BinaryFormatter-based serialization (removed the obsolete SerializationInfo/StreamingContext constructor and GetObjectData override).
Enhancements:
  • Upgraded target framework from net7.0 to net10.0.
  • Updated CI/CD pipeline to use .NET 10 SDK (actions/setup-dotnet@v4).
  • Updated Microsoft.AspNetCore.Mvc.Testing from 9.0.9 to 10.0.0.
  • Migrated internal model DTOs (Field, MetaData, Contenttype, StackResponse, ContentStackError, OAuth token response) from [JsonProperty] to [JsonPropertyName].
  • Migrated OAuthService token exchange/refresh deserialization to System.Text.Json.
  • Migrated the HTTP layer (IResponse, ContentstackResponse, HTTPRequestHandler, ContentstackHttpRequest) from Newtonsoft JObject to System.Text.Json.Nodes.JsonObject.
  • Migrated ContentstackClient's serializer settings, response deserialization, and error parsing to System.Text.Json (JsonSerializerOptions, JsonNode).
  • Migrated the code-generation templates (using statements, field attributes, link class, embedded-object converter, modular-block converter, and helper class) to emit System.Text.Json-based generated code.
  • Fixed reference-field type resolution (GetDatatypeForContentType) to use System.Text.Json.JsonElement instead of the removed Newtonsoft JArray/JObject types.
Bug fix:
  • Fixed GetHeader method visibility (private → internal) to allow test access.
  • Fixed a template bug where the generated embeddedItems property's nullable annotation was emitted as literal text ({nullableString()}) instead of being applied, for content types with RTE-embedded references.

harshithad0703 and others added 28 commits January 12, 2026 18:05
- Bump main project TFM from net7.0 to net10.0
- Bump test project TFM from net9.0 to net10.0
- Update Microsoft.AspNetCore.Mvc.Testing 9.0.9 → 10.0.0
- Upgrade CI: actions/checkout@v1 → @v4, setup-dotnet@v3 → @v4 with dotnet-version 10.x
- Fix pre-existing GetHeader visibility private → internal (unblocks 175 tests)
- Bump PackageVersion and ReleaseVersion to 1.0.0-beta.1
- Update CHANGELOG.md
…yName]

- Replace Newtonsoft.Json [JsonProperty] with STJ [JsonPropertyName] in:
  Field.cs, MetaData.cs, Contenttype.cs, StackResponse.cs,
  ContentStackError.cs, OAuth.cs, OAuthService.cs (OAuthTokenResponse class)
- Swap using Newtonsoft.Json → using System.Text.Json.Serialization in all above files
- Migrate Model/OAuth.cs (OAuthAppAuthorizationResponse, OAuthAppAuthorizationData, OAuthUser, OAuthResponse)
- OAuthService.cs retains using Newtonsoft.Json for JsonConvert calls
feat: upgrade to .NET 10 and bump version to 1.0.0-beta.1
feat: migrate internal model DTOs from [JsonProperty] to [JsonPropertyName]
Replace all Newtonsoft usage across the HTTP abstraction layer as part of the
STJ migration. Renames OpenJObjectResponse() to OpenJsonObjectResponse() returning
System.Text.Json.Nodes.JsonObject, swaps JsonSerializer (Newtonsoft) for
JsonSerializerOptions throughout the request/response pipeline, and replaces
JsonConvert.SerializeObject with JsonSerializer.Serialize for query param building.

Files changed:
- CMA/Http/IResponse.cs
- CMA/Http/ContentstackResponse.cs
- CMA/HTTPRequestHandler.cs
- CMA/Http/ContentstackHttpRequest.cs
…ration

refactor: migrate from Newtonsoft.Json to System.Text.Json for serialization in OAuthService and tests
feat: migrate HTTP layer from Newtonsoft.Json to System.Text.Json
refactor: update serializer settings to use JsonSerializerOptions in ContentstackClient
…tes to System.Text.Json

- Remove the Newtonsoft.Json 13.0.3 PackageReference from
  contentstack.model.generator.csproj now that tool internals no
  longer depend on it
- Update ModelGenerator.cs's _templateStart, CreateLinkClass(),
  CreateFile(), and AddParams() to emit [JsonPropertyName] instead
  of [JsonProperty], and swap the Newtonsoft using statements in
  _templateStart for System.Text.Json / Nodes / Serialization

Note: CreateEmbeddedObjectClass() and CreateModularBlockConverter()
still reference Newtonsoft types (JObject/JArray) for their converter
templates and are not yet migrated, so the project will not build
again until that work lands.
refactor: remove Newtonsoft.Json package and migrate template attributes to System.Text.Json
- Update CreateHelperClass()'s emitted FieldExists signature from
  JObject to JsonObject
- Rewrite CreateModularBlockConverter()'s emitted converter from
  Newtonsoft's ReadJson()/WriteJson()/serializer.Populate() to STJ's
  Read()/Write(), using a parse-then-deserialize-and-replace pattern
  that restores the BlockType discriminator after re-deserializing
  the concrete block type
refactor: migrate modular block converter template to System.Text.Json
refactor: migrate from Newtonsoft.Json to System.Text.Json in ModelGenerator
test: expand unit test coverage for ModelGenerator and previously-untested CMA/Model classes
feat: Update the Read me and version bump for Major Release
@github-actions

Copy link
Copy Markdown

We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.

@github-actions

Copy link
Copy Markdown

We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.

@naman-contentstack naman-contentstack marked this pull request as ready for review July 10, 2026 11:40
@naman-contentstack naman-contentstack requested a review from a team as a code owner July 10, 2026 11:40
@naman-contentstack naman-contentstack merged commit 2137905 into master Jul 13, 2026
9 checks passed
@naman-contentstack naman-contentstack deleted the enhc/beta branch July 13, 2026 10:30
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.

5 participants