Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "8.0.x"
dotnet-version: "9.x"
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test with dotnet
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "8.0.x"
dotnet-version: "9.x"
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test with dotnet
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ jobs:
Protobuf.System.Text.Json
]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2 # Updated to v2 for better performance and new features
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "8.0.x"
dotnet-version: "9.x"
- name: Create NuGet Package
run: dotnet pack -c Release /p:Version=${{ github.event.release.name }} /p:PackageReleaseNotes="See https://github.com/Havret/Protobuf.System.Text.Json/releases/tag/${{ github.event.release.tag_name }}"
- name: Archive NuGet Package
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4 # Migrated to v4
with:
name: ${{ matrix.package }}
path: ./src/${{ matrix.package }}/bin/Release/${{ matrix.package }}.${{ github.event.release.name }}.nupkg
- name: Archive NuGet Package With Symbols
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4 # Migrated to v4
with:
name: ${{ matrix.package }}
name: ${{ matrix.package }}-symbols
path: ./src/${{ matrix.package }}/bin/Release/${{ matrix.package }}.${{ github.event.release.name }}.snupkg
- name: Publish NuGet Package
run: dotnet nuget push ./src/${{ matrix.package }}/bin/Release/${{ matrix.package }}.${{ github.event.release.name }}.nupkg --api-key ${{ secrets.nuget_api_key }} --source https://api.nuget.org/v3/index.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="Google.Protobuf" Version="3.27.1" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.27.1" />
<PackageReference Include="Grpc.Tools" Version="2.64.0">
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="Google.Protobuf" Version="3.29.2" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.29.2" />
<PackageReference Include="Grpc.Tools" Version="2.68.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="Google.Protobuf" Version="3.27.1" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.27.1" />
<PackageReference Include="Grpc.Tools" Version="2.64.0">
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="Google.Protobuf" Version="3.29.2" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.29.2" />
<PackageReference Include="Grpc.Tools" Version="2.68.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.27.1" />
<PackageReference Include="Google.Protobuf" Version="3.29.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="Google.Protobuf" Version="3.27.1" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.27.1" />
<PackageReference Include="Grpc.Tools" Version="2.64.0">
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="Google.Protobuf" Version="3.29.2" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.29.2" />
<PackageReference Include="Grpc.Tools" Version="2.68.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<Summary>System.Text.Json extensions for Protobuf types.</Summary>
<Description>System.Text.Json extensions for Protobuf types.</Description>
<TargetFrameworks>net8.0;net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>12</LangVersion>
<TargetFrameworks>net9.0;net8.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>13.0</LangVersion>
<PackageProjectUrl>https://github.com/Havret/System.Text.Json.Protobuf</PackageProjectUrl>
<PackageId>Protobuf.System.Text.Json</PackageId>
<PackageLicenseUrl>https://github.com/Havret/System.Text.Json.Protobuf/blob/main/LICENSE</PackageLicenseUrl>
Expand All @@ -22,8 +22,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.27.1" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="Google.Protobuf" Version="3.29.2" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json;
using System.Text.Json.Protobuf.Tests;
using Protobuf.System.Text.Json.Tests.Utils;
using Shouldly;
using Xunit;

namespace Protobuf.System.Text.Json.Tests;
Expand All @@ -25,8 +24,8 @@ public void Should_deserialize_a_new_version_of_a_message_using_the_old_version_
var deserialized = JsonSerializer.Deserialize<MessageWithVersionMismatch>(payload, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.DoubleProperty.ShouldBe(msg.DoubleProperty);
Assert.NotNull(deserialized);
Assert.Equal(msg.DoubleProperty, deserialized.DoubleProperty);
}

[Fact]
Expand All @@ -44,7 +43,7 @@ public void Should_deserialize_the_old_version_of_a_message_using_the_new_versio
var deserialized = JsonSerializer.Deserialize<MessageWithVersionMismatchV2>(payload, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.DoubleProperty.ShouldBe(msg.DoubleProperty);
Assert.NotNull(deserialized);
Assert.Equal(msg.DoubleProperty, deserialized.DoubleProperty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Text.Json.Protobuf.Tests;
using System.Text.Json.Serialization;
using Protobuf.System.Text.Json.Tests.Utils;
using Shouldly;
using SmartAnalyzers.ApprovalTestsExtensions;
using Xunit;

Expand Down Expand Up @@ -51,7 +50,7 @@ public void Should_deserialize_message_with_complex_property()
var deserialized = JsonSerializer.Deserialize<MessageWithComplexProperty>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldBeEquivalentTo(msg);
Assert.Equal(msg, deserialized);
}

[Fact]
Expand All @@ -74,6 +73,6 @@ public void Should_deserialize_message_with_complex_property_when_no_value_is_se
var deserialized = JsonSerializer.Deserialize<MessageWithComplexProperty>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldBeEquivalentTo(msg);
Assert.Equal(msg, deserialized);
}
}
14 changes: 6 additions & 8 deletions test/Protobuf.System.Text.Json.Tests/MessageWithDurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Text.Json.Protobuf.Tests;
using Google.Protobuf.WellKnownTypes;
using Protobuf.System.Text.Json.Tests.Utils;
using Shouldly;
using SmartAnalyzers.ApprovalTestsExtensions;
using Xunit;

Expand Down Expand Up @@ -60,8 +59,8 @@ public void Should_serialize_and_deserialize_message_with_duration()
var deserialized = JsonSerializer.Deserialize<MessageWithDuration>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.ShouldBeEquivalentTo(msg);
Assert.NotNull(deserialized);
Assert.Equal(deserialized, msg);
}

[Fact]
Expand All @@ -76,8 +75,8 @@ public void Should_serialize_and_deserialize_message_with_duration_when_value_is
var deserialized = JsonSerializer.Deserialize<MessageWithDuration>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.ShouldBeEquivalentTo(msg);
Assert.NotNull(deserialized);
Assert.Equal(deserialized, msg);
}

[Fact]
Expand Down Expand Up @@ -125,8 +124,7 @@ public void Should_deserialize_duration_property_from_complex_object_when_TreatD
var deserialized = JsonSerializer.Deserialize<MessageWithDuration>(payload, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.ShouldBeEquivalentTo(msg);

Assert.NotNull(deserialized);
Assert.Equal(deserialized, msg);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json;
using System.Text.Json.Protobuf.Tests;
using Protobuf.System.Text.Json.Tests.Utils;
using Shouldly;
using SmartAnalyzers.ApprovalTestsExtensions;
using Xunit;

Expand Down Expand Up @@ -42,8 +41,8 @@ public void Should_deserialize_message_with_with_enum_field()
var deserialized = JsonSerializer.Deserialize<MessageWithEnum>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.ShouldBeEquivalentTo(msg);
Assert.NotNull(deserialized);
Assert.Equal(deserialized, msg);
}

[Fact]
Expand Down Expand Up @@ -106,8 +105,8 @@ public void Should_deserialize_message_with_enum_field_when_value_serialized_usi
var deserialized = JsonSerializer.Deserialize<MessageWithEnum>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.ShouldBeEquivalentTo(msg);
Assert.NotNull(deserialized);
Assert.Equal(deserialized, msg);
}

[Fact]
Expand All @@ -127,6 +126,6 @@ public void Should_throw_exception_when_string_enum_value_cannot_be_deserialized

// Act & Assert
var exception = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<MessageWithEnum>(invalidPayload, jsonSerializerOptions));
exception.Message.ShouldContain("'INVALID_OPTION' is not a valid value for type System.Text.Json.Protobuf.Tests.TestEnum.");
Assert.Contains("'INVALID_OPTION' is not a valid value for type System.Text.Json.Protobuf.Tests.TestEnum.", exception.Message);
}
}
5 changes: 2 additions & 3 deletions test/Protobuf.System.Text.Json.Tests/MessageWithMapsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Text.Json.Protobuf.Tests;
using Google.Protobuf;
using Protobuf.System.Text.Json.Tests.Utils;
using Shouldly;
using SmartAnalyzers.ApprovalTestsExtensions;
using Xunit;

Expand Down Expand Up @@ -59,7 +58,7 @@ public void Should_deserialize_message_with_map_field()
var deserialized = JsonSerializer.Deserialize<MessageWithMaps>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.ShouldBeEquivalentTo(msg);
Assert.NotNull(deserialized);
Assert.Equal(deserialized, msg);
}
}
30 changes: 15 additions & 15 deletions test/Protobuf.System.Text.Json.Tests/MessageWithOneOfTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json;
using System.Text.Json.Protobuf.Tests;
using Protobuf.System.Text.Json.Tests.Utils;
using Shouldly;
using SmartAnalyzers.ApprovalTestsExtensions;
using Xunit;

Expand Down Expand Up @@ -58,10 +57,10 @@ public void Should_serialize_and_deserialize_message_with_one_of_when_value_is_s
var deserialized = JsonSerializer.Deserialize<MessageWithOneOf>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.Int32PropertyValue.ShouldBe(msg.Int32PropertyValue);
deserialized.Int64PropertyValue.ShouldBe(msg.Int64PropertyValue);
deserialized.PropertyCase.ShouldBe(msg.PropertyCase);
Assert.NotNull(deserialized);
Assert.Equal(msg.Int32PropertyValue, deserialized.Int32PropertyValue);
Assert.Equal(msg.Int64PropertyValue, deserialized.Int64PropertyValue);
Assert.Equal(msg.PropertyCase, deserialized.PropertyCase);
}

[Fact]
Expand All @@ -76,10 +75,11 @@ public void Should_serialize_and_deserialize_message_with_one_of_when_value_is_n
var deserialized = JsonSerializer.Deserialize<MessageWithOneOf>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.Int32PropertyValue.ShouldBe(msg.Int32PropertyValue);
deserialized.Int64PropertyValue.ShouldBe(msg.Int64PropertyValue);
deserialized.PropertyCase.ShouldBe(msg.PropertyCase);
Assert.NotNull(deserialized);
Assert.Equal(msg.Int32PropertyValue, deserialized.Int32PropertyValue);
Assert.Equal(msg.Int64PropertyValue, deserialized.Int64PropertyValue);
Assert.Equal(msg.PropertyCase, deserialized.PropertyCase);

}

[Fact]
Expand Down Expand Up @@ -132,9 +132,9 @@ public void Should_serialize_and_deserialize_message_with_optional_property_when
var deserialized = JsonSerializer.Deserialize<MessageWithOptionalProperty>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.Int32Property.ShouldBe(msg.Int32Property);
deserialized.HasInt32Property.ShouldBe(msg.HasInt32Property);
Assert.NotNull(deserialized);
Assert.Equal(msg.Int32Property, deserialized.Int32Property);
Assert.Equal(msg.HasInt32Property, deserialized.HasInt32Property);
}

[Fact]
Expand All @@ -149,8 +149,8 @@ public void Should_serialize_and_deserialize_message_with_optional_property_when
var deserialized = JsonSerializer.Deserialize<MessageWithOptionalProperty>(serialized, jsonSerializerOptions);

// Assert
deserialized.ShouldNotBeNull();
deserialized.Int32Property.ShouldBe(msg.Int32Property);
deserialized.HasInt32Property.ShouldBe(msg.HasInt32Property);
Assert.NotNull(deserialized);
Assert.Equal(msg.Int32Property, deserialized.Int32Property);
Assert.Equal(msg.HasInt32Property, deserialized.HasInt32Property);
}
}
Loading
Loading