Skip to content

Commit 9a4cf93

Browse files
authored
Adopt Serde preview8 (#7)
Adopt p8
1 parent 2841ca4 commit 9a4cf93

8 files changed

+22
-6
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageVersion Include="Serde" Version="[0.8.0-preview7]" />
7+
<PackageVersion Include="Serde" Version="[0.8.0-preview8]" />
88
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
99
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
1010
<PackageVersion Include="xunit" Version="2.9.0" />

src/reader/MsgPackReader.Collections.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ void ITypeDeserializer.SkipValue(ISerdeInfo info, int index)
134134
throw new NotImplementedException();
135135
}
136136

137-
DateTimeOffset ITypeDeserializer.ReadDateTimeOffset(ISerdeInfo info, int index)
137+
DateTime ITypeDeserializer.ReadDateTime(ISerdeInfo info, int index)
138138
{
139-
var next = deserializer.ReadDateTimeOffset();
139+
var next = deserializer.ReadDateTime();
140140
_index++;
141141
return next;
142142
}

src/reader/MsgPackReader.ITypeDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ int ITypeDeserializer.TryReadIndex(ISerdeInfo map, out string? errorName)
7474
}
7575
}
7676

77-
DateTimeOffset ITypeDeserializer.ReadDateTimeOffset(ISerdeInfo info, int index)
78-
=> deserializer.ReadDateTimeOffset();
77+
DateTime ITypeDeserializer.ReadDateTime(ISerdeInfo info, int index)
78+
=> deserializer.ReadDateTime();
7979

8080
void ITypeDeserializer.ReadBytes(ISerdeInfo info, int index, IBufferWriter<byte> writer)
8181
{

src/reader/MsgPackReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ private string ReadString()
351351
return str;
352352
}
353353

354-
public DateTimeOffset ReadDateTimeOffset()
354+
public DateTime ReadDateTime()
355355
{
356356
return DateTime.Parse(ReadString(), styles: DateTimeStyles.RoundtripKind);
357357
}

src/writer/MsgPackWriter.EnumSerializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public void WriteValue<T>(ISerdeInfo typeInfo, int index, T value, ISerialize<T>
3737
public void WriteU64(ISerdeInfo typeInfo, int index, ulong u64) => writer.WriteU64(u64);
3838
public void WriteDateTimeOffset(ISerdeInfo typeInfo, int index, DateTimeOffset dateTimeOffset)
3939
=> writer.WriteDateTimeOffset(dateTimeOffset);
40+
public void WriteDateTime(ISerdeInfo typeInfo, int index, DateTime dateTime)
41+
=> writer.WriteDateTime(dateTime);
4042
public void WriteBytes(ISerdeInfo typeInfo, int index, ReadOnlyMemory<byte> bytes)
4143
=> writer.WriteBytes(bytes);
4244
}

src/writer/MsgPackWriter.ISerializeCollection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public void WriteValue<T>(ISerdeInfo typeInfo, int index, T value, ISerialize<T>
6262
public void WriteDateTimeOffset(ISerdeInfo typeInfo, int index, DateTimeOffset dateTimeOffset)
6363
=> writer.WriteDateTimeOffset(dateTimeOffset);
6464

65+
public void WriteDateTime(ISerdeInfo typeInfo, int index, DateTime dateTime)
66+
=> writer.WriteDateTime(dateTime);
67+
6568
public void WriteBytes(ISerdeInfo typeInfo, int index, ReadOnlyMemory<byte> bytes)
6669
=> writer.WriteBytes(bytes);
6770
}

src/writer/MsgPackWriter.ISerializeType.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ void ITypeSerializer.WriteDateTimeOffset(ISerdeInfo typeInfo, int index, DateTim
118118
WriteDateTimeOffset(dt);
119119
}
120120

121+
void ITypeSerializer.WriteDateTime(ISerdeInfo typeInfo, int index, DateTime dt)
122+
{
123+
WritePropertyName(typeInfo, index);
124+
WriteDateTime(dt);
125+
}
126+
121127
void ITypeSerializer.WriteBytes(ISerdeInfo typeInfo, int index, ReadOnlyMemory<byte> bytes)
122128
{
123129
WritePropertyName(typeInfo, index);

src/writer/MsgPackWriter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public void WriteDateTimeOffset(DateTimeOffset dt)
142142
WriteString(dt.ToString("O"));
143143
}
144144

145+
public void WriteDateTime(DateTime dt)
146+
{
147+
WriteString(dt.ToString("O"));
148+
}
149+
145150
public void WriteBytes(ReadOnlyMemory<byte> bytes)
146151
{
147152
byte code = bytes.Length switch

0 commit comments

Comments
 (0)