Skip to content

Commit 816bff5

Browse files
committed
Update implementation to use a single attribute converter
- Update the tests to rely on metadata only as previous image is no longer available
1 parent c175e7d commit 816bff5

6 files changed

Lines changed: 151 additions & 217 deletions

File tree

Microsoft.Azure.Cosmos.sln

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29123.88
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36518.9 d17.14
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Cosmos", "Microsoft.Azure.Cosmos\src\Microsoft.Azure.Cosmos.csproj", "{36F6F6A8-CEC8-4261-9948-903495BC3C25}"
77
EndProject
@@ -181,6 +181,18 @@ Global
181181
{021DDC27-02EF-42C4-9A9E-AA600833C2EE}.Release|Any CPU.Build.0 = Release|Any CPU
182182
{021DDC27-02EF-42C4-9A9E-AA600833C2EE}.Release|x64.ActiveCfg = Release|Any CPU
183183
{021DDC27-02EF-42C4-9A9E-AA600833C2EE}.Release|x64.Build.0 = Release|Any CPU
184+
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|Any CPU.ActiveCfg = Debug|Any CPU
185+
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|Any CPU.Build.0 = Debug|Any CPU
186+
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|x64.ActiveCfg = Debug|Any CPU
187+
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|x64.Build.0 = Debug|Any CPU
188+
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
189+
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|Any CPU.Build.0 = Debug|Any CPU
190+
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|x64.ActiveCfg = Debug|Any CPU
191+
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|x64.Build.0 = Debug|Any CPU
192+
{D744906A-1091-403F-B0B6-794DE045169A}.Release|Any CPU.ActiveCfg = Release|Any CPU
193+
{D744906A-1091-403F-B0B6-794DE045169A}.Release|Any CPU.Build.0 = Release|Any CPU
194+
{D744906A-1091-403F-B0B6-794DE045169A}.Release|x64.ActiveCfg = Release|Any CPU
195+
{D744906A-1091-403F-B0B6-794DE045169A}.Release|x64.Build.0 = Release|Any CPU
184196
{CE4D6DA8-148D-4A98-943B-D8C2D532E1DC}.Cover|Any CPU.ActiveCfg = Debug|Any CPU
185197
{CE4D6DA8-148D-4A98-943B-D8C2D532E1DC}.Cover|Any CPU.Build.0 = Debug|Any CPU
186198
{CE4D6DA8-148D-4A98-943B-D8C2D532E1DC}.Cover|x64.ActiveCfg = Debug|Any CPU

Microsoft.Azure.Cosmos/src/Resource/FullFidelity/ChangeFeedMetadata.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace Microsoft.Azure.Cosmos
1616
/// The metadata of a change feed resource with <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.AllVersionsAndDeletes"/>.
1717
/// </summary>
1818
[System.Text.Json.Serialization.JsonConverter(typeof(ChangeFeedMetadataConverter))]
19-
[JsonConverter(typeof(ChangeFeedMetadataNewtonSoftConverter))]
2019
#if PREVIEW
2120
public
2221
#else
@@ -27,38 +26,48 @@ class ChangeFeedMetadata
2726
/// <summary>
2827
/// The change's conflict resolution timestamp.
2928
/// </summary>
29+
[JsonProperty(PropertyName = ChangeFeedMetadataFields.ConflictResolutionTimestamp, NullValueHandling = NullValueHandling.Ignore)]
30+
[JsonConverter(typeof(UnixDateTimeConverter))]
3031
public DateTime ConflictResolutionTimestamp { get; internal set; }
3132

3233
/// <summary>
3334
/// The current change's logical sequence number.
3435
/// </summary>
36+
[JsonProperty(PropertyName = ChangeFeedMetadataFields.Lsn, NullValueHandling = NullValueHandling.Ignore)]
3537
public long Lsn { get; internal set; }
3638

3739
/// <summary>
3840
/// The change's feed operation type <see cref="ChangeFeedOperationType"/>.
3941
/// </summary>
42+
[JsonProperty(PropertyName = ChangeFeedMetadataFields.OperationType, NullValueHandling = NullValueHandling.Ignore)]
43+
[JsonConverter(typeof(StringEnumConverter))]
4044
public ChangeFeedOperationType OperationType { get; internal set; }
4145

4246
/// <summary>
4347
/// The previous change's logical sequence number.
4448
/// </summary>
49+
[JsonProperty(PropertyName = ChangeFeedMetadataFields.PreviousImageLSN, NullValueHandling = NullValueHandling.Ignore)]
4550
public long PreviousLsn { get; internal set; }
4651

4752
/// <summary>
4853
/// Used to distinguish explicit deletes (e.g. via DeleteItem) from deletes caused by TTL expiration (a collection may define time-to-live policy for documents).
4954
/// </summary>
55+
[JsonProperty(PropertyName = ChangeFeedMetadataFields.TimeToLiveExpired, NullValueHandling = NullValueHandling.Ignore)]
5056
public bool IsTimeToLiveExpired { get; internal set; }
5157

5258
/// <summary>
5359
/// Applicable for delete operations only, otherwise null.
5460
/// The id of the previous item version.
5561
/// </summary>
62+
[JsonProperty(PropertyName = ChangeFeedMetadataFields.Id, NullValueHandling = NullValueHandling.Ignore)]
5663
public string Id { get; internal set; }
5764

5865
/// <summary>
59-
/// Applicable for delete operations only, otherwise null.
66+
/// Applicable for delete operations only, otherwise null.
6067
/// The partition key of the previous item version. string is the partition key property name and object is the partition key property value. All levels of hierarchy will be represented in order if a HPK is used.
6168
/// </summary>
69+
[JsonProperty(PropertyName = ChangeFeedMetadataFields.PartitionKey, NullValueHandling = NullValueHandling.Ignore)]
70+
[JsonConverter(typeof(ListNewtonSoftConverter))]
6271
public List<(string, object)> PartitionKey { get; internal set; }
6372
}
6473
}

Microsoft.Azure.Cosmos/src/Resource/FullFidelity/Converters/ChangeFeedMetadataConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public override void Write(Utf8JsonWriter writer, ChangeFeedMetadata value, Json
141141
break;
142142

143143
default:
144-
throw new JsonException($"Unexpected value type '{objectValue.GetType()}' for PartitionKey property '{key}'.");
144+
throw new JsonException($"Unexpected value type '{objectValue.GetType()}' for PartitionKey property '{key}'.");
145145
}
146146
}
147147
writer.WriteEndObject();

Microsoft.Azure.Cosmos/src/Resource/FullFidelity/Converters/ChangeFeedMetadataNewtonSoftConverter.cs

Lines changed: 0 additions & 201 deletions
This file was deleted.

0 commit comments

Comments
 (0)