Skip to content

Commit

Permalink
Merge pull request #88 from ARKlab/renovate/messagepack-3.x
Browse files Browse the repository at this point in the history
chore(deps): update dependency messagepack to v3
  • Loading branch information
AndreaCuneo authored Dec 12, 2024
2 parents 61af6db + 8c5253f commit b526442
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class LDT
}

[Collection("ResolverCollection")]
public class ObjectTesting
public class ContractlessTests
{
[Fact]
public void AnonType()
Expand Down
3 changes: 2 additions & 1 deletion MessagePack.NodaTime.Tests/Init/MessagePackTestInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public ResolverFixture()
{
var resolver = CompositeResolver.Create(new[] {
BuiltinResolver.Instance,
NodatimeResolver.Instance,
AttributeFormatterResolver.Instance,
SourceGeneratedFormatterResolver.Instance,
NodatimeResolver.Instance,
DynamicEnumAsStringResolver.Instance,
ContractlessStandardResolver.Instance
}
Expand Down
53 changes: 53 additions & 0 deletions MessagePack.NodaTime.Tests/SourceGeneratedContractTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) ARK LTD. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for
// license information.
using MessagePack;
using MessagePack.Resolvers;
using NodaTime;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Xunit;

namespace MessagePack.NodaTime.Tests
{
[MessagePackObject]
public record MyClass
{
[Key(0)]
public LocalDateTime LocalDateTime { get; set; } = LocalDateTime.FromDateTime(DateTime.Now);

[Key(1)]
public Instant Instant { get; set; } = Instant.FromDateTimeUtc(DateTime.UtcNow);

[Key(2)]
public Period Period { get; set; } = Period.Zero;

[Key(3)]
public LocalDate LocalDate { get; set; } = LocalDate.FromDateTime(DateTime.Now.Date);

[Key(4)]
public OffsetDateTime OffsetDateTime { get; set; } = OffsetDateTime.FromDateTimeOffset(DateTimeOffset.Now);

[Key(5)]
public Duration Duration { get; set; } = Duration.Zero;

[Key(6)]
public ZonedDateTime ZonedDateTime { get; set; } = ZonedDateTime.FromDateTimeOffset(DateTimeOffset.Now);
}

[Collection("ResolverCollection")]
public class SourceGeneratedContractTests
{
[Fact]
public void Roundtrip()
{
var o = new MyClass { LocalDateTime = LocalDateTime.FromDateTime(DateTime.Now) };
var bin = MessagePackSerializer.Serialize(o);
var res = MessagePackSerializer.Deserialize<MyClass>(bin);

Assert.Equal(o.LocalDateTime, res.LocalDateTime); // in DateTime format due to 'abc' being DateTime object
}
}
}
1 change: 1 addition & 0 deletions MessagePack.NodaTime/DurationMessagePackFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace MessagePack.NodaTime
{
[ExcludeFormatterFromSourceGeneratedResolver]
public sealed class DurationAsNanosecondsMessagePackFormatter : IMessagePackFormatter<Duration>
{
public static readonly DurationAsNanosecondsMessagePackFormatter Instance = new DurationAsNanosecondsMessagePackFormatter();
Expand Down
1 change: 1 addition & 0 deletions MessagePack.NodaTime/LocalDateMessagePackFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace MessagePack.NodaTime
{
// Not interoperable
[ExcludeFormatterFromSourceGeneratedResolver]
public sealed class LocalDateAsExtMessagePackFormatter : IMessagePackFormatter<LocalDate>
{
public static readonly LocalDateAsExtMessagePackFormatter Instance = new LocalDateAsExtMessagePackFormatter();
Expand Down
2 changes: 1 addition & 1 deletion MessagePack.NodaTime/MessagePack.NodaTime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MessagePack" Version="2.5.192" />
<PackageReference Include="MessagePack" Version="3.0.308" />
<PackageReference Include="NodaTime" Version="3.2.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions MessagePack.NodaTime/PeriodMessagePackFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace MessagePack.NodaTime
{
[ExcludeFormatterFromSourceGeneratedResolver]
public sealed class PeriodAsIsoStringMessagePackFormatter : IMessagePackFormatter<Period?>
{
public static readonly PeriodAsIsoStringMessagePackFormatter Instance = new PeriodAsIsoStringMessagePackFormatter();
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ or download directly from NuGet.
To use the NodaTime resolver, you will have to add it to the composite resolver, as shown in the example below:
```csharp
CompositeResolver.RegisterAndSetAsDefault(
BuiltinResolver.Instance,
NodatimeResolver.Instance,
AttributeFormatterResolver.Instance,
DynamicEnumAsStringResolver.Instance,
ContractlessStandardResolver.Instance
BuiltinResolver.Instance,
AttributeFormatterResolver.Instance,
SourceGeneratedFormatterResolver.Instance,
NodatimeResolver.Instance,
DynamicEnumAsStringResolver.Instance,
ContractlessStandardResolver.Instance
);
```
## Quick Start
Expand Down

0 comments on commit b526442

Please sign in to comment.