Skip to content

Commit ffa3ff3

Browse files
authored
Merge pull request #76 from contentstack/master
chore: back-merge master into development
2 parents 5e795ef + 58973ba commit ffa3ff3

30 files changed

Lines changed: 1338 additions & 485 deletions

.github/workflows/issues-jira.yml

Lines changed: 0 additions & 118 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ packages/
2121
*.trx
2222
*/TestResults/
2323
*/app.config
24-
.dccache
24+
.dccache
25+
*/Assets/regions.json

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
### Version: 2.0.0
2+
#### Date: July-13-2026
3+
- **Breaking:** Replaced **Newtonsoft.Json** with **System.Text.Json** across the package. The `Newtonsoft.Json` package reference is removed; add `System.Text.Json` (or rely on the BCL on supported runtimes) as needed in consuming projects.
4+
- **Breaking:** `GetVariantAliases(JObject, string)` / `GetVariantAliases(JArray, string)``GetVariantAliases(JsonObject, string)` / `GetVariantAliases(JsonArray, string)`.
5+
- **Breaking:** `GetVariantMetadataTags(JObject, string)` / `GetVariantMetadataTags(JArray, string)``GetVariantMetadataTags(JsonObject, string)` / `GetVariantMetadataTags(JsonArray, string)`.
6+
- **Breaking:** `GetDataCsvariantsAttribute(JObject/JArray, string)` is deprecated and now maps to `JsonObject`/`JsonArray` overloads.
7+
- **Breaking:** `Node.attrs` values are now `System.Text.Json.JsonElement` instead of `Newtonsoft.Json.Linq.JToken` — update `node.attrs["src"].Value<string>()` to `node.attrs["src"].GetString()`.
8+
- **Breaking:** Model classes use `[JsonPropertyName]` instead of `[JsonProperty]`.
9+
- **Breaking:** Requires **.NET 10** or later (previously netstandard2.0 / net6.0).
10+
- **New:** Multi-region endpoint resolution via `Endpoint.GetContentstackEndpoint(region, service)` — resolves Contentstack service URLs for all 7 supported regions (NA, EU, AU, Azure-NA, Azure-EU, GCP-NA, GCP-EU) and 18 service keys (contentDelivery, contentManagement, auth, graphqlDelivery, preview, images, assets, automate, launch, developerHub, brandKit, genAI, personalizeManagement, personalizeEdge, composableStudio, assetManagement, and more).
11+
- **New:** `Utils.GetContentstackEndpoint(region, service)` proxy — access endpoint resolution directly from the `Utils` class without importing `Contentstack.Utils.Endpoints`.
12+
- **New:** `omitHttps` flag strips the `https://` scheme from returned URLs — pass directly to SDK host configuration (e.g. `new ContentstackOptions { Host = Endpoint.GetContentstackEndpoint("eu", "contentDelivery", omitHttps: true) }`).
13+
- **New:** Case-insensitive region alias support — `"us"`, `"NA"`, `"AWS-NA"`, `"azure_na"` all resolve correctly to the same region.
14+
- **New:** `regions.json` registry auto-downloaded from `artifacts.contentstack.com` on first use and cached on disk — no setup required. The SDK self-heals if the file is missing.
15+
- **New:** `Scripts/refresh-region.py` bundled inside the NuGet package — automatically placed in your project's `Scripts/` folder on first `dotnet build`. Run `python3 Scripts/refresh-region.py` (Mac/Linux) or `python Scripts/refresh-region.py` (Windows) anytime to pull the latest regions from CDN.
16+
17+
##### Migration Guide:
18+
- See [Migrating from Newtonsoft.Json to System.Text.Json](https://www.contentstack.com/docs/developers/sdks/utils-sdk/dot-net/migrate-dotnet-utils-sdk-from-newtonsoft.json-to-system.text.json) for the full upgrade path from v1.x.
19+
20+
### Version: 2.0.0-beta.2
21+
#### Date: June-22-2026
22+
- **New:** Multi-region endpoint resolution via `Endpoint.GetContentstackEndpoint(region, service)` — resolves Contentstack service URLs for all 7 supported regions (NA, EU, AU, Azure-NA, Azure-EU, GCP-NA, GCP-EU) and 18 service keys (contentDelivery, contentManagement, auth, graphqlDelivery, preview, images, assets, automate, launch, developerHub, brandKit, genAI, personalizeManagement, personalizeEdge, composableStudio, assetManagement, and more).
23+
- **New:** `Utils.GetContentstackEndpoint(region, service)` proxy — access endpoint resolution directly from the `Utils` class without importing `Contentstack.Utils.Endpoints`.
24+
- **New:** `omitHttps` flag strips the `https://` scheme from returned URLs — pass directly to SDK host configuration (e.g. `new ContentstackOptions { Host = Endpoint.GetContentstackEndpoint("eu", "contentDelivery", omitHttps: true) }`).
25+
- **New:** Case-insensitive region alias support — `"us"`, `"NA"`, `"AWS-NA"`, `"azure_na"` all resolve correctly to the same region.
26+
- **New:** `regions.json` registry auto-downloaded from `artifacts.contentstack.com` on first use and cached on disk — no setup required. The SDK self-heals if the file is missing.
27+
- **New:** `Scripts/refresh-region.py` bundled inside the NuGet package — automatically placed in your project's `Scripts/` folder on first `dotnet build`. Run `python3 Scripts/refresh-region.py` (Mac/Linux) or `python Scripts/refresh-region.py` (Windows) anytime to pull the latest regions from CDN.
28+
29+
### Version: 2.0.0-beta.1
30+
#### Date: April-27-2026
31+
- **Breaking:** Replaced **Newtonsoft.Json** with **System.Text.Json** across the package. The `Newtonsoft.Json` package reference is removed; add `System.Text.Json` (or rely on the BCL on supported runtimes) as needed in consuming projects.
32+
- **Breaking:** Variant metadata APIs that previously took `JObject` / `JArray` now use `System.Text.Json.Nodes.JsonObject` and `JsonArray` (`GetVariantAliases`, `GetVariantMetadataTags`, and obsolete `GetDataCsvariantsAttribute` overloads).
33+
- JSON serialization uses the same model attributes with `System.Text.Json.Serialization` (`JsonPropertyName`, `JsonConverter`), including custom converters for RTE/GQL-shaped JSON and **path-mapped** embedded models (`PathMappedJsonConverter<T>`).
34+
- RTE JSON deserialization tolerates **trailing commas** when using the documented test/helper patterns (`AllowTrailingCommas`); attribute dictionaries may surface **`JsonElement`** values instead of boxed strings—use helpers or unwrap explicitly if you access `Node.attrs` directly.
35+
- Internal: `LangVersion` set to **latest** for multi-target builds; utilities normalize attribute values where the HTML pipeline expects strings.
36+
137
### Version: 1.4.0
238
#### Date: June-23-2026
339
- Added `EmbeddedObject` as a concrete implementation of `IEmbeddedObject`, covering both `IEmbeddedEntry` and `IEmbeddedAsset`.
@@ -13,7 +49,7 @@
1349
- Added configurable locale casing through `AddEditableTagsOptions.UseLowerCaseLocale`.
1450
- Added unit tests for Live Preview editable tags.
1551

16-
52+
### Version: 1.2.0
1753
#### Date: March-31-2026
1854
- Added `GetVariantMetadataTags(JObject, string)` and `GetVariantMetadataTags(JArray, string)` as the canonical API for building the `data-csvariants` payload (same behavior as the previous helpers).
1955

Contentstack.Utils.Tests/Contentstack.Utils.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0</TargetFrameworks>
4+
<TargetFrameworks>net10.0</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77
<ReleaseVersion>$(Version)</ReleaseVersion>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
12-
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
1312
<PackageReference Include="coverlet.collector" Version="6.0.4">
1413
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1514
<PrivateAssets>all</PrivateAssets>

Contentstack.Utils.Tests/DefaultRenderTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Contentstack.Utils.Tests.Helpers;
66
using Contentstack.Utils.Tests.Constants;
77
using System;
8+
using Contentstack.Utils;
89

910
namespace Contentstack.Utils.Tests
1011
{
@@ -178,9 +179,9 @@ public void testLinkhDocument()
178179

179180
string result = defaultRender.RenderNode("a", nodeLink, (nodes) => { return text; });
180181

181-
string url = nodeLink.attrs.ContainsKey("url") ? (string)nodeLink.attrs["url"] : "";
182-
string target = nodeLink.attrs.ContainsKey("target") ? (string)nodeLink.attrs["target"] : "";
183-
string title = nodeLink.attrs.ContainsKey("title") ? (string)nodeLink.attrs["title"] : "";
182+
string url = nodeLink.attrs.ContainsKey("url") ? JsonAttrValue.AsString(nodeLink.attrs["url"]) : "";
183+
string target = nodeLink.attrs.ContainsKey("target") ? JsonAttrValue.AsString(nodeLink.attrs["target"]) : "";
184+
string title = nodeLink.attrs.ContainsKey("title") ? JsonAttrValue.AsString(nodeLink.attrs["title"]) : "";
184185

185186
Assert.Equal($"<a href=\"{url}\" target=\"{target}\" title=\"{title}\" >Text To set Link</a>", result);
186187
}

0 commit comments

Comments
 (0)