Skip to content

Commit

Permalink
Merge branch 'release/0.63.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed May 25, 2023
2 parents 7e75090 + 0ce28e8 commit 468d333
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 31 deletions.
10 changes: 5 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ insert_final_newline = false
trim_trailing_whitespace = true

# .NET Code files
[*.{cs,csx,cake,vb}]
[*.{cs,csx,cake,vb,vbx,h,cpp,idl}]
indent_style = tab
tab_width = 4
insert_final_newline = true
Expand All @@ -21,12 +21,12 @@ insert_final_newline = true
indent_style = tab
tab_width = 4

# Visual Studio XML Project Files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
# MSBuild project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,msbuildproj}]
indent_size = 2

# Various XML Configuration Files
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}]
# Xml config files
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct,runsettings}]
indent_size = 2

# JSON Files
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@
*.DOT diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

# The macOS codesign tool is extremely picky, and requires LF line endings.
*.plist eol=lf
40 changes: 40 additions & 0 deletions Source/ZoomNet.UnitTests/Json/TrackingFieldsConverterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Shouldly;
using System;
using System.Text;
using System.Text.Json;
using Xunit;
using ZoomNet.Json;

namespace ZoomNet.UnitTests.Json
{
public class TrackingFieldsConverterTests
{
[Fact]
public void Read()
{
// Arrange
var json = @"[
{ ""field"": ""some_field"", ""value"": ""ABC_123"" },
{ ""field"": ""another_field"", ""value"": ""FooBar"" }
]";
var jsonUtf8 = (ReadOnlySpan<byte>)Encoding.UTF8.GetBytes(json);
var jsonReader = new Utf8JsonReader(jsonUtf8);
var objectType = (Type)null;
var options = new JsonSerializerOptions();

var converter = new TrackingFieldsConverter();

// Act
jsonReader.Read();
var result = converter.Read(ref jsonReader, objectType, options);

// Assert
result.ShouldNotBeNull();
result.Length.ShouldBe(2);
result[0].Key.ShouldBe("some_field");
result[0].Value.ShouldBe("ABC_123");
result[1].Key.ShouldBe("another_field");
result[1].Value.ShouldBe("FooBar");
}
}
}
4 changes: 2 additions & 2 deletions Source/ZoomNet.UnitTests/ZoomNet.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
Expand Down
10 changes: 4 additions & 6 deletions Source/ZoomNet/Json/KeyValuePairConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace ZoomNet.Json
{
/// <summary>
/// Converts an array of <see cref="KeyValuePair{TKey, TValue}"/> to or from JSON.
/// Converts an array of <see cref="KeyValuePair{String, String}"/> to or from JSON.
/// </summary>
/// <seealso cref="ZoomNetJsonConverter{T}"/>
internal class KeyValuePairConverter : ZoomNetJsonConverter<KeyValuePair<string, string>[]>
Expand Down Expand Up @@ -33,16 +33,14 @@ public override KeyValuePair<string, string>[] Read(ref Utf8JsonReader reader, T
{
var values = new List<KeyValuePair<string, string>>();

reader.Read();

while ((reader.TokenType != JsonTokenType.EndArray) && reader.Read())
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
{
if (reader.TokenType == JsonTokenType.StartObject)
{
var fieldName = string.Empty;
var fieldValue = string.Empty;

while ((reader.TokenType != JsonTokenType.EndObject) && reader.Read())
while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
{
if (reader.TokenType == JsonTokenType.PropertyName)
{
Expand All @@ -54,7 +52,7 @@ public override KeyValuePair<string, string>[] Read(ref Utf8JsonReader reader, T
}
}

values.Add(new KeyValuePair<string, string>(fieldName, fieldValue));
if (!string.IsNullOrEmpty(fieldName)) values.Add(new KeyValuePair<string, string>(fieldName, fieldValue));
}
}

Expand Down
19 changes: 5 additions & 14 deletions Source/ZoomNet/Json/TrackingFieldsConverter.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text.Json;

namespace ZoomNet.Json
{
/// <summary>
/// Converts an array of <see cref="KeyValuePair{TKey, TValue}"/> to or from JSON.
/// Converts an array of <see cref="KeyValuePair{String, String}"/> to or from JSON.
/// </summary>
/// <seealso cref="ZoomNetJsonConverter{T}"/>
internal class TrackingFieldsConverter : ZoomNetJsonConverter<KeyValuePair<string, string>[]>
/// <seealso cref="KeyValuePairConverter"/>
internal class TrackingFieldsConverter : KeyValuePairConverter
{
private readonly KeyValuePairConverter _converter = new KeyValuePairConverter("field", "value");

public override KeyValuePair<string, string>[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return _converter.Read(ref reader, typeToConvert, options);
}

public override void Write(Utf8JsonWriter writer, KeyValuePair<string, string>[] value, JsonSerializerOptions options)
public TrackingFieldsConverter()
: base("field", "value")
{
_converter.Write(writer, value, options);
}
}
}
4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#tool dotnet:?package=GitVersion.Tool&version=5.12.0
#tool dotnet:?package=coveralls.net&version=4.0.1
#tool nuget:?package=GitReleaseManager&version=0.13.0
#tool nuget:?package=ReportGenerator&version=5.1.20
#tool nuget:?package=ReportGenerator&version=5.1.21
#tool nuget:?package=xunit.runner.console&version=2.4.2
#tool nuget:?package=Codecov&version=1.13.0

Expand Down Expand Up @@ -91,7 +91,7 @@ var isBenchmarkProjectPresent = FileExists(benchmarkProject);
// - when running unit tests on Ubuntu
// - when calculating code coverage
// FYI, this will cause an error if the source project and/or the unit test project are not configured to target this desired framework:
const string DefaultFramework = "net6.0";
const string DefaultFramework = "net7.0";
var desiredFramework = (
!IsRunningOnWindows() ||
target.Equals("Coverage", StringComparison.OrdinalIgnoreCase) ||
Expand Down
5 changes: 3 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"sdk": {
"version": "7.0.203",
"rollForward": "latestFeature"
"version": "7.0.302",
"rollForward": "patch",
"allowPrerelease": false
}
}

0 comments on commit 468d333

Please sign in to comment.