diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a4e2dd6..5856fe0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Dependency cache uses: actions/cache@v2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a7eb0cc..6a7c89c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: "5.0.x" + dotnet-version: "6.0.x" - name: Create the package run: dotnet pack --configuration Release ./src diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 7f51c55..2461d6f 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -19,11 +19,11 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Reviewdog env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - dotnet build -clp:NoSummary -p:GenerateFullPaths=true --no-incremental --nologo -f net5.0 -v q src \ + dotnet build -clp:NoSummary -p:GenerateFullPaths=true --no-incremental --nologo -f net6.0 -v q src \ | reviewdog -f=dotnet -name=dotnet -reporter=github-pr-review \ No newline at end of file diff --git a/src/stream-net-tests/IntegrationTests.cs b/src/stream-net-tests/IntegrationTests.cs index dad05a4..5df784d 100644 --- a/src/stream-net-tests/IntegrationTests.cs +++ b/src/stream-net-tests/IntegrationTests.cs @@ -4,8 +4,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json.Linq; namespace StreamNetTests { @@ -79,6 +81,10 @@ public async Task TestAddActivityWithArray() { var newActivity = new Stream.Activity("1", "test", "1"); newActivity.SetData("complex", new String[] { "tommaso", "thierry", "shawn" }); + newActivity.SetData("special_json", new { StuffOneTwo = "thing" }, new JsonSerializer + { + ContractResolver = new DefaultContractResolver { NamingStrategy = new KebabCaseNamingStrategy() } + }); var response = await this._user1.AddActivity(newActivity); Assert.IsNotNull(response); @@ -94,6 +100,8 @@ public async Task TestAddActivityWithArray() Assert.IsNotNull(complex); Assert.AreEqual(3, complex.Length); Assert.AreEqual("shawn", complex[2]); + + Assert.AreEqual("thing", first.GetData("special_json")["stuff-one-two"].Value()); } [Test] diff --git a/src/stream-net-tests/stream-net-tests.csproj b/src/stream-net-tests/stream-net-tests.csproj index f518e71..6307104 100644 --- a/src/stream-net-tests/stream-net-tests.csproj +++ b/src/stream-net-tests/stream-net-tests.csproj @@ -3,13 +3,13 @@ TRACE;DEBUG;NETCORE - net5.0 + net6.0 false - + diff --git a/src/stream-net/Activity.cs b/src/stream-net/Activity.cs index 46b390e..a7a408c 100644 --- a/src/stream-net/Activity.cs +++ b/src/stream-net/Activity.cs @@ -83,9 +83,14 @@ public T GetData(string name) return default(T); } - public void SetData(string name, T data) + public void SetData(string name, T data) => SetData(name, data, null); + + public void SetData(string name, T data, JsonSerializer serializer) { - _data[name] = JValue.FromObject(data); + if (serializer != null) + _data[name] = JValue.FromObject(data, serializer); + else + _data[name] = JValue.FromObject(data); } [JsonConstructor] diff --git a/src/stream-net/Collections.cs b/src/stream-net/Collections.cs index f13e5e8..72962ca 100644 --- a/src/stream-net/Collections.cs +++ b/src/stream-net/Collections.cs @@ -31,6 +31,11 @@ public void SetData(string name, T data) this._data.SetData(name, data); } + public void SetData(string name, T data, JsonSerializer serializer) + { + this._data.SetData(name, data, serializer); + } + public string Ref(string collectionName) { return Collections.Ref(collectionName, this); diff --git a/src/stream-net/EnrichedActivity.cs b/src/stream-net/EnrichedActivity.cs index a2e3933..62aedf1 100644 --- a/src/stream-net/EnrichedActivity.cs +++ b/src/stream-net/EnrichedActivity.cs @@ -76,9 +76,14 @@ public T GetData(string name) return default(T); } - public void SetData(string name, T data) + public void SetData(string name, T data) => SetData(name, data, null); + + public void SetData(string name, T data, JsonSerializer serializer) { - _data[name] = JValue.FromObject(data); + if (serializer != null) + _data[name] = JValue.FromObject(data, serializer); + else + _data[name] = JValue.FromObject(data); } [JsonConstructor] diff --git a/src/stream-net/GenericData.cs b/src/stream-net/GenericData.cs index 08c8bea..085c4e9 100644 --- a/src/stream-net/GenericData.cs +++ b/src/stream-net/GenericData.cs @@ -18,9 +18,14 @@ public T GetData(string name) return this._data.TryGetValue(name, out val) ? val.ToObject() : default(T); } - public void SetData(string name, T data) + public void SetData(string name, T data) => SetData(name, data, null); + + public void SetData(string name, T data, JsonSerializer serializer) { - this._data[name] = JValue.FromObject(data); + if (serializer != null) + _data[name] = JValue.FromObject(data, serializer); + else + _data[name] = JValue.FromObject(data); } internal JObject ToJObject() diff --git a/src/stream-net/stream-net.csproj b/src/stream-net/stream-net.csproj index ec8dda1..a09507c 100644 --- a/src/stream-net/stream-net.csproj +++ b/src/stream-net/stream-net.csproj @@ -3,7 +3,7 @@ TRACE;DEBUG;NETCORE - net45;net46;net47;net48;netstandard1.6;netstandard2.0;netstandard2.1;net5.0 + net45;net46;net47;net48;netstandard1.6;netstandard2.0;netstandard2.1;net5.0;net6.0 stream-net