Skip to content

Commit 8c5ba62

Browse files
committed
CSHARP-2214: Deprecate snapshot option.
1 parent 38033d4 commit 8c5ba62

File tree

7 files changed

+34
-1
lines changed

7 files changed

+34
-1
lines changed

src/MongoDB.Driver.Core/Core/Operations/FindCommandOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ public int? Skip
395395
/// <value>
396396
/// Whether to use snapshot behavior.
397397
/// </value>
398+
[Obsolete("Snapshot was deprecated in server version 3.7.4.")]
398399
public bool? Snapshot
399400
{
400401
get { return _snapshot; }

src/MongoDB.Driver.Core/Core/Operations/FindOpcodeOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ public int? Skip
336336
/// <value>
337337
/// Whether to use snapshot behavior.
338338
/// </value>
339+
[Obsolete("Snapshot was deprecated in server version 3.7.4.")]
339340
public bool? Snapshot
340341
{
341342
get { return _snapshot; }

src/MongoDB.Driver.Core/Core/Operations/FindOperation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ public int? Skip
394394
/// <value>
395395
/// Whether to use snapshot behavior.
396396
/// </value>
397+
[Obsolete("Snapshot was deprecated in server version 3.7.4.")]
397398
public bool? Snapshot
398399
{
399400
get { return _snapshot; }
@@ -477,6 +478,7 @@ internal FindCommandOperation<TDocument> CreateFindCommandOperation()
477478
}
478479
}
479480

481+
#pragma warning disable 618
480482
var operation = new FindCommandOperation<TDocument>(
481483
_collectionNamespace,
482484
_resultSerializer,
@@ -507,6 +509,7 @@ internal FindCommandOperation<TDocument> CreateFindCommandOperation()
507509
Snapshot = snapshot,
508510
Sort = sort
509511
};
512+
#pragma warning restore
510513

511514
return operation;
512515
}
@@ -522,6 +525,7 @@ internal FindOpcodeOperation<TDocument> CreateFindOpcodeOperation()
522525
throw new NotSupportedException($"OP_QUERY does not support collations.");
523526
}
524527

528+
#pragma warning disable 618
525529
var operation = new FindOpcodeOperation<TDocument>(
526530
_collectionNamespace,
527531
_resultSerializer,
@@ -551,6 +555,7 @@ internal FindOpcodeOperation<TDocument> CreateFindOpcodeOperation()
551555

552556
return operation;
553557
}
558+
#pragma warning restore
554559

555560
private IReadOperation<IAsyncCursor<TDocument>> CreateOperation(SemanticVersion serverVersion)
556561
{

src/MongoDB.Driver.Legacy/MongoCursor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ public virtual MongoCursor SetSkip(int skip)
688688
/// Sets the $snapshot option.
689689
/// </summary>
690690
/// <returns>The cursor (so you can chain method calls to it).</returns>
691+
[Obsolete("Snapshot was deprecated in server version 3.7.4.")]
691692
public virtual MongoCursor SetSnapshot()
692693
{
693694
if (_isFrozen) { ThrowFrozen(); }
@@ -1074,6 +1075,7 @@ public virtual MongoCursor<TDocument> SetSerializer(IBsonSerializer<TDocument> s
10741075
/// Sets the $snapshot option.
10751076
/// </summary>
10761077
/// <returns>The cursor (so you can chain method calls to it).</returns>
1078+
[Obsolete("Snapshot was deprecated in server version 3.7.4.")]
10771079
public new virtual MongoCursor<TDocument> SetSnapshot()
10781080
{
10791081
return (MongoCursor<TDocument>)base.SetSnapshot();

tests/MongoDB.Driver.Core.Tests/Core/Operations/FindCommandOperationTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ public void constructor_should_initialize_instance()
134134
subject.ShowRecordId.Should().NotHaveValue();
135135
subject.SingleBatch.Should().NotHaveValue();
136136
subject.Skip.Should().NotHaveValue();
137+
#pragma warning disable 618
137138
subject.Snapshot.Should().NotHaveValue();
139+
#pragma warning restore
138140
subject.Sort.Should().BeNull();
139141
}
140142

@@ -661,10 +663,12 @@ public void CreateCommand_should_return_expected_result_when_Snapshot_is_set(
661663
[Values(null, false, true)]
662664
bool? snapshot)
663665
{
666+
#pragma warning disable 618
664667
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
665668
{
666669
Snapshot = snapshot
667670
};
671+
#pragma warning restore
668672

669673
var connectionDescription = OperationTestHelper.CreateConnectionDescription();
670674
var session = OperationTestHelper.CreateSession();
@@ -1241,8 +1245,10 @@ public void Snapshot_get_and_set_should_work(
12411245
{
12421246
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
12431247

1248+
#pragma warning disable 618
12441249
subject.Snapshot = value;
12451250
var result = subject.Snapshot;
1251+
#pragma warning restore
12461252

12471253
result.Should().Be(value);
12481254
}

tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOpcodeOperationTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public void constructor_should_initialize_instance()
130130
subject.Projection.Should().BeNull();
131131
subject.ShowRecordId.Should().NotHaveValue();
132132
subject.Skip.Should().NotHaveValue();
133+
#pragma warning disable 618
133134
subject.Snapshot.Should().NotHaveValue();
135+
#pragma warning restore
134136
subject.Sort.Should().BeNull();
135137
}
136138

@@ -624,9 +626,11 @@ public void Snapshot_get_and_set_should_work(
624626
{
625627
var subject = new FindOpcodeOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
626628

629+
#pragma warning disable 618
627630
subject.Snapshot = value;
628631
var result = subject.Snapshot;
629-
632+
#pragma warning restore
633+
630634
result.Should().Be(value);
631635
}
632636

tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOperationTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ public void constructor_should_initialize_instance()
150150
subject.ShowRecordId.Should().NotHaveValue();
151151
subject.SingleBatch.Should().NotHaveValue();
152152
subject.Skip.Should().NotHaveValue();
153+
#pragma warning disable 618
153154
subject.Snapshot.Should().NotHaveValue();
155+
#pragma warning restore
154156
subject.Sort.Should().BeNull();
155157
}
156158

@@ -184,6 +186,7 @@ public void constructor_should_throw_when_resultSerializer_is_null()
184186
[Fact]
185187
public void CreateFindCommandOperation_should_return_expected_result()
186188
{
189+
#pragma warning disable 618
187190
var subject = new FindOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
188191
{
189192
AllowPartialResults = true,
@@ -211,6 +214,7 @@ public void CreateFindCommandOperation_should_return_expected_result()
211214
Snapshot = true,
212215
Sort = new BsonDocument("sort", 1)
213216
};
217+
#pragma warning restore
214218

215219
var result = subject.CreateFindCommandOperation();
216220

@@ -239,7 +243,9 @@ public void CreateFindCommandOperation_should_return_expected_result()
239243
result.ShowRecordId.Should().Be(subject.ShowRecordId);
240244
result.SingleBatch.Should().Be(subject.SingleBatch);
241245
result.Skip.Should().Be(subject.Skip);
246+
#pragma warning disable 618
242247
result.Snapshot.Should().Be(subject.Snapshot);
248+
#pragma warning restore
243249
result.Sort.Should().BeSameAs(subject.Sort);
244250
}
245251

@@ -273,13 +279,16 @@ public void CreateFindCommandOperation_should_return_expected_result_when_modifi
273279
result.Min.Should().Be(subject.Modifiers["$min"].AsBsonDocument);
274280
result.ReturnKey.Should().Be(subject.Modifiers["$returnKey"].ToBoolean());
275281
result.ShowRecordId.Should().Be(subject.Modifiers["$showDiskLoc"].AsBoolean);
282+
#pragma warning disable 618
276283
result.Snapshot.Should().Be(subject.Modifiers["$snapshot"].AsBoolean);
284+
#pragma warning restore
277285
result.Sort.Should().Be(subject.Modifiers["$orderby"].AsBsonDocument);
278286
}
279287

280288
[Fact]
281289
public void CreateFindOpcodeOperation_should_return_expected_result()
282290
{
291+
#pragma warning disable 618
283292
var subject = new FindOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
284293
{
285294
AllowPartialResults = true,
@@ -305,6 +314,7 @@ public void CreateFindOpcodeOperation_should_return_expected_result()
305314
Snapshot = true,
306315
Sort = new BsonDocument("sort", 1)
307316
};
317+
#pragma warning restore
308318

309319
var result = subject.CreateFindOpcodeOperation();
310320

@@ -329,7 +339,9 @@ public void CreateFindOpcodeOperation_should_return_expected_result()
329339
result.ResultSerializer.Should().Be(subject.ResultSerializer);
330340
result.ShowRecordId.Should().Be(subject.ShowRecordId);
331341
result.Skip.Should().Be(subject.Skip);
342+
#pragma warning disable 618
332343
result.Snapshot.Should().Be(subject.Snapshot);
344+
#pragma warning restore
333345
result.Sort.Should().Be(subject.Sort);
334346
}
335347

@@ -933,8 +945,10 @@ public void Snapshot_get_and_set_should_work(
933945
{
934946
var subject = new FindOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
935947

948+
#pragma warning disable 618
936949
subject.Snapshot = value;
937950
var result = subject.Snapshot;
951+
#pragma warning restore
938952

939953
result.Should().Be(value);
940954
}

0 commit comments

Comments
 (0)