Skip to content

Commit cdbed4f

Browse files
committed
CSHARP-3058: Obsolete ReIndex helper method.
1 parent f74a311 commit cdbed4f

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16+
using System;
1617
using System.Threading;
1718
using System.Threading.Tasks;
1819
using MongoDB.Bson;
@@ -26,6 +27,7 @@ namespace MongoDB.Driver.Core.Operations
2627
/// <summary>
2728
/// Represents a reindex operation.
2829
/// </summary>
30+
[Obsolete("This class will be removed in a later version of the driver.")]
2931
public class ReIndexOperation : IWriteOperation<BsonDocument>
3032
{
3133
// fields

src/MongoDB.Driver.Legacy/MongoCollection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,14 +1833,17 @@ public ReadOnlyCollection<IEnumerator> ParallelScanAs(Type documentType, Paralle
18331833
/// Runs the ReIndex command on this collection.
18341834
/// </summary>
18351835
/// <returns>A CommandResult.</returns>
1836+
[Obsolete("This method will be removed in a later version of the driver.")]
18361837
public virtual CommandResult ReIndex()
18371838
{
18381839
return UsingImplicitSession(session => ReIndex(session));
18391840
}
18401841

18411842
private CommandResult ReIndex(IClientSessionHandle session)
18421843
{
1844+
#pragma warning disable 618
18431845
var operation = new ReIndexOperation(_collectionNamespace, GetMessageEncoderSettings());
1846+
#pragma warning restore 618
18441847
var result = ExecuteWriteOperation(session, operation);
18451848
return new CommandResult(result);
18461849
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace MongoDB.Driver.Core.Operations
2727
{
28+
#pragma warning disable 618
2829
public class ReIndexOperationTests : OperationTestBase
2930
{
3031
[Fact]
@@ -76,7 +77,7 @@ public void Execute_should_return_expected_result(
7677
[Values(false, true)]
7778
bool async)
7879
{
79-
RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
80+
RequireServer.Check().ClusterTypes(ClusterType.Standalone);
8081
EnsureCollectionExists();
8182
var subject = new ReIndexOperation(_collectionNamespace, _messageEncoderSettings);
8283

@@ -111,17 +112,21 @@ public void Execute_should_throw_when_binding_is_null(
111112
public void Execute_should_send_session_id_when_supported(
112113
[Values(false, true)] bool async)
113114
{
114-
RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
115+
RequireServer.Check().ClusterTypes(ClusterType.Standalone);
115116
EnsureCollectionExists();
117+
#pragma warning disable 618
116118
var subject = new ReIndexOperation(_collectionNamespace, _messageEncoderSettings);
119+
#pragma warning restore 618
117120

118121
VerifySessionIdWasSentWhenSupported(subject, "reIndex", async);
119122
}
120123

121124
[Fact]
122125
public void CreateCommand_should_return_expected_result()
123126
{
127+
#pragma warning disable 618
124128
var subject = new ReIndexOperation(_collectionNamespace, _messageEncoderSettings);
129+
#pragma warning restore 618
125130

126131
var result = subject.CreateCommand(null);
127132

@@ -141,4 +146,5 @@ public void EnsureCollectionExists()
141146
ExecuteOperation(operation);
142147
}
143148
}
149+
#pragma warning restore 618
144150
}

tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,7 @@ public void TestParallelScan()
29892989
[Fact]
29902990
public void TestReIndex()
29912991
{
2992-
if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
2992+
if (_primary.InstanceType == MongoServerInstanceType.StandAlone)
29932993
{
29942994
_collection.Drop();
29952995
_collection.Insert(new BsonDocument("x", 1));
@@ -2998,7 +2998,9 @@ public void TestReIndex()
29982998
// note: prior to 1.8.1 the reIndex command was returning duplicate ok elements
29992999
try
30003000
{
3001+
#pragma warning disable 618
30013002
var result = _collection.ReIndex();
3003+
#pragma warning restore 618
30023004
Assert.Equal(2, result.Response["nIndexes"].ToInt32());
30033005
Assert.Equal(2, result.Response["nIndexesWas"].ToInt32());
30043006
}

0 commit comments

Comments
 (0)