diff --git a/src/MongoDB.Bson/ObjectModel/BsonDocument.cs b/src/MongoDB.Bson/ObjectModel/BsonDocument.cs index 653f75bc870..6f07ad1c808 100644 --- a/src/MongoDB.Bson/ObjectModel/BsonDocument.cs +++ b/src/MongoDB.Bson/ObjectModel/BsonDocument.cs @@ -123,17 +123,6 @@ public BsonDocument(IEnumerable elements) AddRange(elements); } - /// - /// Initializes a new instance of the BsonDocument class and adds one or more elements. - /// - /// One or more elements to add to the document. - [Obsolete("Use BsonDocument(IEnumerable elements) instead.")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] - public BsonDocument(params BsonElement[] elements) - { - AddRange(elements); - } - /// /// Initializes a new instance of the BsonDocument class and creates and adds a new element. /// diff --git a/src/MongoDB.Driver.Encryption/AGENTS.md b/src/MongoDB.Driver.Encryption/AGENTS.md index 1ed677fb9ad..458734348eb 100644 --- a/src/MongoDB.Driver.Encryption/AGENTS.md +++ b/src/MongoDB.Driver.Encryption/AGENTS.md @@ -13,7 +13,7 @@ This project wraps **libmongocrypt** (the C library that implements CSFLE and Qu - `ClientEncryption` — explicit encryption surface, incl. `CreateDataKey`, `RewrapManyDataKey`, `Encrypt`, `EncryptExpression`, `Decrypt`, `GetKey`, `GetKeyByAlternateKeyName`, `AddAlternateKeyName`, `RemoveAlternateKeyName`, `DeleteKey`, `GetKeys`, `CreateEncryptedCollection`. All have sync + async pairs and accept a `CancellationToken`. Backed by `ExplicitEncryptionLibMongoCryptController`. - `ClientEncryptionOptions` — `KeyVaultClient` (typically a separate `IMongoClient` for the key vault), `KeyVaultNamespace`, `KmsProviders` (per-provider credentials), `TlsOptions`, `KeyExpiration` (DEK cache TTL; the C# property defaults to `null`, which causes libmongocrypt to apply its 60-second default; `Zero` = never expire). Validates KMS option values are `byte[]` or `string`; rejects per-provider TLS settings that supply a `ServerCertificateValidationCallback` (insecure-by-construction). Other `SslSettings` knobs (custom CAs via the standard validation callback chain, client certificates, etc.) are not blocked. -- `EncryptOptions`, `EncryptionAlgorithm`, `DataKeyOptions`, `RewrapManyDataKeyOptions`, `RangeOptions`, `TextOptions` (with `PrefixOptions`, `SubstringOptions`, `SuffixOptions` for the QE TextPreview surface), `CsfleSchemaBuilder` (a fluent builder for **CSFLE** `$jsonSchema`-style schemas suitable for `AutoEncryptionOptions.SchemaMap`; QE encrypted-field schemas are configured via `AutoEncryptionOptions.EncryptedFieldsMap`, not via this builder). +- `EncryptOptions`, `EncryptionAlgorithm`, `DataKeyOptions`, `RewrapManyDataKeyOptions`, `RangeOptions`, `StringOptions` (with `PrefixOptions`, `SubstringOptions`, `SuffixOptions` for the QE String surface), `CsfleSchemaBuilder` (a fluent builder for **CSFLE** `$jsonSchema`-style schemas suitable for `AutoEncryptionOptions.SchemaMap`; QE encrypted-field schemas are configured via `AutoEncryptionOptions.EncryptedFieldsMap`, not via this builder). ## Controllers @@ -49,13 +49,13 @@ libmongocrypt asks managed code for AES / HMAC / random / RSA signing via callba - `CsfleSchemaBuilder` — fluent builder for **CSFLE** `$jsonSchema`-style schemas (composes with `AutoEncryptionOptions.SchemaMap`). The duplicate-namespace check is incidental: `Encrypt(CollectionNamespace, Action>)` calls `_schemas.Add(...)` on the underlying `Dictionary`, which throws `ArgumentException` on a duplicate key — there is no explicit validation step beyond that. **Not** the entry point for Queryable Encryption — QE schemas are configured via `AutoEncryptionOptions.EncryptedFieldsMap`. - `EncryptionAlgorithm` is a single flat enum — values are not partitioned in the type system, only by usage convention: - **CSFLE-only by convention** — `AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic` (equality-queryable, same plaintext → same ciphertext), `AEAD_AES_256_CBC_HMAC_SHA_512_Random` (no queries possible). - - **QE-only by convention** — `Indexed` (equality with contention), `Range` (range queries), `TextPreview` (preview), `Unindexed`. Server-version availability (preview vs GA) for each algorithm is a server-side concern; consult the MongoDB server release notes rather than relying on driver-side enum metadata. The "Preview" suffix on `TextPreview` reflects the server's preview status — but `EncryptionAlgorithm` is a **public enum**, so the value itself is SemVer-covered: renaming or removing `TextPreview` (e.g. once the server feature GAs as `Text`) requires an `[Obsolete]` deprecation cycle, not an in-place rename. The migration shape is additive-then-deprecate: introduce a new `Text` enum member alongside `TextPreview`, mark `TextPreview` `[Obsolete]`, and only remove it in a later major version — never reuse the existing enum value, since the integer is part of the on-the-wire contract for any caller that has it baked in. + - **QE-only by convention** — `Indexed` (equality with contention), `Range` (range queries), `String` (prefix / substring / suffix queries, including the `*Preview` query types), `Unindexed`. Server-version availability (preview vs GA) for each algorithm is a server-side concern; consult the MongoDB server release notes rather than relying on driver-side enum metadata. Preview versus GA is expressed by the **query type** (`prefixPreview` vs `prefix`, and so on — see `ValidStringQueryTypes` in `EncryptOptions.cs`), not by a separate algorithm or options type. `EncryptionAlgorithm` is a **public enum**, so renaming or removing a member is SemVer-covered and needs an `[Obsolete]` cycle followed by removal in a major version, not an in-place rename. The integers are **not** part of the wire contract — `ConvertEnumAlgorithmToString` sends the member name as a string, and the enum declares no explicit values — so members may be removed without pinning the remaining ordinals. Contrast `CompressorType` in `Core/Compression/ICompressor.cs`, which does pin its values because there the integers are wire protocol IDs. Server-side enforcement decides which value is valid in a given context. Confusing CSFLE and QE algorithms is a recurring bug. ## Mongocryptd vs crypt_shared - `MongocryptdFactory` — spawns a local `mongocryptd` process if needed. Default URI `mongodb://localhost:27020`. Controlled by `extraOptions["mongocryptdURI"]`, `mongocryptdSpawnArgs`. Skipped if `BypassQueryAnalysis = true`. -- **`crypt_shared` is preferred** — it's a shared library loaded by libmongocrypt, no separate process. Set `CRYPT_SHARED_LIB_PATH` to point libmongocrypt at it. **QE (Indexed/Range/TextPreview) requires `crypt_shared`**; mongocryptd does not implement QE. +- **`crypt_shared` is preferred** — it's a shared library loaded by libmongocrypt, no separate process. Set `CRYPT_SHARED_LIB_PATH` to point libmongocrypt at it. **QE (Indexed/Range/String) requires `crypt_shared`**; mongocryptd does not implement QE. ## Threading & lifecycle @@ -70,7 +70,7 @@ libmongocrypt asks managed code for AES / HMAC / random / RSA signing via callba - **State-machine misuse.** Calling `Encrypt` / `Decrypt` before `InitContext`, or feeding wrong-shape input, corrupts the context. Always drive contexts to `DONE`. - **KMS credential expiry mid-operation.** AWS STS, Azure IMDS, GCP service tokens can expire. libmongocrypt asks for fresh credentials via `NEED_KMS_CREDENTIALS`; the controller must refetch and resupply. Failing to handle this looks like sporadic "auth failed" errors under load. - **DEK cache staleness.** `KeyExpiration` is the cache-pruning lever — TTL expiry evicts a DEK on next lookup, not in the background. Long-lived processes that never re-encrypt may accumulate cache entries. `RewrapManyDataKey` is **key rotation** (re-encrypts each DEK with a new KEK in the key vault); it does not itself prune the local DEK cache, but is the canonical way to rotate keys on a schedule — entries then expire normally per `KeyExpiration`. -- **CSFLE vs QE algorithms confused.** `Deterministic`/`Random` are CSFLE-only; `Indexed`/`Range`/`TextPreview`/`Unindexed` are QE-only. The wrong combination on the server side fails with cryptic schema errors. +- **CSFLE vs QE algorithms confused.** `Deterministic`/`Random` are CSFLE-only; `Indexed`/`Range`/`String`/`Unindexed` are QE-only. The wrong combination on the server side fails with cryptic schema errors. - **SafeHandle ordering bug.** A `ContextSafeHandle` outliving its parent `MongoCryptSafeHandle` dereferences a destroyed pointer. Don't rearrange disposal order without checking `GC.KeepAlive` calls. - **TLS callback security.** `ClientEncryptionOptions` rejects insecure TLS callbacks at construction. Don't add a "for testing" bypass that disables this — tests should use the mock KMS instead. diff --git a/src/MongoDB.Driver.Encryption/ClientEncryption.cs b/src/MongoDB.Driver.Encryption/ClientEncryption.cs index fd75d182f42..8315e2030da 100644 --- a/src/MongoDB.Driver.Encryption/ClientEncryption.cs +++ b/src/MongoDB.Driver.Encryption/ClientEncryption.cs @@ -79,27 +79,6 @@ public BsonDocument AddAlternateKeyName(Guid id, string alternateKeyName, Cancel public Task AddAlternateKeyNameAsync(Guid id, string alternateKeyName, CancellationToken cancellationToken = default) => _libMongoCryptController.AddAlternateKeyNameAsync(id, alternateKeyName, cancellationToken); - /// - /// Create encrypted collection. - /// - /// The database. - /// The collection name. - /// The create collection options. - /// The kms provider. - /// The datakey options. - /// The cancellation token. - /// The operation result. - /// - /// If EncryptionFields contains a keyId with a null value, a data key will be automatically generated and returned in . - /// - [Obsolete("Use the overload with masterKey instead.")] - public CreateEncryptedCollectionResult CreateEncryptedCollection(IMongoDatabase database, string collectionName, CreateCollectionOptions createCollectionOptions, string kmsProvider, DataKeyOptions dataKeyOptions, CancellationToken cancellationToken = default) - { - Ensure.That(dataKeyOptions?.AlternateKeyNames == null && dataKeyOptions?.KeyMaterial == null, $"{nameof(CreateEncryptedCollection)} supports only {nameof(dataKeyOptions.MasterKey)} in {nameof(DataKeyOptions)}."); - - return CreateEncryptedCollection(database, collectionName, createCollectionOptions, kmsProvider, dataKeyOptions?.MasterKey, cancellationToken); - } - /// /// Create encrypted collection. /// @@ -142,27 +121,6 @@ public CreateEncryptedCollectionResult CreateEncryptedCollection(IMongoDatabase return new CreateEncryptedCollectionResult(encryptedFields); } - /// - /// Create encrypted collection. - /// - /// The database. - /// The collection name. - /// The create collection options. - /// The kms provider. - /// The datakey options. - /// The cancellation token. - /// The operation result. - /// - /// If EncryptionFields contains a keyId with a null value, a data key will be automatically generated and returned in . - /// - [Obsolete("Use the overload with masterKey instead.")] - public Task CreateEncryptedCollectionAsync(IMongoDatabase database, string collectionName, CreateCollectionOptions createCollectionOptions, string kmsProvider, DataKeyOptions dataKeyOptions, CancellationToken cancellationToken = default) - { - Ensure.That(dataKeyOptions?.AlternateKeyNames == null && dataKeyOptions?.KeyMaterial == null, $"{nameof(CreateEncryptedCollection)} supports only {nameof(dataKeyOptions.MasterKey)} in {nameof(DataKeyOptions)}."); - - return CreateEncryptedCollectionAsync(database, collectionName, createCollectionOptions, kmsProvider, dataKeyOptions?.MasterKey, cancellationToken); - } - /// /// Create encrypted collection. /// diff --git a/src/MongoDB.Driver.Encryption/EncryptOptions.cs b/src/MongoDB.Driver.Encryption/EncryptOptions.cs index e9705b1d2bd..145cb8af971 100644 --- a/src/MongoDB.Driver.Encryption/EncryptOptions.cs +++ b/src/MongoDB.Driver.Encryption/EncryptOptions.cs @@ -96,7 +96,7 @@ public RangeOptions( /// Prefix options. /// /// - /// PrefixOptions is used with StringOptions (or the deprecated TextOptions) and provides further options to support "prefix" and "prefixPreview" queries. + /// PrefixOptions is used with StringOptions and provides further options to support "prefix" and "prefixPreview" queries. /// public sealed class PrefixOptions { @@ -140,7 +140,7 @@ public PrefixOptions(int strMaxQueryLength, int strMinQueryLength) /// Substring options. /// /// - /// SubstringOptions is used with StringOptions (or the deprecated TextOptions) and provides further options to support "substring" and "substringPreview" queries. + /// SubstringOptions is used with StringOptions and provides further options to support "substring" and "substringPreview" queries. /// public sealed class SubstringOptions { @@ -199,7 +199,7 @@ public SubstringOptions(int strMaxLength, int strMaxQueryLength, int strMinQuery /// Suffix options. /// /// - /// SuffixOptions is used with StringOptions (or the deprecated TextOptions) and provides further options to support "suffix" and "suffixPreview" queries. + /// SuffixOptions is used with StringOptions and provides further options to support "suffix" and "suffixPreview" queries. /// public sealed class SuffixOptions { @@ -302,69 +302,6 @@ public StringOptions( public SuffixOptions SuffixOptions => _suffixOptions; } - /// - /// Text options. - /// - /// - /// This is a deprecated alias for . Use instead. - /// - [Obsolete("Use StringOptions instead.")] - public sealed class TextOptions - { - private readonly bool _caseSensitive; - private readonly bool _diacriticSensitive; - private readonly PrefixOptions _prefixOptions; - private readonly SubstringOptions _substringOptions; - private readonly SuffixOptions _suffixOptions; - - /// - /// Initializes a new instance of the class. - /// - /// The indicator of whether text indexes for this field are case-sensitive. - /// The indicator of whether text indexes for this field are diacritic sensitive. - /// The prefix options. - /// The substring options. - /// The suffix options. - public TextOptions( - bool caseSensitive, - bool diacriticSensitive, - Optional prefixOptions = default, - Optional substringOptions = default, - Optional suffixOptions = default) - { - _caseSensitive = caseSensitive; - _diacriticSensitive = diacriticSensitive; - _prefixOptions = prefixOptions.WithDefault(null); - _substringOptions = substringOptions.WithDefault(null); - _suffixOptions = suffixOptions.WithDefault(null); - } - - /// - /// Gets whether text indexes for this field are case-sensitive. - /// - public bool CaseSensitive => _caseSensitive; - - /// - /// Gets whether text indexes for this field are diacritic sensitive. - /// - public bool DiacriticSensitive => _diacriticSensitive; - - /// - /// Gets the prefix options. - /// - public PrefixOptions PrefixOptions => _prefixOptions; - - /// - /// Gets the substring options. - /// - public SubstringOptions SubstringOptions => _substringOptions; - - /// - /// Gets the suffix options. - /// - public SuffixOptions SuffixOptions => _suffixOptions; - } - /// /// Encryption options for explicit encryption. /// @@ -376,9 +313,6 @@ private static string ConvertEnumAlgorithmToString(EncryptionAlgorithm encryptio { EncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic => "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic", EncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Random => "AEAD_AES_256_CBC_HMAC_SHA_512-Random", -#pragma warning disable CS0618 // TextPreview is a deprecated alias for String and is translated to "String". - EncryptionAlgorithm.TextPreview => EncryptionAlgorithm.String.ToString(), -#pragma warning restore CS0618 _ => encryptionAlgorithm.ToString(), }; @@ -392,9 +326,6 @@ private static string ConvertEnumAlgorithmToString(EncryptionAlgorithm encryptio private readonly Guid? _keyId; private readonly RangeOptions _rangeOptions; private readonly StringOptions _stringOptions; -#pragma warning disable CS0618 // _textOptions is the deprecated alias for _stringOptions. - private readonly TextOptions _textOptions; -#pragma warning restore CS0618 private readonly string _queryType; // constructors @@ -469,43 +400,6 @@ public EncryptOptions( EnsureThatOptionsAreValid(); } - /// - /// Initializes a new instance of the class. - /// - /// The encryption algorithm. - /// The text options. - /// The alternate key name. - /// The contention factor. - /// The key Id. - /// The query type. - [Obsolete("Use the StringOptions overload instead.")] - public EncryptOptions( - string algorithm, - TextOptions textOptions, - Optional alternateKeyName = default, - Optional contentionFactor = default, - Optional keyId = default, - Optional queryType = default) - { - Ensure.IsNotNull(algorithm, nameof(algorithm)); - Ensure.IsNotNull(textOptions, nameof(textOptions)); - if (Enum.TryParse(algorithm, out var @enum)) - { - _algorithm = ConvertEnumAlgorithmToString(@enum); - } - else - { - _algorithm = algorithm; - } - - _alternateKeyName = alternateKeyName.WithDefault(null); - _contentionFactor = contentionFactor.WithDefault(null); - _keyId = keyId.WithDefault(null); - _textOptions = textOptions; - _queryType = queryType.WithDefault(null); - EnsureThatOptionsAreValid(); - } - /// /// Initializes a new instance of the class. /// @@ -558,33 +452,6 @@ public EncryptOptions( { } - /// - /// Initializes a new instance of the class. - /// - /// The encryption algorithm. - /// The text options. - /// The alternate key name. - /// The key Id. - /// The contention factor. - /// The query type. - [Obsolete("Use the StringOptions overload instead.")] - public EncryptOptions( - EncryptionAlgorithm algorithm, - TextOptions textOptions, - Optional alternateKeyName = default, - Optional keyId = default, - Optional contentionFactor = default, - Optional queryType = default) - : this( - algorithm: ConvertEnumAlgorithmToString(algorithm), - textOptions, - alternateKeyName, - contentionFactor, - keyId, - queryType) - { - } - // public properties /// /// Gets the algorithm. @@ -651,15 +518,6 @@ public EncryptOptions( /// public StringOptions StringOptions => _stringOptions; - /// - /// Gets the text options. - /// - /// - /// This is a deprecated alias for . Use instead. - /// - [Obsolete("Use StringOptions instead.")] - public TextOptions TextOptions => _textOptions; - /// /// Returns a new EncryptOptions instance with some settings changed. /// @@ -714,39 +572,6 @@ public EncryptOptions With( stringOptions: stringOptions); } - /// - /// Returns a new EncryptOptions instance with some settings changed. - /// - /// The text options. - /// The encryption algorithm. - /// The alternate key name. - /// The keyId. - /// The contention factor. - /// The query type. - /// A new EncryptOptions instance. - [Obsolete("Use the StringOptions overload instead.")] - public EncryptOptions With( - TextOptions textOptions, - Optional algorithm = default, - Optional alternateKeyName = default, - Optional keyId = default, - Optional contentionFactor = default, - Optional queryType = default) - { - return new EncryptOptions( - algorithm: algorithm.WithDefault(_algorithm), - alternateKeyName: alternateKeyName.WithDefault(_alternateKeyName), - contentionFactor: contentionFactor.WithDefault(_contentionFactor), - keyId: keyId.WithDefault(_keyId), - queryType: queryType.WithDefault(_queryType), - textOptions: textOptions); - } - - // internal methods -#pragma warning disable CS0618 // marshal whichever of StringOptions/TextOptions was set. - internal BsonDocument GetStringOptionsDocument() => _stringOptions?.CreateDocument() ?? _textOptions?.CreateDocument(); -#pragma warning restore CS0618 - // private methods private void EnsureThatOptionsAreValid() { @@ -756,8 +581,6 @@ private void EnsureThatOptionsAreValid() Ensure.That(!(_queryType != null && (_algorithm != EncryptionAlgorithm.Indexed.ToString() && _algorithm != EncryptionAlgorithm.Range.ToString() && _algorithm != EncryptionAlgorithm.String.ToString())), "QueryType only applies for Indexed, Range, or String algorithm."); Ensure.That(!(_rangeOptions != null && _algorithm != EncryptionAlgorithm.Range.ToString()), "RangeOptions only applies for Range algorithm."); Ensure.That(!(_stringOptions != null && _algorithm != EncryptionAlgorithm.String.ToString()), "StringOptions only applies for String algorithm."); -#pragma warning disable CS0618 // _textOptions is the deprecated alias; validate whichever options were set. - Ensure.That(!(_textOptions != null && _algorithm != EncryptionAlgorithm.String.ToString()), "TextOptions only applies for String algorithm."); if (_algorithm == EncryptionAlgorithm.String.ToString() && _queryType != null) { @@ -766,19 +589,18 @@ private void EnsureThatOptionsAreValid() $"QueryType '{_queryType}' is not valid for String algorithm. Use: {string.Join(", ", ValidStringQueryTypes)}."); } - if ((_stringOptions != null || _textOptions != null) && _queryType != null) + if (_stringOptions != null && _queryType != null) { Ensure.That( - !((_queryType == "prefix" || _queryType == "prefixPreview") && (_stringOptions?.PrefixOptions ?? _textOptions?.PrefixOptions) == null), + !((_queryType == "prefix" || _queryType == "prefixPreview") && _stringOptions.PrefixOptions == null), "PrefixOptions must be set when queryType is 'prefix' or 'prefixPreview'"); Ensure.That( - !((_queryType == "substring" || _queryType == "substringPreview") && (_stringOptions?.SubstringOptions ?? _textOptions?.SubstringOptions) == null), + !((_queryType == "substring" || _queryType == "substringPreview") && _stringOptions.SubstringOptions == null), "SubstringOptions must be set when queryType is 'substring' or 'substringPreview'"); Ensure.That( - !((_queryType == "suffix" || _queryType == "suffixPreview") && (_stringOptions?.SuffixOptions ?? _textOptions?.SuffixOptions) == null), + !((_queryType == "suffix" || _queryType == "suffixPreview") && _stringOptions.SuffixOptions == null), "SuffixOptions must be set when queryType is 'suffix' or 'suffixPreview'"); } -#pragma warning restore CS0618 } } } diff --git a/src/MongoDB.Driver.Encryption/EncryptionAlgorithm.cs b/src/MongoDB.Driver.Encryption/EncryptionAlgorithm.cs index 97a7f36c903..c0b48a1d2a4 100644 --- a/src/MongoDB.Driver.Encryption/EncryptionAlgorithm.cs +++ b/src/MongoDB.Driver.Encryption/EncryptionAlgorithm.cs @@ -57,15 +57,6 @@ public enum EncryptionAlgorithm /// Range, - /// - /// TextPreview algorithm. - /// - /// - /// This is a deprecated alias for and is translated to "String". Use instead. - /// - [Obsolete("Use String instead.")] - TextPreview, - /// /// String algorithm. /// diff --git a/src/MongoDB.Driver.Encryption/EncryptionOptionsExtensions.cs b/src/MongoDB.Driver.Encryption/EncryptionOptionsExtensions.cs index 9beb844cbfe..529ed2a7824 100644 --- a/src/MongoDB.Driver.Encryption/EncryptionOptionsExtensions.cs +++ b/src/MongoDB.Driver.Encryption/EncryptionOptionsExtensions.cs @@ -30,47 +30,34 @@ public static BsonDocument CreateDocument(this RangeOptions rangeOptions) => }; public static BsonDocument CreateDocument(this StringOptions stringOptions) => - CreateStringOptionsDocument(stringOptions.CaseSensitive, stringOptions.DiacriticSensitive, stringOptions.PrefixOptions, stringOptions.SubstringOptions, stringOptions.SuffixOptions); - -#pragma warning disable CS0618 // TextOptions is the deprecated alias for StringOptions. - public static BsonDocument CreateDocument(this TextOptions textOptions) => - CreateStringOptionsDocument(textOptions.CaseSensitive, textOptions.DiacriticSensitive, textOptions.PrefixOptions, textOptions.SubstringOptions, textOptions.SuffixOptions); -#pragma warning restore CS0618 - - private static BsonDocument CreateStringOptionsDocument( - bool caseSensitive, - bool diacriticSensitive, - PrefixOptions prefixOptions, - SubstringOptions substringOptions, - SuffixOptions suffixOptions) => new() { - { "caseSensitive", caseSensitive }, - { "diacriticSensitive", diacriticSensitive }, + { "caseSensitive", stringOptions.CaseSensitive }, + { "diacriticSensitive", stringOptions.DiacriticSensitive }, { "prefix", () => new BsonDocument { - { "strMaxQueryLength", prefixOptions.StrMaxQueryLength }, - { "strMinQueryLength", prefixOptions.StrMinQueryLength } + { "strMaxQueryLength", stringOptions.PrefixOptions.StrMaxQueryLength }, + { "strMinQueryLength", stringOptions.PrefixOptions.StrMinQueryLength } }, - prefixOptions != null + stringOptions.PrefixOptions != null }, { "substring", () => new BsonDocument { - { "strMaxLength", substringOptions.StrMaxLength }, - { "strMaxQueryLength", substringOptions.StrMaxQueryLength }, - { "strMinQueryLength", substringOptions.StrMinQueryLength } + { "strMaxLength", stringOptions.SubstringOptions.StrMaxLength }, + { "strMaxQueryLength", stringOptions.SubstringOptions.StrMaxQueryLength }, + { "strMinQueryLength", stringOptions.SubstringOptions.StrMinQueryLength } }, - substringOptions != null + stringOptions.SubstringOptions != null }, { "suffix", () => new BsonDocument { - { "strMaxQueryLength", suffixOptions.StrMaxQueryLength }, - { "strMinQueryLength", suffixOptions.StrMinQueryLength } + { "strMaxQueryLength", stringOptions.SuffixOptions.StrMaxQueryLength }, + { "strMinQueryLength", stringOptions.SuffixOptions.StrMinQueryLength } }, - suffixOptions != null + stringOptions.SuffixOptions != null } }; } diff --git a/src/MongoDB.Driver.Encryption/ExplicitEncryptionLibMongoCryptController.cs b/src/MongoDB.Driver.Encryption/ExplicitEncryptionLibMongoCryptController.cs index ef1127936e9..be0361b53ca 100644 --- a/src/MongoDB.Driver.Encryption/ExplicitEncryptionLibMongoCryptController.cs +++ b/src/MongoDB.Driver.Encryption/ExplicitEncryptionLibMongoCryptController.cs @@ -232,7 +232,7 @@ public BsonValue EncryptField( encryptOptions.Algorithm, wrappedValueBytes, ToBsonIfNotNull(encryptOptions.RangeOptions?.CreateDocument()), - ToBsonIfNotNull(encryptOptions.GetStringOptionsDocument()), + ToBsonIfNotNull(encryptOptions.StringOptions?.CreateDocument()), isExpressionMode); using (context) @@ -268,7 +268,7 @@ public async Task EncryptFieldAsync( encryptOptions.Algorithm, wrappedValueBytes, ToBsonIfNotNull(encryptOptions.RangeOptions?.CreateDocument()), - ToBsonIfNotNull(encryptOptions.GetStringOptionsDocument()), + ToBsonIfNotNull(encryptOptions.StringOptions?.CreateDocument()), isExpressionMode); using (context) diff --git a/src/MongoDB.Driver/AggregateFluent.cs b/src/MongoDB.Driver/AggregateFluent.cs index 90bd9823ce1..fcd8b874e2f 100644 --- a/src/MongoDB.Driver/AggregateFluent.cs +++ b/src/MongoDB.Driver/AggregateFluent.cs @@ -369,11 +369,6 @@ public override IAggregateFluent UnionWith( return WithPipeline(_pipeline.UnionWith(withCollection, withPipeline)); } - public override IAggregateFluent Unwind(FieldDefinition field, IBsonSerializer newResultSerializer) - { - return WithPipeline(_pipeline.Unwind(field, new AggregateUnwindOptions { ResultSerializer = newResultSerializer })); - } - public override IAggregateFluent Unwind(FieldDefinition field, AggregateUnwindOptions options) { return WithPipeline(_pipeline.Unwind(field, options)); diff --git a/src/MongoDB.Driver/AggregateFluentBase.cs b/src/MongoDB.Driver/AggregateFluentBase.cs index 4aad9f8a97e..ff23efa44e8 100644 --- a/src/MongoDB.Driver/AggregateFluentBase.cs +++ b/src/MongoDB.Driver/AggregateFluentBase.cs @@ -316,9 +316,6 @@ public virtual IAggregateFluent UnionWith( throw new NotImplementedException(); } - /// - public abstract IAggregateFluent Unwind(FieldDefinition field, IBsonSerializer newResultSerializer); - /// public virtual IAggregateFluent Unwind(FieldDefinition field, AggregateUnwindOptions options) { diff --git a/src/MongoDB.Driver/AggregateOptions.cs b/src/MongoDB.Driver/AggregateOptions.cs index 55134aa07d4..a33f96c9dd4 100644 --- a/src/MongoDB.Driver/AggregateOptions.cs +++ b/src/MongoDB.Driver/AggregateOptions.cs @@ -36,7 +36,6 @@ public class AggregateOptions private TimeSpan? _maxTime; private TimeSpan? _timeout; private ExpressionTranslationOptions _translationOptions; - private bool? _useCursor; // implicit conversions /// @@ -147,14 +146,5 @@ public ExpressionTranslationOptions TranslationOptions set { _translationOptions = value; } } - /// - /// Gets or sets a value indicating whether to use a cursor. - /// - [Obsolete("Server versions 3.6 and newer always use a cursor.")] - public bool? UseCursor - { - get { return _useCursor; } - set { _useCursor = value; } - } } } diff --git a/src/MongoDB.Driver/BulkWriteInsertOneResult.cs b/src/MongoDB.Driver/BulkWriteInsertOneResult.cs index 290b65462ed..dc730409475 100644 --- a/src/MongoDB.Driver/BulkWriteInsertOneResult.cs +++ b/src/MongoDB.Driver/BulkWriteInsertOneResult.cs @@ -23,19 +23,6 @@ namespace MongoDB.Driver /// public class BulkWriteInsertOneResult { - /// - /// The id of the inserted document. - /// - [Obsolete("InsertedId is deprecated and will be removed in future versions. Use DocumentId instead.")] - public BsonValue InsertedId - { - get => BsonValue.Create(DocumentId); - init - { - DocumentId = value; - } - } - /// /// The id of the inserted document. /// diff --git a/src/MongoDB.Driver/Core/AGENTS.md b/src/MongoDB.Driver/Core/AGENTS.md index 74e9d6ed1f4..26d5cc776d5 100644 --- a/src/MongoDB.Driver/Core/AGENTS.md +++ b/src/MongoDB.Driver/Core/AGENTS.md @@ -38,8 +38,7 @@ This file covers the **Server Discovery And Monitoring (SDAM)** topology layer, - `WritableServerSelector` — returns only writable servers (Primaries in RS, all in Standalone/Sharded). - `LatencyLimitingServerSelector` — filters servers within `LocalThreshold` of the fastest server, reducing tail latency. - `EndPointServerSelector` — filters a specific server by endpoint (used internally for pinned connections). - - `DeprioritizedServersServerSelector` — deprioritizes known bad servers. - - `PriorityServerSelector` — `[Obsolete]`. The public, legacy form of the deprioritization filter: a standalone `public sealed` selector that takes a `deprioritizedServers` collection and removes those endpoints from the candidate set on sharded clusters. The internal replacement is `DeprioritizedServersServerSelector` (an `internal sealed` *composing* selector that wraps another `IServerSelector` and filters its output). Neither is related to replica-set priorities; `PriorityServerSelector` is slated for removal in a future release. + - `DeprioritizedServersServerSelector` — deprioritizes known bad servers. An `internal sealed` *composing* selector: it wraps another `IServerSelector` and filters that selector's output, removing deprioritized endpoints on sharded clusters. Despite the name, it has nothing to do with replica-set priorities. - `OperationsCountServerSelector` — load-balances by operation count (for load-balanced deployments). - `RandomServerSelector` — random tie-breaker when multiple servers are equally good. - `DelegateServerSelector` — wraps an arbitrary `Func<…>` for ad-hoc selection logic (rarely used in production code; useful for tests and bespoke deployments). @@ -288,7 +287,7 @@ This file covers the **Server Discovery And Monitoring (SDAM)** topology layer, - **`Ensure`** — precondition checks (NotNull, IsGreaterThanZero, etc.). - **`DnsClientWrapper`** — async DNS resolver. The implementation uses the `DnsClient` NuGet package (not `System.Net.Dns`) so SRV/TXT queries work consistently across platforms. Both `IDnsResolver` and `DnsClientWrapper` are `internal`; there is no public seam for plugging in a custom resolver. The interface exists so in-assembly tests (via `InternalsVisibleTo`) can substitute a fake — production code always goes through `DnsClientWrapper` from `DnsMonitor`. Past versions of this file claimed users could substitute a custom `IDnsResolver`; do not re-introduce that claim. - **`ExceptionMapper`** — classifies wire exceptions (network error, timeout, server error) into semantic types. -- **`Feature`** — checks server version for feature availability (e.g., "does this server support transactions?"). +- **`Feature`** — checks server version for feature availability (e.g., "does this server support client bulk write?"). Only features whose support varies across the server versions this driver supports belong here; once the driver's minimum server version passes a feature's floor, the entry is removed rather than left as a tautology. - **`EnvironmentVariableProvider`** — abstraction over `Environment.GetEnvironmentVariable` for testing. --- diff --git a/src/MongoDB.Driver/Core/ChangeStreamDocument.cs b/src/MongoDB.Driver/Core/ChangeStreamDocument.cs index f160bdf9485..c8925b316b4 100644 --- a/src/MongoDB.Driver/Core/ChangeStreamDocument.cs +++ b/src/MongoDB.Driver/Core/ChangeStreamDocument.cs @@ -93,38 +93,6 @@ public ChangeStreamDocument( /// public DatabaseNamespace DatabaseNamespace => GetValue(nameof(DatabaseNamespace), null); - /// - /// Gets the disambiguated paths if present. - /// - /// - /// The disambiguated paths. - /// - /// - /// - /// A document containing a map that associates an update path to an array containing the path components used in the update document. This data - /// can be used in combination with the other fields in an to determine the - /// actual path in the document that was updated. This is necessary in cases where a key contains dot-separated strings (i.e. { "a.b": "c" }) or - /// a document contains a numeric literal string key (i.e. { "a": { "0": "a" } }). Note that in this scenario, the numeric key can't be the top - /// level key because { "0": "a" } is not ambiguous - update paths would simply be '0' which is unambiguous because BSON documents cannot have - /// arrays at the top level. Each entry in the document maps an update path to an array which contains the actual path used when the document - /// was updated. For example, given a document with the following shape { "a": { "0": 0 } } and an update of { $inc: { "a.0": 1 } }, - /// would look like the following: - /// - /// - /// { - /// "a.0": ["a", "0"] - /// } - /// - /// - /// In each array, all elements will be returned as strings with the exception of array indices, which will be returned as 32-bit integers. - /// - /// - /// Added in MongoDB version 6.1.0. - /// - /// - [Obsolete("DisambiguatedPaths is obsolete and will be removed in a future version. Use instead.")] - public BsonDocument DisambiguatedPaths => null; - /// /// Gets the document key. /// diff --git a/src/MongoDB.Driver/Core/ChangeStreamUpdateDescription.cs b/src/MongoDB.Driver/Core/ChangeStreamUpdateDescription.cs index f8b5535e807..52f53d91cc9 100644 --- a/src/MongoDB.Driver/Core/ChangeStreamUpdateDescription.cs +++ b/src/MongoDB.Driver/Core/ChangeStreamUpdateDescription.cs @@ -93,7 +93,7 @@ public ChangeStreamUpdateDescription( /// level key because { "0": "a" } is not ambiguous - update paths would simply be '0' which is unambiguous because BSON documents cannot have /// arrays at the top level. Each entry in the document maps an update path to an array which contains the actual path used when the document /// was updated. For example, given a document with the following shape { "a": { "0": 0 } } and an update of { $inc: { "a.0": 1 } }, - /// would look like the following: + /// the disambiguated paths would look like the following: /// /// /// { diff --git a/src/MongoDB.Driver/Core/Clusters/ServerSelectors/PriorityServerSelector.cs b/src/MongoDB.Driver/Core/Clusters/ServerSelectors/PriorityServerSelector.cs deleted file mode 100644 index abde5d146bc..00000000000 --- a/src/MongoDB.Driver/Core/Clusters/ServerSelectors/PriorityServerSelector.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright 2010-present MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using MongoDB.Driver.Core.Misc; -using MongoDB.Driver.Core.Servers; - -namespace MongoDB.Driver.Core.Clusters.ServerSelectors -{ - /// - /// Represents a server selector that selects servers based on a collection of servers to deprioritize. - /// - [Obsolete("PriorityServerSelector is obsolete and will be removed in a future release.")] - public sealed class PriorityServerSelector : IServerSelector - { - private readonly IReadOnlyCollection _deprioritizedServers; - - /// - /// Initializes a new instance of the class. - /// - /// The collection of servers to deprioritize. - public PriorityServerSelector(IReadOnlyCollection deprioritizedServers) - { - _deprioritizedServers = Ensure.IsNotNullOrEmpty(deprioritizedServers, nameof(deprioritizedServers)) as IReadOnlyCollection; - } - - /// - public IEnumerable SelectServers(ClusterDescription cluster, IEnumerable servers) - { - // according to spec, we only do deprioritization in a sharded cluster. - if (cluster.Type != ClusterType.Sharded) - { - return servers; - } - - var filteredServers = servers.Where(description => _deprioritizedServers.All(d => d.EndPoint != description.EndPoint)).ToList(); - - return filteredServers.Any() ? filteredServers : servers; - } - - /// - public override string ToString() => $"PriorityServerSelector{{{{ Deprioritized servers: {string.Join(", ", _deprioritizedServers.Select(s => s.EndPoint))} }}}}"; - } -} diff --git a/src/MongoDB.Driver/Core/Configuration/ConnectionString.cs b/src/MongoDB.Driver/Core/Configuration/ConnectionString.cs index 7c8ee885d8d..2513d797167 100644 --- a/src/MongoDB.Driver/Core/Configuration/ConnectionString.cs +++ b/src/MongoDB.Driver/Core/Configuration/ConnectionString.cs @@ -499,21 +499,6 @@ public TimeSpan? SocketTimeout /// public string SrvServiceName => _srvServiceName; - /// - /// Gets whether to use SSL. - /// - [Obsolete("Use Tls instead.")] - public bool? Ssl - { - get { return _tls; } - } - - /// - /// Gets whether to verify SSL certificates. - /// - [Obsolete("Use TlsInsecure instead.")] - public bool? SslVerifyCertificate => !_tlsInsecure; - /// /// Gets the per-operation timeout. /// diff --git a/src/MongoDB.Driver/Core/Connections/ConnectionDescription.cs b/src/MongoDB.Driver/Core/Connections/ConnectionDescription.cs index d4de1486866..06b63b04625 100644 --- a/src/MongoDB.Driver/Core/Connections/ConnectionDescription.cs +++ b/src/MongoDB.Driver/Core/Connections/ConnectionDescription.cs @@ -36,7 +36,6 @@ public sealed class ConnectionDescription : IEquatable private readonly int _maxMessageSize; private readonly int _maxWireVersion; private readonly int _minWireVersion; - private readonly SemanticVersion _serverVersion; private readonly ObjectId? _serviceId; // constructors @@ -57,7 +56,6 @@ public ConnectionDescription(ConnectionId connectionId, HelloResult helloResult) _maxWireVersion = helloResult.MaxWireVersion; _minWireVersion = helloResult.MinWireVersion; _serviceId = helloResult.ServiceId; - _serverVersion = WireVersion.ToServerVersion(_maxWireVersion); } // properties @@ -157,18 +155,6 @@ public int MinWireVersion get { return _minWireVersion; } } - /// - /// Gets the server version. - /// - /// - /// The server version. - /// - [Obsolete("Use MaxWireVersion instead.")] - public SemanticVersion ServerVersion - { - get { return _serverVersion; } - } - /// /// Gets the service identifier. /// diff --git a/src/MongoDB.Driver/Core/Connections/ConnectionId.cs b/src/MongoDB.Driver/Core/Connections/ConnectionId.cs index 6ae0e2d8d09..18b6f684f3a 100644 --- a/src/MongoDB.Driver/Core/Connections/ConnectionId.cs +++ b/src/MongoDB.Driver/Core/Connections/ConnectionId.cs @@ -74,18 +74,6 @@ public ServerId ServerId get { return _serverId; } } - /// - /// Gets the local value. - /// - /// - /// The local value. - /// - [Obsolete("Use LongLocalValue instead.")] - public int LocalValue - { - get { return (int)_localValue; } - } - /// /// Gets the local value. /// @@ -97,18 +85,6 @@ public long LongLocalValue get { return _localValue; } } - /// - /// Gets the server value. - /// - /// - /// The server value. - /// - [Obsolete("Use LongServerValue instead.")] - public int? ServerValue - { - get { return (int?)_serverValue; } - } - /// /// Gets the server value. /// diff --git a/src/MongoDB.Driver/Core/DatabaseNamespace.cs b/src/MongoDB.Driver/Core/DatabaseNamespace.cs index 360a527065b..e2c0e2a8495 100644 --- a/src/MongoDB.Driver/Core/DatabaseNamespace.cs +++ b/src/MongoDB.Driver/Core/DatabaseNamespace.cs @@ -86,18 +86,6 @@ public string DatabaseName get { return _databaseName; } } - [Obsolete("This collection namespace was removed in server version 4.2. As such, this property will be removed in a later release.")] - internal CollectionNamespace SystemIndexesCollection - { - get { return new CollectionNamespace(this, "system.indexes"); } - } - - [Obsolete("This collection namespace was removed in server version 4.2. As such, this property will be removed in a later release.")] - internal CollectionNamespace SystemNamespacesCollection - { - get { return new CollectionNamespace(this, "system.namespaces"); } - } - // methods /// public bool Equals(DatabaseNamespace other) diff --git a/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesEvent.cs b/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesEvent.cs index f61acad279d..9527ebc4290 100644 --- a/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesEvent.cs +++ b/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesEvent.cs @@ -14,8 +14,6 @@ */ using System; -using System.Collections.Generic; -using System.Linq; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Servers; @@ -32,21 +30,6 @@ public struct ConnectionSendingMessagesEvent : IEvent private readonly int _requestId; private readonly DateTime _timestamp; - /// - /// Initializes a new instance of the struct. - /// - /// The connection identifier. - /// The request ids. - /// The operation identifier. - [Obsolete("Support for sending multiple messages has been removed, use the constructor with single requestId instead.")] - public ConnectionSendingMessagesEvent(ConnectionId connectionId, IReadOnlyList requestIds, long? operationId) - { - _connectionId = connectionId; - _requestId = requestIds.Single(); - _operationId = operationId; - _timestamp = DateTime.UtcNow; - } - /// /// Initializes a new instance of the struct. /// @@ -85,15 +68,6 @@ public int RequestId get { return _requestId; } } - /// - /// Gets the request ids. - /// - [Obsolete($"Support for sending multiple messages has been removed, use {nameof(RequestId)} instead.")] - public IReadOnlyList RequestIds - { - get { return [_requestId]; } - } - /// /// Gets the operation identifier. /// diff --git a/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesFailedEvent.cs b/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesFailedEvent.cs index fd9f9624d01..af701ec2e0c 100644 --- a/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesFailedEvent.cs +++ b/src/MongoDB.Driver/Core/Events/ConnectionSendingMessagesFailedEvent.cs @@ -14,8 +14,6 @@ */ using System; -using System.Collections.Generic; -using System.Linq; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Servers; @@ -33,23 +31,6 @@ public struct ConnectionSendingMessagesFailedEvent : IEvent private readonly int _requestId; private readonly DateTime _timestamp; - /// - /// Initializes a new instance of the struct. - /// - /// The connection identifier. - /// The request ids. - /// The exception. - /// The operation identifier. - [Obsolete("Support for sending multiple messages has been removed, use the constructor with single requestId instead.")] - public ConnectionSendingMessagesFailedEvent(ConnectionId connectionId, IReadOnlyList requestIds, Exception exception, long? operationId) - { - _connectionId = connectionId; - _requestId = requestIds.Single(); - _exception = exception; - _operationId = operationId; - _timestamp = DateTime.UtcNow; - } - /// /// Initializes a new instance of the struct. /// @@ -106,15 +87,6 @@ public int RequestId get { return _requestId; } } - /// - /// Gets the request ids. - /// - [Obsolete($"Support for sending multiple messages has been removed, use {nameof(RequestId)} instead.")] - public IReadOnlyList RequestIds - { - get { return [_requestId]; } - } - /// /// Gets the server identifier. /// diff --git a/src/MongoDB.Driver/Core/Events/ConnectionSentMessagesEvent.cs b/src/MongoDB.Driver/Core/Events/ConnectionSentMessagesEvent.cs index 6e66e122339..a8312add5a8 100644 --- a/src/MongoDB.Driver/Core/Events/ConnectionSentMessagesEvent.cs +++ b/src/MongoDB.Driver/Core/Events/ConnectionSentMessagesEvent.cs @@ -14,8 +14,6 @@ */ using System; -using System.Collections.Generic; -using System.Linq; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Servers; @@ -35,27 +33,6 @@ public struct ConnectionSentMessagesEvent : IEvent private readonly int _requestId; private readonly DateTime _timestamp; - /// - /// Initializes a new instance of the struct. - /// - /// The connection identifier. - /// The request ids. - /// The length. - /// The duration of time spent on the network. - /// The duration of time spent serializing the messages. - /// The operation identifier. - [Obsolete("Support for sending multiple messages has been removed, use the constructor with single requestId instead.")] - public ConnectionSentMessagesEvent(ConnectionId connectionId, IReadOnlyList requestIds, int length, TimeSpan networkDuration, TimeSpan serializationDuration, long? operationId) - { - _connectionId = connectionId; - _requestId = requestIds.Single(); - _length = length; - _networkDuration = networkDuration; - _serializationDuration = serializationDuration; - _operationId = operationId; - _timestamp = DateTime.UtcNow; - } - /// /// Initializes a new instance of the struct. /// @@ -140,15 +117,6 @@ public int RequestId get { return _requestId; } } - /// - /// Gets the request ids. - /// - [Obsolete($"Support for sending multiple messages has been removed, use {nameof(RequestId)} instead.")] - public IReadOnlyList RequestIds - { - get { return [_requestId]; } - } - /// /// Gets the server identifier. /// diff --git a/src/MongoDB.Driver/Core/Events/ServerHeartbeatFailedEvent.cs b/src/MongoDB.Driver/Core/Events/ServerHeartbeatFailedEvent.cs index 1ab8bb865cc..acd43c902c9 100644 --- a/src/MongoDB.Driver/Core/Events/ServerHeartbeatFailedEvent.cs +++ b/src/MongoDB.Driver/Core/Events/ServerHeartbeatFailedEvent.cs @@ -31,22 +31,6 @@ public struct ServerHeartbeatFailedEvent : IEvent private readonly Exception _exception; private readonly DateTime _timestamp; - /// - /// Initializes a new instance of the struct. - /// - /// The connection identifier. - /// The exception. - /// The awaited flag. - [Obsolete("Use the other contstructor instead")] - public ServerHeartbeatFailedEvent(ConnectionId connectionId, Exception exception, bool awaited) - { - _awaited = awaited; - _connectionId = connectionId; - _duration = TimeSpan.MinValue; - _exception = exception; - _timestamp = DateTime.UtcNow; - } - /// /// Initializes a new instance of the struct. /// diff --git a/src/MongoDB.Driver/Core/Misc/BatchableSource.cs b/src/MongoDB.Driver/Core/Misc/BatchableSource.cs index 4452dac3a99..85726b51c65 100644 --- a/src/MongoDB.Driver/Core/Misc/BatchableSource.cs +++ b/src/MongoDB.Driver/Core/Misc/BatchableSource.cs @@ -46,30 +46,6 @@ private static IReadOnlyList EnumeratorToList(IEnumerator enumerator) private int _processedCount; // constructors - /// - /// Initializes a new instance of the class. - /// - /// - /// Use this overload when you know the batch is small and won't have to be broken up into sub-batches. - /// In that case using this overload is simpler than using an enumerator and using the other constructor. - /// - /// The single batch. - [Obsolete("Use one of the other constructors instead.")] - public BatchableSource(IEnumerable batch) - : this(Ensure.IsNotNull(batch, nameof(batch)).ToList(), canBeSplit: true) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The enumerator that will provide the items for the batch. - [Obsolete("Use one of the other constructors instead.")] - public BatchableSource(IEnumerator enumerator) - : this(EnumeratorToList(Ensure.IsNotNull(enumerator, nameof(enumerator))), canBeSplit: true) - { - } - /// /// Initializes a new instance of the class. /// diff --git a/src/MongoDB.Driver/Core/Misc/Feature.cs b/src/MongoDB.Driver/Core/Misc/Feature.cs index 9e00e0b83ce..bd3c8ab2e52 100644 --- a/src/MongoDB.Driver/Core/Misc/Feature.cs +++ b/src/MongoDB.Driver/Core/Misc/Feature.cs @@ -42,12 +42,6 @@ public class Feature /// public static Feature AggregateOptionsLet { get; } = new("AggregateOptionsLet", WireVersion.Server50); - /// - /// Gets the aggregate merge feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature AggregateMerge { get; } = new("AggregateMerge", WireVersion.Server42); - /// /// Gets the aggregate out on secondary feature. /// @@ -63,12 +57,6 @@ public class Feature /// public static Feature AggregateOutToDifferentDatabase { get; } = new("AggregateOutToDifferentDatabase", WireVersion.Server44); - /// - /// Gets the aggregate toString feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature AggregateToString { get; } = new("AggregateToString", WireVersion.Server40); - /// /// Gets the aggregate unionWith feature. /// @@ -84,24 +72,6 @@ public class Feature /// public static Feature BitwiseOperators { get; } = new("BitwiseOperators", WireVersion.Server63); - /// - /// Gets the change stream all changes for cluster feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ChangeStreamAllChangesForCluster { get; } = new("ChangeStreamAllChangesForCluster", WireVersion.Server40); - - /// - /// Gets the change stream for database feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ChangeStreamForDatabase { get; } = new("ChangeStreamForDatabase", WireVersion.Server40); - - /// - /// Gets the change stream post batch resume token feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ChangeStreamPostBatchResumeToken { get; } = new("ChangeStreamPostBatchResumeToken", WireVersion.Server40); - /// /// Gets the change stream pre post images feature. /// @@ -117,12 +87,6 @@ public class Feature /// public static Feature ClientBulkWrite { get; } = new("ClientBulkWrite", WireVersion.Server80); - /// - /// Gets the client side encryption feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ClientSideEncryption { get; } = new("ClientSideEncryption", WireVersion.Server42); - /// /// Gets the clustered indexes feature. /// @@ -163,12 +127,6 @@ public class Feature /// public static Feature CreateIndexCommitQuorum { get; } = new("CreateIndexCommitQuorum", WireVersion.Server44); - /// - /// Gets the create indexes using insert operations feature. - /// - [Obsolete("This feature was removed in server version 4.2. This property will be removed in the next major release.")] - public static Feature CreateIndexesUsingInsertOperations { get; } = new("CreateIndexesUsingInsertOperations", WireVersion.Zero, WireVersion.Server42); - /// /// Represents support for the $createObjectId operator feature. /// @@ -214,18 +172,6 @@ public class Feature /// public static Feature Csfle2QEv2StringPreviewAlgorithm { get; } = new("csfle2Qev2StringPreviewAlgorithm", WireVersion.Server82); - /// - /// Gets the csfle2 textPreview algorithm feature. - /// - [Obsolete("Use Csfle2QEv2StringPreviewAlgorithm instead.")] - public static Feature Csfle2QEv2TextPreviewAlgorithm { get; } = new("csfle2Qev2TextPreviewAlgorithm", WireVersion.Server82); - - /// - /// Gets the $dateFromString format argument feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature DateFromStringFormatArgument { get; } = new("DateFromStringFormatArgument", WireVersion.Server40); - /// /// Gets the date operators added in 5.0 feature. /// @@ -256,30 +202,6 @@ public class Feature /// public static Feature ElectionIdPriorityInSDAM { get; } = new("ElectionIdPriorityInSDAM ", WireVersion.Server60); - /// - /// Gets the eval feature. - /// - [Obsolete("This feature was removed in server version 4.2. This property will be removed in the next major release.")] - public static Feature Eval { get; } = new("Eval", WireVersion.Zero, WireVersion.Server42); - - /// - /// Gets the fail points block connection feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature FailPointsBlockConnection { get; } = new("FailPointsBlockConnection", WireVersion.Server42); - - /// - /// Gets the fail points fail command feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature FailPointsFailCommand { get; } = new("FailPointsFailCommand", WireVersion.Server40); - - /// - /// Gets the fail points fail command for sharded feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature FailPointsFailCommandForSharded { get; } = new("FailPointsFailCommandForSharded", WireVersion.Server42); - /// /// Gets filter limit feature. /// @@ -295,13 +217,6 @@ public class Feature /// public static Feature FindProjectionExpressions { get; } = new("FindProjectionExpressions", WireVersion.Server44); - /// - /// Gets the geoNear command feature. - /// - /// - [Obsolete("This feature was removed in server version 4.2. This property will be removed in the next major release.")] - public static Feature GeoNearCommand { get; } = new("GeoNearCommand", WireVersion.Zero, WireVersion.Server42); - /// /// Gets the getField feature. /// @@ -312,12 +227,6 @@ public class Feature /// public static Feature GetMoreComment { get; } = new("GetMoreComment", WireVersion.Server44); - /// - /// Gets the group command feature. - /// - [Obsolete("This feature was removed in server version 4.2. This property will be removed in the next major release.")] - public static Feature GroupCommand { get; } = new("GroupCommand", WireVersion.Zero, WireVersion.Server42); - /// /// Gets the $hash operator feature. /// @@ -338,46 +247,16 @@ public class Feature /// public static Feature HintForDeleteOperations { get; } = new("HintForDeleteOperations", WireVersion.Server44); - /// - /// Gets the hint for find and modify operations feature. - /// - [Obsolete("HintForFindAndModifyFeature is Obsolete and will be removed in the next major release. Use HintForFindAndModifyOperations instead")] - public static HintForFindAndModifyFeature HintForFindAndModifyFeature { get; } = new("HintForFindAndModify", WireVersion.Server44); - /// /// Gets the hint for find and modify operations feature. /// public static Feature HintForFindAndModifyOperations { get; } = new("HintForFindAndModifyOperations", WireVersion.Server44); - /// - /// Gets the hint for update and replace operations feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature HintForUpdateAndReplaceOperations { get; } = new("HintForUpdateAndReplaceOperations", WireVersion.Server42); - - /// - /// Gets the keep connection pool when NotPrimary connection exception feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature KeepConnectionPoolWhenNotPrimaryConnectionException { get; } = new("KeepConnectionPoolWhenNotWritablePrimaryConnectionException", WireVersion.Server42); - - /// - /// Gets the keep connection pool when replSetStepDown feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature KeepConnectionPoolWhenReplSetStepDown { get; } = new("KeepConnectionPoolWhenReplSetStepDown", WireVersion.Server42); - /// /// Gets the legacy wire protocol feature. /// public static Feature LegacyWireProtocol { get; } = new("LegacyWireProtocol", WireVersion.Zero, WireVersion.Server51); - /// - /// Get the list databases authorizedDatabases feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ListDatabasesAuthorizedDatabases { get; } = new("ListDatabasesAuthorizedDatabases", WireVersion.Server40); - /// /// Gets the load balanced mode feature. /// @@ -393,12 +272,6 @@ public class Feature /// public static Feature LookupDocuments { get; } = new("LookupDocuments", WireVersion.Server60); - /// - /// Gets the mmapv1 storage engine feature. - /// - [Obsolete("This feature was removed in server version 4.2. This property will be removed in the next major release.")] - public static Feature MmapV1StorageEngine { get; } = new("MmapV1StorageEngine", WireVersion.Zero, WireVersion.Server42); - /// /// Gets the $median operator added in 7.0 /// @@ -424,12 +297,6 @@ public class Feature /// public static Feature RankFusionStage { get; } = new("RankFusionStage", WireVersion.Server81); - /// - /// Gets the regex match feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature RegexMatch { get; } = new("RegexMatch", WireVersion.Server42); - /// /// Gets the $replaceAll feature. /// @@ -440,23 +307,11 @@ public class Feature /// public static Feature ReplaceAllWithRegex { get; } = new("ReplaceAllWithRegex", WireVersion.Server82); - /// - /// Gets the $round feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature Round { get; } = new("Round", WireVersion.Server42); - /// /// Gets the $scoreFusion feature. /// public static Feature ScoreFusionStage { get; } = new("ScoreFusionStage", WireVersion.Server82); - /// - /// Gets the scram sha256 authentication feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ScramSha256Authentication { get; } = new("ScramSha256Authentication", WireVersion.Server40); - /// /// Gets the server returns resumableChangeStream label feature. /// @@ -472,12 +327,6 @@ public class Feature /// public static Feature SerializeEJsonOperator { get; } = new("SerializeEJsonOperator", WireVersion.Server83); - /// - /// Gets the $set stage feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature SetStage { get; } = new("SetStage", WireVersion.Server42); - /// /// Gets the set window fields feature. /// @@ -488,12 +337,6 @@ public class Feature /// public static Feature SetWindowFieldsLocf { get; } = new("SetWindowFieldsLocf", WireVersion.Server52); - /// - /// Gets the sharded transactions feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ShardedTransactions { get; } = new("ShardedTransactions", WireVersion.Server42); - /// /// Gets the $sigmoid operator feature. /// @@ -540,42 +383,6 @@ public class Feature /// public static Feature SubtypeOperator { get; } = new("SubtypeOperator", WireVersion.Server83); - /// - /// Gets the $toXyz conversion operators feature ($toDouble etc.). - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature ToConversionOperators { get; } = new("ToConversionOperators", WireVersion.Server40); - - /// - /// Gets the transactions feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature Transactions { get; } = new("Transactions", WireVersion.Server40); - - /// - /// Gets the trig operators feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature TrigOperators { get; } = new("TrigOperators", WireVersion.Server42); - - /// - /// Gets the trim operator feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature TrimOperator { get; } = new("TrimOperator", WireVersion.Server40); - - /// - /// Gets the update with aggregation pipeline feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature UpdateWithAggregationPipeline { get; } = new("UpdateWithAggregationPipeline", WireVersion.Server42); - - /// - /// Gets the wildcard indexes feature. - /// - [Obsolete("This feature is supported by all server versions supported by this driver. This property will be removed in the next major release.")] - public static Feature WildcardIndexes { get; } = new("WildcardIndexes", WireVersion.Server42); - #endregion private readonly int? _supportRemovedWireVersion; diff --git a/src/MongoDB.Driver/Core/Misc/HintForFindAndModifyFeature.cs b/src/MongoDB.Driver/Core/Misc/HintForFindAndModifyFeature.cs deleted file mode 100644 index 0e2d511899a..00000000000 --- a/src/MongoDB.Driver/Core/Misc/HintForFindAndModifyFeature.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2020-present MongoDB Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace MongoDB.Driver.Core.Misc -{ - /// - /// Represents the hint for find and modify feature. - /// - [Obsolete("HintForFindAndModifyFeature is obsolete and will be removed in the next major release.")] - public class HintForFindAndModifyFeature : Feature - { - private readonly int _firstWireVersionWhereWeRelyOnServerToReturnError = WireVersion.Server42; - - /// - /// Initializes a new instance of the class. - /// - /// The name of the feature. - /// The first wire version that supports the feature. - public HintForFindAndModifyFeature(string name, int firstSupportedWireVersion) - : base(name, firstSupportedWireVersion) - { - } - - /// - /// Determines whether the driver must throw an exception if the feature is not supported by the server. - /// - /// The wire version. - /// Whether the driver must throw if feature is not supported. - public bool DriverMustThrowIfNotSupported(int wireVersion) - { - return wireVersion < _firstWireVersionWhereWeRelyOnServerToReturnError; - } - } -} diff --git a/src/MongoDB.Driver/Core/Misc/SemaphoreSlimRequest.cs b/src/MongoDB.Driver/Core/Misc/SemaphoreSlimRequest.cs deleted file mode 100644 index 8c583fa72d8..00000000000 --- a/src/MongoDB.Driver/Core/Misc/SemaphoreSlimRequest.cs +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2015-present MongoDB Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace MongoDB.Driver.Core.Misc -{ - /// - /// Represents a tentative request to acquire a SemaphoreSlim. - /// - [Obsolete("SemaphoreSlimRequest is deprecated and will be removed in future release")] - public sealed class SemaphoreSlimRequest : IDisposable - { - // private fields - private readonly CancellationTokenSource _disposeCancellationTokenSource; - private readonly CancellationTokenSource _linkedCancellationTokenSource; -#pragma warning disable CA2213 // Disposable fields should be disposed - private readonly SemaphoreSlim _semaphore; -#pragma warning restore CA2213 // Disposable fields should be disposed - private readonly Task _task; - - // constructors - /// - /// Initializes a new instance of the class. - /// - /// The semaphore. - /// The cancellation token. - public SemaphoreSlimRequest(SemaphoreSlim semaphore, CancellationToken cancellationToken) - : this(semaphore, Timeout.InfiniteTimeSpan, cancellationToken) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The semaphore. - /// The timeout. - /// The cancellation token. - public SemaphoreSlimRequest(SemaphoreSlim semaphore, TimeSpan timeout, CancellationToken cancellationToken) - { - _semaphore = Ensure.IsNotNull(semaphore, nameof(semaphore)); - - _disposeCancellationTokenSource = new CancellationTokenSource(); - _linkedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _disposeCancellationTokenSource.Token); - _task = semaphore.WaitAsync(timeout, _linkedCancellationTokenSource.Token); - } - - // public properties - /// - /// Gets the semaphore wait task. - /// - /// - /// The semaphore wait task. - /// - public Task Task => _task; - - // public methods - /// - public void Dispose() - { - _disposeCancellationTokenSource.Cancel(); // does nothing if we have the lock, otherwise cancels the request - SpinWait.SpinUntil(() => _task.IsCompleted); - - if (_task.Status == TaskStatus.RanToCompletion) - { - try - { - _semaphore.Release(); - } - catch - { - // ignore... - } - } - - _disposeCancellationTokenSource.Dispose(); - _linkedCancellationTokenSource.Dispose(); - } - } -} diff --git a/src/MongoDB.Driver/Core/MongoConnectionException.cs b/src/MongoDB.Driver/Core/MongoConnectionException.cs index ac33e7b20c5..516a1fae64e 100644 --- a/src/MongoDB.Driver/Core/MongoConnectionException.cs +++ b/src/MongoDB.Driver/Core/MongoConnectionException.cs @@ -63,26 +63,6 @@ public ConnectionId ConnectionId get { return _connectionId; } } - /// - /// Whether or not this exception contains a socket timeout exception. - /// - [Obsolete("Use ContainsTimeoutException instead.")] - public bool ContainsSocketTimeoutException - { - get - { - for (var exception = InnerException; exception != null; exception = exception.InnerException) - { - if (exception is SocketException socketException && - socketException.SocketErrorCode == SocketError.TimedOut) - { - return true; - } - } - return false; - } - } - /// /// Whether or not this exception contains a timeout exception. /// diff --git a/src/MongoDB.Driver/Core/Operations/AggregateOperation.cs b/src/MongoDB.Driver/Core/Operations/AggregateOperation.cs index 8b11b541461..f8eba289c87 100644 --- a/src/MongoDB.Driver/Core/Operations/AggregateOperation.cs +++ b/src/MongoDB.Driver/Core/Operations/AggregateOperation.cs @@ -49,7 +49,6 @@ internal sealed class AggregateOperation : IReadOperation _resultSerializer; private bool _retryRequested; - private bool? _useCursor; // constructors /// @@ -275,19 +274,6 @@ public bool RetryRequested public bool IsOperationRetryable => true; - /// - /// Gets or sets a value indicating whether the server should use a cursor to return the results. - /// - /// - /// A value indicating whether the server should use a cursor to return the results. - /// - [Obsolete("Server versions 3.6 and newer always use a cursor.")] - public bool? UseCursor - { - get { return _useCursor; } - set { _useCursor = value; } - } - // methods /// public IAsyncCursor Execute(OperationContext operationContext, IReadBinding binding) diff --git a/src/MongoDB.Driver/Core/Operations/CreateIndexRequest.cs b/src/MongoDB.Driver/Core/Operations/CreateIndexRequest.cs index dc77c279767..b7274cffda4 100644 --- a/src/MongoDB.Driver/Core/Operations/CreateIndexRequest.cs +++ b/src/MongoDB.Driver/Core/Operations/CreateIndexRequest.cs @@ -31,8 +31,6 @@ public CreateIndexRequest(BsonDocument keys) public BsonDocument AdditionalOptions { get; set; } public bool? Background { get; set; } public int? Bits { get; set; } - [Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")] - public double? BucketSize { get; set; } public Collation Collation { get; set; } public string DefaultLanguage { get; set; } public TimeSpan? ExpireAfter { get; set; } @@ -81,9 +79,6 @@ public BsonDocument CreateIndexDocument() { "name", GetIndexName() }, { "background", () => Background.Value, Background.HasValue }, { "bits", () => Bits.Value, Bits.HasValue }, -#pragma warning disable CS0618 // Type or member is obsolete - { "bucketSize", () => BucketSize.Value, BucketSize.HasValue }, -#pragma warning restore CS0618 // Type or member is obsolete { "collation", () => Collation.ToBsonDocument(), Collation != null }, { "default_language", () => DefaultLanguage, DefaultLanguage != null }, { "expireAfterSeconds", () => ExpireAfter.Value.TotalSeconds, ExpireAfter.HasValue }, diff --git a/src/MongoDB.Driver/Core/Servers/Server.cs b/src/MongoDB.Driver/Core/Servers/Server.cs index 62c44c3866e..e7b17bfe02a 100644 --- a/src/MongoDB.Driver/Core/Servers/Server.cs +++ b/src/MongoDB.Driver/Core/Servers/Server.cs @@ -184,12 +184,6 @@ public void Initialize() } } - [Obsolete("Use Invalidate with TopologyDescription instead.")] - public void Invalidate(string reasonInvalidated) - { - Invalidate(reasonInvalidated, responseTopologyDescription: null); - } - public void Invalidate(string reasonInvalidated, TopologyVersion responseTopologyDescription) { Invalidate(reasonInvalidated, clearConnectionPool: true, responseTopologyDescription); diff --git a/src/MongoDB.Driver/Core/Servers/ServerDescription.cs b/src/MongoDB.Driver/Core/Servers/ServerDescription.cs index 8f199fda1e9..954bc268438 100644 --- a/src/MongoDB.Driver/Core/Servers/ServerDescription.cs +++ b/src/MongoDB.Driver/Core/Servers/ServerDescription.cs @@ -100,7 +100,6 @@ public int GetHashCode(ServerDescription obj) => private readonly TagSet _tags; private readonly TopologyVersion _topologyVersion; private readonly ServerType _type; - private readonly SemanticVersion _version; private readonly Range _wireVersionRange; // constructors @@ -129,7 +128,6 @@ public int GetHashCode(ServerDescription obj) => /// The replica set tags. /// The topology version. /// The server type. - /// The server version. /// The wire version range. /// EndPoint and ServerId.EndPoint must match. public ServerDescription( @@ -155,7 +153,6 @@ public ServerDescription( Optional tags = default(Optional), Optional topologyVersion = default(Optional), Optional type = default(Optional), - Optional version = default(Optional), Optional> wireVersionRange = default(Optional>)) { Ensure.IsNotNull(endPoint, nameof(endPoint)); @@ -187,7 +184,6 @@ public ServerDescription( _tags = tags.WithDefault(null); _topologyVersion = topologyVersion.WithDefault(null); _type = type.WithDefault(ServerType.Unknown); - _version = version.WithDefault(null); _wireVersionRange = wireVersionRange.WithDefault(null); } @@ -480,18 +476,6 @@ public TopologyVersion TopologyVersion get { return _topologyVersion; } } - /// - /// Gets the approximate server version (only the major and minor version numbers are known). - /// - /// - /// The server version. - /// - [Obsolete("This property will be removed in a later release.")] - public SemanticVersion Version - { - get { return _version; } - } - /// /// Gets the wire version range. /// @@ -540,7 +524,6 @@ public bool Equals(ServerDescription other) _state == other._state && object.Equals(_tags, other._tags) && _type == other._type && - object.Equals(_version, other._version) && object.Equals(_wireVersionRange, other._wireVersionRange); } @@ -571,7 +554,6 @@ public override int GetHashCode() .Hash(_tags) .Hash(_topologyVersion) .Hash(_type) - .Hash(_version) .Hash(_wireVersionRange) .GetHashCode(); } @@ -607,7 +589,6 @@ public override string ToString() .AppendFormat(", EndPoint: \"{0}\"", _endPoint) .AppendFormat(", ReasonChanged: \"{0}\"", _reasonChanged) .AppendFormat(", State: \"{0}\"", _state) - .Append($", ServerVersion: {_version}") .Append($", TopologyVersion: {_topologyVersion}") .AppendFormat(", Type: \"{0}\"", _type) .AppendFormatIf(_tags != null && !_tags.IsEmpty, ", Tags: \"{0}\"", _tags) @@ -643,7 +624,6 @@ public override string ToString() /// The replica set tags. /// The topology version. /// The server type. - /// The server version. /// The wire version range. /// /// A new instance of ServerDescription. @@ -669,7 +649,6 @@ public ServerDescription With( Optional tags = default(Optional), Optional topologyVersion = default(Optional), Optional type = default(Optional), - Optional version = default(Optional), Optional> wireVersionRange = default(Optional>)) { return new ServerDescription( @@ -695,7 +674,6 @@ public ServerDescription With( tags: tags.WithDefault(_tags), topologyVersion: topologyVersion.WithDefault(_topologyVersion), type: type.WithDefault(_type), - version: version.WithDefault(_version), wireVersionRange: wireVersionRange.WithDefault(_wireVersionRange)); } @@ -731,7 +709,6 @@ public ServerDescription WithHeartbeatException(Exception heartbeatException) tags: _tags, topologyVersion: _topologyVersion, type: _type, - version: _version, wireVersionRange: _wireVersionRange); } } diff --git a/src/MongoDB.Driver/Core/Servers/ServerMonitor.cs b/src/MongoDB.Driver/Core/Servers/ServerMonitor.cs index 3d7948af746..4e6214d9913 100644 --- a/src/MongoDB.Driver/Core/Servers/ServerMonitor.cs +++ b/src/MongoDB.Driver/Core/Servers/ServerMonitor.cs @@ -415,7 +415,6 @@ private void Heartbeat(CancellationToken cancellationToken) tags: heartbeatHelloResult.Tags, topologyVersion: heartbeatHelloResult.TopologyVersion, type: heartbeatHelloResult.ServerType, - version: WireVersion.ToServerVersion(heartbeatHelloResult.MaxWireVersion), wireVersionRange: new Range(heartbeatHelloResult.MinWireVersion, heartbeatHelloResult.MaxWireVersion)); } else diff --git a/src/MongoDB.Driver/Core/WireProtocol/Messages/Encoders/MessageEncoderSettings.cs b/src/MongoDB.Driver/Core/WireProtocol/Messages/Encoders/MessageEncoderSettings.cs index 30c2e33e2fd..73cfea12103 100644 --- a/src/MongoDB.Driver/Core/WireProtocol/Messages/Encoders/MessageEncoderSettings.cs +++ b/src/MongoDB.Driver/Core/WireProtocol/Messages/Encoders/MessageEncoderSettings.cs @@ -24,8 +24,6 @@ internal static class MessageEncoderSettingsName // encoder settings used by the binary encoders public const string BinaryDocumentFieldDecryptor = nameof(BinaryDocumentFieldDecryptor); public const string BinaryDocumentFieldEncryptor = nameof(BinaryDocumentFieldEncryptor); - [Obsolete("Configure serializers instead.")] - public const string GuidRepresentation = nameof(GuidRepresentation); public const string MaxDocumentSize = nameof(MaxDocumentSize); public const string MaxMessageSize = nameof(MaxMessageSize); public const string MaxSerializationDepth = nameof(MaxSerializationDepth); diff --git a/src/MongoDB.Driver/CreateCollectionOptions.cs b/src/MongoDB.Driver/CreateCollectionOptions.cs index a91a13cf1fa..b4f0d33d484 100644 --- a/src/MongoDB.Driver/CreateCollectionOptions.cs +++ b/src/MongoDB.Driver/CreateCollectionOptions.cs @@ -34,11 +34,9 @@ public class CreateCollectionOptions private IndexOptionDefaults _indexOptionDefaults; private long? _maxDocuments; private long? _maxSize; - private bool? _noPadding; private BsonDocument _storageEngine; private TimeSpan? _timeout; private TimeSeriesOptions _timeSeriesOptions; - private bool? _usePowerOf2Sizes; private IBsonSerializerRegistry _serializerRegistry; private DocumentValidationAction? _validationAction; private DocumentValidationLevel? _validationLevel; @@ -119,16 +117,6 @@ public long? MaxSize set { _maxSize = value; } } - /// - /// Gets or sets whether padding should not be used. - /// - [Obsolete("This option was removed in server version 4.2. As such, this property will be removed in a later release.")] - public bool? NoPadding - { - get { return _noPadding; } - set { _noPadding = value; } - } - /// /// Gets or sets the serializer registry. /// @@ -166,16 +154,6 @@ public TimeSeriesOptions TimeSeriesOptions set { _timeSeriesOptions = value; } } - /// - /// Gets or sets a value indicating whether to use power of 2 sizes. - /// - [Obsolete("This option was removed in server version 4.2. As such, this property will be removed in a later release.")] - public bool? UsePowerOf2Sizes - { - get { return _usePowerOf2Sizes; } - set { _usePowerOf2Sizes = value; } - } - /// /// Gets or sets the validation action. /// diff --git a/src/MongoDB.Driver/CreateIndexOptions.cs b/src/MongoDB.Driver/CreateIndexOptions.cs index 246be0fe719..c7b72f8fd3f 100644 --- a/src/MongoDB.Driver/CreateIndexOptions.cs +++ b/src/MongoDB.Driver/CreateIndexOptions.cs @@ -26,7 +26,6 @@ public class CreateIndexOptions // fields private bool? _background; private int? _bits; - private double? _bucketSize; private Collation _collation; private string _defaultLanguage; private TimeSpan? _expireAfter; @@ -62,16 +61,6 @@ public int? Bits set { _bits = value; } } - /// - /// Gets or sets the size of a geohash bucket. - /// - [Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")] - public double? BucketSize - { - get { return _bucketSize; } - set { _bucketSize = value; } - } - /// /// Gets or sets the collation. /// @@ -229,9 +218,6 @@ internal static CreateIndexOptions CoercedFrom(CreateIndexOptions opt { Background = options.Background, Bits = options.Bits, -#pragma warning disable 618 - BucketSize = options.BucketSize, -#pragma warning restore 618 Collation = options.Collation, DefaultLanguage = options.DefaultLanguage, ExpireAfter = options.ExpireAfter, diff --git a/src/MongoDB.Driver/FieldDefinition.cs b/src/MongoDB.Driver/FieldDefinition.cs index 363ecc91bef..c1860cdad36 100644 --- a/src/MongoDB.Driver/FieldDefinition.cs +++ b/src/MongoDB.Driver/FieldDefinition.cs @@ -86,17 +86,6 @@ public sealed class RenderedFieldDefinition private readonly IBsonSerializer _underlyingSerializer; private readonly IBsonSerializer _valueSerializer; - /// - /// Initializes a new instance of the class. - /// - /// The field name. - /// The field serializer. - [Obsolete("Use the constructor that takes 4 arguments instead.")] - public RenderedFieldDefinition(string fieldName, IBsonSerializer fieldSerializer) - : this(fieldName, fieldSerializer, fieldSerializer, fieldSerializer) - { - } - /// /// Initializes a new instance of the class. /// diff --git a/src/MongoDB.Driver/FilteredMongoCollectionBase.cs b/src/MongoDB.Driver/FilteredMongoCollectionBase.cs index 0fb4fede975..04f8d1aa546 100644 --- a/src/MongoDB.Driver/FilteredMongoCollectionBase.cs +++ b/src/MongoDB.Driver/FilteredMongoCollectionBase.cs @@ -148,30 +148,6 @@ protected IMongoCollection WrappedCollection return _wrappedCollection.BulkWriteAsync(session, CombineModelFilters(requests), options, cancellationToken); } - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - public override long Count(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - return _wrappedCollection.Count(CombineFilters(filter), options, cancellationToken); - } - - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - public override long Count(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - return _wrappedCollection.Count(session, CombineFilters(filter), options, cancellationToken); - } - - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public override Task CountAsync(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - return _wrappedCollection.CountAsync(CombineFilters(filter), options, cancellationToken); - } - - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public override Task CountAsync(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - return _wrappedCollection.CountAsync(session, CombineFilters(filter), options, cancellationToken); - } - public override long CountDocuments(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { return _wrappedCollection.CountDocuments(CombineFilters(filter), options, cancellationToken); diff --git a/src/MongoDB.Driver/FindFluent.cs b/src/MongoDB.Driver/FindFluent.cs index 022e9fe6b6e..651c885bf34 100644 --- a/src/MongoDB.Driver/FindFluent.cs +++ b/src/MongoDB.Driver/FindFluent.cs @@ -58,34 +58,6 @@ public override IFindFluent As(IBsonSerializer CountAsync(CancellationToken cancellationToken) - { - var options = CreateCountOptions(); - if (_session == null) - { - return _collection.CountAsync(_filter, options, cancellationToken); - } - else - { - return _collection.CountAsync(_session, _filter, options, cancellationToken); - } - } - public override long CountDocuments(CancellationToken cancellationToken) { var options = CreateCountOptions(); diff --git a/src/MongoDB.Driver/FindFluentBase.cs b/src/MongoDB.Driver/FindFluentBase.cs index 6670b669d08..bd2c2bdd54c 100644 --- a/src/MongoDB.Driver/FindFluentBase.cs +++ b/src/MongoDB.Driver/FindFluentBase.cs @@ -36,17 +36,6 @@ public abstract class FindFluentBase : IOrderedFindFluen /// public abstract IFindFluent As(IBsonSerializer resultSerializer); - /// - [Obsolete("Use CountDocuments instead.")] - public virtual long Count(CancellationToken cancellationToken = default(CancellationToken)) - { - throw new NotImplementedException(); - } - - /// - [Obsolete("Use CountDocumentsAsync instead.")] - public abstract Task CountAsync(CancellationToken cancellationToken = default(CancellationToken)); - /// public virtual long CountDocuments(CancellationToken cancellationToken = default(CancellationToken)) { diff --git a/src/MongoDB.Driver/GridFS/GridFSFileInfoCompat.cs b/src/MongoDB.Driver/GridFS/GridFSFileInfoCompat.cs index 73911fe58dd..c43c7fe8077 100644 --- a/src/MongoDB.Driver/GridFS/GridFSFileInfoCompat.cs +++ b/src/MongoDB.Driver/GridFS/GridFSFileInfoCompat.cs @@ -84,18 +84,6 @@ public ObjectId Id get { return GetValue("IdAsBsonValue").AsObjectId; } } - /// - /// Gets the identifier as a BsonValue. - /// - /// - /// The identifier as a BsonValue. - /// - [Obsolete("All new GridFS files should use an ObjectId as the Id.")] - public BsonValue IdAsBsonValue - { - get { return GetValue("IdAsBsonValue"); } - } - /// /// Gets the length. /// diff --git a/src/MongoDB.Driver/IAggregateFluent.cs b/src/MongoDB.Driver/IAggregateFluent.cs index e8d825c66e6..9800cae18e4 100644 --- a/src/MongoDB.Driver/IAggregateFluent.cs +++ b/src/MongoDB.Driver/IAggregateFluent.cs @@ -524,18 +524,6 @@ IAggregateFluent UnionWith( IMongoCollection withCollection, PipelineDefinition withPipeline = null); - /// - /// Appends an unwind stage to the pipeline. - /// - /// The type of the result of the stage. - /// The field. - /// The new result serializer. - /// - /// The fluent aggregate interface. - /// - [Obsolete("Use the Unwind overload which takes an options parameter.")] - IAggregateFluent Unwind(FieldDefinition field, IBsonSerializer newResultSerializer); - /// /// Appends an unwind stage to the pipeline. /// diff --git a/src/MongoDB.Driver/IAggregateFluentExtensions.cs b/src/MongoDB.Driver/IAggregateFluentExtensions.cs index 810c8b52c9e..ec6f8890f45 100644 --- a/src/MongoDB.Driver/IAggregateFluentExtensions.cs +++ b/src/MongoDB.Driver/IAggregateFluentExtensions.cs @@ -1034,24 +1034,6 @@ public static IAggregateFluent Unwind(this IAggregateFlue return aggregate.AppendStage(PipelineStageDefinitionBuilder.Unwind(field)); } - /// - /// Appends an unwind stage to the pipeline. - /// - /// The type of the result. - /// The type of the new result. - /// The aggregate. - /// The field to unwind. - /// The new result serializer. - /// - /// The fluent aggregate interface. - /// - [Obsolete("Use the Unwind overload which takes an options parameter.")] - public static IAggregateFluent Unwind(this IAggregateFluent aggregate, Expression> field, IBsonSerializer newResultSerializer) - { - Ensure.IsNotNull(aggregate, nameof(aggregate)); - return aggregate.AppendStage(PipelineStageDefinitionBuilder.Unwind(field, new AggregateUnwindOptions { ResultSerializer = newResultSerializer })); - } - /// /// Appends an unwind stage to the pipeline. /// diff --git a/src/MongoDB.Driver/IFindFluent.cs b/src/MongoDB.Driver/IFindFluent.cs index f2027e0c9a4..d73b903570a 100644 --- a/src/MongoDB.Driver/IFindFluent.cs +++ b/src/MongoDB.Driver/IFindFluent.cs @@ -49,22 +49,6 @@ public interface IFindFluent : IAsyncCursorSourceThe fluent find interface. IFindFluent As(IBsonSerializer resultSerializer = null); - /// - /// Counts the number of documents. - /// - /// The cancellation token. - /// The count. - [Obsolete("Use CountDocuments instead.")] - long Count(CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Counts the number of documents. - /// - /// The cancellation token. - /// A Task whose result is the count. - [Obsolete("Use CountDocumentsAsync instead.")] - Task CountAsync(CancellationToken cancellationToken = default(CancellationToken)); - /// /// Counts the number of documents. /// diff --git a/src/MongoDB.Driver/IMongoCollection.cs b/src/MongoDB.Driver/IMongoCollection.cs index 5d44271f46d..74340ea9bbc 100644 --- a/src/MongoDB.Driver/IMongoCollection.cs +++ b/src/MongoDB.Driver/IMongoCollection.cs @@ -198,56 +198,6 @@ public interface IMongoCollection // TODO: derive from IMongoCollecti /// Task> BulkWriteAsync(IClientSessionHandle session, IEnumerable> requests, BulkWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Counts the number of documents in the collection. - /// - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - long Count(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Counts the number of documents in the collection. - /// - /// The session. - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - long Count(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Counts the number of documents in the collection. - /// - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - Task CountAsync(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Counts the number of documents in the collection. - /// - /// The session. - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - Task CountAsync(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - /// /// Counts the number of documents in the collection. /// For a fast estimate of the total documents in a collection see . diff --git a/src/MongoDB.Driver/IMongoCollectionExtensions.cs b/src/MongoDB.Driver/IMongoCollectionExtensions.cs index 2e5507dca7f..465ca66a773 100644 --- a/src/MongoDB.Driver/IMongoCollectionExtensions.cs +++ b/src/MongoDB.Driver/IMongoCollectionExtensions.cs @@ -91,90 +91,6 @@ public static IQueryable AsQueryable(this IMongoCollection return AsQueryableHelper(collection, session, aggregateOptions); } - /// - /// Counts the number of documents in the collection. - /// - /// The type of the document. - /// The collection. - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - public static long Count(this IMongoCollection collection, Expression> filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - Ensure.IsNotNull(collection, nameof(collection)); - Ensure.IsNotNull(filter, nameof(filter)); - - return collection.Count(new ExpressionFilterDefinition(filter), options, cancellationToken); - } - - /// - /// Counts the number of documents in the collection. - /// - /// The type of the document. - /// The session. - /// The collection. - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - public static long Count(this IMongoCollection collection, IClientSessionHandle session, Expression> filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - Ensure.IsNotNull(collection, nameof(collection)); - Ensure.IsNotNull(session, nameof(session)); - Ensure.IsNotNull(filter, nameof(filter)); - - return collection.Count(session, new ExpressionFilterDefinition(filter), options, cancellationToken); - } - - /// - /// Counts the number of documents in the collection. - /// - /// The type of the document. - /// The collection. - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public static Task CountAsync(this IMongoCollection collection, Expression> filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - Ensure.IsNotNull(collection, nameof(collection)); - Ensure.IsNotNull(filter, nameof(filter)); - - return collection.CountAsync(new ExpressionFilterDefinition(filter), options, cancellationToken); - } - - /// - /// Counts the number of documents in the collection. - /// - /// The type of the document. - /// The collection. - /// The session. - /// The filter. - /// The options. - /// The cancellation token. - /// - /// The number of documents in the collection. - /// - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public static Task CountAsync(this IMongoCollection collection, IClientSessionHandle session, Expression> filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - Ensure.IsNotNull(collection, nameof(collection)); - Ensure.IsNotNull(session, nameof(session)); - Ensure.IsNotNull(filter, nameof(filter)); - - return collection.CountAsync(session, new ExpressionFilterDefinition(filter), options, cancellationToken); - } - /// /// Counts the number of documents in the collection. /// For a fast estimate of the total documents in a collection see . diff --git a/src/MongoDB.Driver/IMongoIndexManager.cs b/src/MongoDB.Driver/IMongoIndexManager.cs index 3321723f226..7aa63eb7a0f 100644 --- a/src/MongoDB.Driver/IMongoIndexManager.cs +++ b/src/MongoDB.Driver/IMongoIndexManager.cs @@ -163,31 +163,6 @@ string CreateOne( CreateOneIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates an index. - /// - /// The keys. - /// The create index request options. - /// The cancellation token. - /// - /// The name of the index that was created. - /// - [Obsolete("Use CreateOne with a CreateIndexModel instead.")] - string CreateOne(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Creates an index. - /// - /// The session. - /// The keys. - /// The create index request options. - /// The cancellation token. - /// - /// The name of the index that was created. - /// - [Obsolete("Use CreateOne with a CreateIndexModel instead.")] - string CreateOne(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - /// /// Creates an index. /// @@ -219,31 +194,6 @@ Task CreateOneAsync( CreateOneIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates an index. - /// - /// The keys. - /// The create index request options. - /// The cancellation token. - /// - /// A task whose result is the name of the index that was created. - /// - [Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")] - Task CreateOneAsync(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Creates an index. - /// - /// The session. - /// The keys. - /// The create index request options. - /// The cancellation token. - /// - /// A task whose result is the name of the index that was created. - /// - [Obsolete("Use CreateOneAsyc with a CreateIndexModel instead.")] - Task CreateOneAsync(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - /// /// Creates an index. /// diff --git a/src/MongoDB.Driver/IServerSession.cs b/src/MongoDB.Driver/IServerSession.cs index f2ea7989f5d..289c8948323 100644 --- a/src/MongoDB.Driver/IServerSession.cs +++ b/src/MongoDB.Driver/IServerSession.cs @@ -39,19 +39,5 @@ public interface IServerSession : IDisposable /// The time this server session was last used (in UTC). /// DateTime? LastUsedAt { get; } - - /// - /// Gets the next transaction number. - /// - /// The transaction number. - [Obsolete("Let the driver handle when to advance the transaction number.")] - long AdvanceTransactionNumber(); - - // methods - /// - /// Called by the driver when the session is used (i.e. sent to the server). - /// - [Obsolete("Let the driver handle tracking when the session was last used.")] - void WasUsed(); } } diff --git a/src/MongoDB.Driver/IndexKeysDefinitionBuilder.cs b/src/MongoDB.Driver/IndexKeysDefinitionBuilder.cs index 1b42c938411..2d1b50d375a 100644 --- a/src/MongoDB.Driver/IndexKeysDefinitionBuilder.cs +++ b/src/MongoDB.Driver/IndexKeysDefinitionBuilder.cs @@ -117,40 +117,6 @@ public static IndexKeysDefinition Geo2D(this IndexKeysDefi return builder.Combine(keys, builder.Geo2D(field)); } - /// - /// Combines an existing index keys definition with a geo haystack index key definition. - /// - /// The type of the document. - /// The keys. - /// The field. - /// Name of the additional field. - /// - /// A combined index keys definition. - /// - [Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")] - public static IndexKeysDefinition GeoHaystack(this IndexKeysDefinition keys, FieldDefinition field, FieldDefinition additionalFieldName = null) - { - var builder = Builders.IndexKeys; - return builder.Combine(keys, builder.GeoHaystack(field, additionalFieldName)); - } - - /// - /// Combines an existing index keys definition with a geo haystack index key definition. - /// - /// The type of the document. - /// The keys. - /// The field. - /// Name of the additional field. - /// - /// A combined index keys definition. - /// - [Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")] - public static IndexKeysDefinition GeoHaystack(this IndexKeysDefinition keys, Expression> field, Expression> additionalFieldName = null) - { - var builder = Builders.IndexKeys; - return builder.Combine(keys, builder.GeoHaystack(field, additionalFieldName)); - } - /// /// Combines an existing index keys definition with a 2dsphere index key definition. /// @@ -328,35 +294,6 @@ public IndexKeysDefinition Geo2D(Expression> return Geo2D(new ExpressionFieldDefinition(field)); } - /// - /// Creates a geo haystack index key definition. - /// - /// The field. - /// Name of the additional field. - /// - /// A geo haystack index key definition. - /// - [Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")] - public IndexKeysDefinition GeoHaystack(FieldDefinition field, FieldDefinition additionalFieldName = null) - { - return new GeoHaystackIndexKeyDefinition(field, additionalFieldName); - } - - /// - /// Creates a geo haystack index key definition. - /// - /// The field. - /// Name of the additional field. - /// - /// A geo haystack index key definition. - /// - [Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")] - public IndexKeysDefinition GeoHaystack(Expression> field, Expression> additionalFieldName = null) - { - FieldDefinition additional = additionalFieldName == null ? null : new ExpressionFieldDefinition(additionalFieldName); - return GeoHaystack(new ExpressionFieldDefinition(field), additional); - } - /// /// Creates a 2dsphere index key definition. /// @@ -491,33 +428,6 @@ public override BsonDocument Render(RenderArgs args) } } - [Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")] - internal sealed class GeoHaystackIndexKeyDefinition : IndexKeysDefinition - { - private readonly FieldDefinition _field; - private readonly FieldDefinition _additionalFieldName; - - public GeoHaystackIndexKeyDefinition(FieldDefinition field, FieldDefinition additionalFieldName = null) - { - _field = Ensure.IsNotNull(field, nameof(field)); - _additionalFieldName = additionalFieldName; - } - - public override BsonDocument Render(RenderArgs args) - { - var renderedField = _field.Render(args); - - var document = new BsonDocument(renderedField.FieldName, "geoHaystack"); - if (_additionalFieldName != null) - { - var additionalRenderedField = _additionalFieldName.Render(args); - document.Add(additionalRenderedField.FieldName, 1); - } - - return document; - } - } - internal sealed class SimpleIndexKeyDefinition : IndexKeysDefinition { private readonly FieldDefinition _field; diff --git a/src/MongoDB.Driver/MongoClientSettings.cs b/src/MongoDB.Driver/MongoClientSettings.cs index c601821ce8c..9203f292904 100644 --- a/src/MongoDB.Driver/MongoClientSettings.cs +++ b/src/MongoDB.Driver/MongoClientSettings.cs @@ -772,20 +772,6 @@ public ExpressionTranslationOptions TranslationOptions } } - /// - /// Gets or sets a value indicating whether to use SSL. - /// - [Obsolete("Use UseTls instead.")] - public bool UseSsl - { - get { return _useTls; } - set - { - if (_isFrozen) { throw new InvalidOperationException("MongoClientSettings is frozen."); } - _useTls = value; - } - } - /// /// Gets or sets a value indicating whether to use TLS. /// @@ -799,21 +785,6 @@ public bool UseTls } } - /// - /// Gets or sets a value indicating whether to verify an SSL certificate. - /// - [Obsolete("Use AllowInsecureTls instead.")] - public bool VerifySslCertificate - { - get { return !_allowInsecureTls; } - set - { - if (_isFrozen) { throw new InvalidOperationException("MongoClientSettings is frozen."); } - // use property instead of private field because setter has additional side effects - AllowInsecureTls = !value; - } - } - /// /// Gets or sets the wait queue size. /// diff --git a/src/MongoDB.Driver/MongoCollectionBase.cs b/src/MongoDB.Driver/MongoCollectionBase.cs index 8e3fa3e5c59..a2d5314d451 100644 --- a/src/MongoDB.Driver/MongoCollectionBase.cs +++ b/src/MongoDB.Driver/MongoCollectionBase.cs @@ -93,27 +93,6 @@ internal abstract class MongoCollectionBase : IMongoCollection filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new NotImplementedException(); - } - - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - public virtual long Count(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new NotImplementedException(); - } - - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public abstract Task CountAsync(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); - - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public virtual Task CountAsync(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new NotImplementedException(); - } - public virtual long CountDocuments(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { throw new NotImplementedException(); diff --git a/src/MongoDB.Driver/MongoCollectionImpl.cs b/src/MongoDB.Driver/MongoCollectionImpl.cs index efa238ae965..39158302676 100644 --- a/src/MongoDB.Driver/MongoCollectionImpl.cs +++ b/src/MongoDB.Driver/MongoCollectionImpl.cs @@ -248,40 +248,6 @@ public override async Task> BulkWriteAsync(IClientSes } } - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - public override long Count(FilterDefinition filter, CountOptions options, CancellationToken cancellationToken = default) - { - using var session = _operationExecutor.StartImplicitSession(); - return Count(session, filter, options, cancellationToken); - } - - [Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")] - public override long Count(IClientSessionHandle session, FilterDefinition filter, CountOptions options, CancellationToken cancellationToken = default) - { - Ensure.IsNotNull(session, nameof(session)); - Ensure.IsNotNull(filter, nameof(filter)); - - var operation = CreateCountOperation(filter, options); - return ExecuteReadOperation(session, operation, options?.Timeout, cancellationToken); - } - - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public override async Task CountAsync(FilterDefinition filter, CountOptions options, CancellationToken cancellationToken = default) - { - using var session = _operationExecutor.StartImplicitSession(); - return await CountAsync(session, filter, options, cancellationToken).ConfigureAwait(false); - } - - [Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")] - public override Task CountAsync(IClientSessionHandle session, FilterDefinition filter, CountOptions options, CancellationToken cancellationToken = default) - { - Ensure.IsNotNull(session, nameof(session)); - Ensure.IsNotNull(filter, nameof(filter)); - - var operation = CreateCountOperation(filter, options); - return ExecuteReadOperationAsync(session, operation, options?.Timeout, cancellationToken); - } - public override long CountDocuments(FilterDefinition filter, CountOptions options, CancellationToken cancellationToken = default) { using var session = _operationExecutor.StartImplicitSession(); @@ -768,10 +734,7 @@ private AggregateOperation CreateAggregateOperation(RenderedPi MaxAwaitTime = options.MaxAwaitTime, MaxTime = options.MaxTime, ReadConcern = _settings.ReadConcern, - RetryRequested = _database.Client.Settings.RetryReads, -#pragma warning disable 618 - UseCursor = options.UseCursor -#pragma warning restore 618 + RetryRequested = _database.Client.Settings.RetryReads }; } @@ -923,29 +886,6 @@ private CountDocumentsOperation CreateCountDocumentsOperation( }; } - private CountOperation CreateCountOperation( - FilterDefinition filter, - CountOptions options) - { - options ??= new CountOptions(); - var renderArgs = GetRenderArgs(); - - return new CountOperation(_collectionNamespace, _messageEncoderSettings) - { - Collation = options.Collation, - Comment = options.Comment, - EnableOverloadRetargeting = _database.Client.Settings.EnableOverloadRetargeting, - Filter = filter.Render(renderArgs), - Hint = options.Hint, - Limit = options.Limit, - MaxAdaptiveRetries = _database.Client.Settings.MaxAdaptiveRetries, - MaxTime = options.MaxTime, - ReadConcern = _settings.ReadConcern, - RetryRequested = _database.Client.Settings.RetryReads, - Skip = options.Skip - }; - } - private DistinctOperation CreateDistinctOperation( FieldDefinition field, FilterDefinition filter, @@ -1672,9 +1612,6 @@ private IEnumerable CreateCreateIndexRequests(IEnumerable - /// Gets the password. - /// - [Obsolete("Use Evidence instead.")] - public string Password - { - get - { - var passwordEvidence = _evidence as PasswordEvidence; - if (passwordEvidence != null) - { - return SecureStringHelper.ToInsecureString(passwordEvidence.SecurePassword); - } - - return null; - } - } - /// /// Gets the source. /// diff --git a/src/MongoDB.Driver/MongoDatabase.cs b/src/MongoDB.Driver/MongoDatabase.cs index 35547290b4a..dfce9d7cfd9 100644 --- a/src/MongoDB.Driver/MongoDatabase.cs +++ b/src/MongoDB.Driver/MongoDatabase.cs @@ -551,10 +551,7 @@ private AggregateOperation CreateAggregateOperation(RenderedPi MaxAwaitTime = options.MaxAwaitTime, MaxTime = options.MaxTime, ReadConcern = _settings.ReadConcern, - RetryRequested = _client.Settings.RetryReads, -#pragma warning disable 618 - UseCursor = options.UseCursor -#pragma warning restore 618 + RetryRequested = _client.Settings.RetryReads }; } diff --git a/src/MongoDB.Driver/MongoIndexManagerBase.cs b/src/MongoDB.Driver/MongoIndexManagerBase.cs index 5cfbaad1d72..a84f3a81e9f 100644 --- a/src/MongoDB.Driver/MongoIndexManagerBase.cs +++ b/src/MongoDB.Driver/MongoIndexManagerBase.cs @@ -40,15 +40,6 @@ public abstract class MongoIndexManagerBase : IMongoIndexManager - [Obsolete("Use CreateOne with a CreateIndexModel instead.")] - public virtual string CreateOne(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - var model = new CreateIndexModel(keys, options); - var result = CreateMany(new[] { model }, cancellationToken); - return result.Single(); - } - /// public virtual string CreateOne( CreateIndexModel model, @@ -60,15 +51,6 @@ public virtual string CreateOne( return result.Single(); } - /// - [Obsolete("Use CreateOne with a CreateIndexModel instead.")] - public virtual string CreateOne(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - var model = new CreateIndexModel(keys, options); - var result = CreateMany(session, new[] { model }, cancellationToken); - return result.Single(); - } - /// public virtual string CreateOne( IClientSessionHandle session, @@ -81,15 +63,6 @@ public virtual string CreateOne( return result.Single(); } - /// - [Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")] - public virtual async Task CreateOneAsync(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - var model = new CreateIndexModel(keys, options); - var result = await CreateManyAsync(new[] { model }, cancellationToken).ConfigureAwait(false); - return result.Single(); - } - /// public virtual async Task CreateOneAsync( CreateIndexModel model, @@ -101,15 +74,6 @@ public virtual async Task CreateOneAsync( return result.Single(); } - /// - [Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")] - public virtual async Task CreateOneAsync(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) - { - var model = new CreateIndexModel(keys, options); - var result = await CreateManyAsync(session, new[] { model }, cancellationToken).ConfigureAwait(false); - return result.Single(); - } - /// public virtual async Task CreateOneAsync( IClientSessionHandle session, diff --git a/src/MongoDB.Driver/MongoUrl.cs b/src/MongoDB.Driver/MongoUrl.cs index a74cec4c4fc..6c11ab3c1ec 100644 --- a/src/MongoDB.Driver/MongoUrl.cs +++ b/src/MongoDB.Driver/MongoUrl.cs @@ -535,23 +535,11 @@ public string Username get { return _username; } } - /// - /// Gets a value indicating whether to use SSL. - /// - [Obsolete("Use UseTls instead.")] - public bool UseSsl => _useTls; - /// /// Gets a value indicating whether to use TLS. /// public bool UseTls => _useTls; - /// - /// Gets a value indicating whether to verify an SSL certificate. - /// - [Obsolete("Use AllowInsecureTls instead.")] - public bool VerifySslCertificate => !_allowInsecureTls; - /// /// Gets the W component of the write concern. /// diff --git a/src/MongoDB.Driver/MongoUrlBuilder.cs b/src/MongoDB.Driver/MongoUrlBuilder.cs index 5dabf557918..1b590086078 100644 --- a/src/MongoDB.Driver/MongoUrlBuilder.cs +++ b/src/MongoDB.Driver/MongoUrlBuilder.cs @@ -705,16 +705,6 @@ public string Username set { _username = value; } } - /// - /// Gets or sets a value indicating whether to use SSL. - /// - [Obsolete("Use UseTls instead.")] - public bool UseSsl - { - get { return _useTls; } - set { _useTls = value; } - } - /// /// Gets or sets a value indicating whether to use TLS. /// @@ -724,16 +714,6 @@ public bool UseTls set => _useTls = value; } - /// - /// Gets or sets a value indicating whether to verify an SSL certificate. - /// - [Obsolete("Use AllowInsecureTls instead.")] - public bool VerifySslCertificate - { - get => !_allowInsecureTls; - set => _allowInsecureTls = !value; - } - /// /// Gets or sets the W component of the write concern. /// diff --git a/src/MongoDB.Driver/PipelineDefinition.cs b/src/MongoDB.Driver/PipelineDefinition.cs index fbd9d69d5c0..1872fc5ec8e 100644 --- a/src/MongoDB.Driver/PipelineDefinition.cs +++ b/src/MongoDB.Driver/PipelineDefinition.cs @@ -307,15 +307,6 @@ public PipelineStagePipelineDefinition(IEnumerable sta /// public override IBsonSerializer OutputSerializer => _outputSerializer; - /// - /// Gets the serializer. - /// - [Obsolete("Use OutputSerializer instead.")] - public IBsonSerializer Serializer - { - get { return _outputSerializer; } - } - /// /// Gets the stages. /// diff --git a/src/MongoDB.Driver/ServerSession.cs b/src/MongoDB.Driver/ServerSession.cs index 6174172681a..5da26747886 100644 --- a/src/MongoDB.Driver/ServerSession.cs +++ b/src/MongoDB.Driver/ServerSession.cs @@ -44,25 +44,10 @@ public ServerSession(ICoreServerSession coreServerSession) public DateTime? LastUsedAt => _coreServerSession.LastUsedAt; // public methods - /// - [Obsolete("Let the driver handle when to advance the transaction number.")] - public long AdvanceTransactionNumber() - { - // do nothing - return -1; - } - /// public void Dispose() { // do nothing (the ServerSession does NOT own the wrapped core server session) } - - /// - [Obsolete("Let the driver handle tracking when the session was last used.")] - public void WasUsed() - { - // do nothing - } } } diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs index 8944dec3f66..4c35cc5689b 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs @@ -227,27 +227,6 @@ public void TestConstructorElementsDocumentDuplicateNames() documentB.Elements.ShouldAllBeEquivalentTo(documentA.Elements); } - [Fact] - public void TestConstructorElementsParams() - { - var element1 = new BsonElement("x", 1); - var element2 = new BsonElement("y", 2); -#pragma warning disable 618 - var document = new BsonDocument(element1, element2); -#pragma warning restore - Assert.False(document.AllowDuplicateNames); - Assert.Equal(2, document.ElementCount); - Assert.Equal(2, document.ElementCount); - Assert.Equal(1, document["x"].AsInt32); - Assert.Equal(2, document["y"].AsInt32); - Assert.Equal(true, document.Contains("x")); - Assert.Equal(true, document.Contains("y")); - Assert.Equal(true, document.ContainsValue(1)); - Assert.Equal(true, document.ContainsValue(2)); - Assert.Same(element1.Value, document.GetElement("x").Value); - Assert.Same(element2.Value, document.GetElement("y").Value); - } - [Fact] public void TestConstructorDictionaryGeneric() { diff --git a/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs b/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs index 043d3726182..4335321dc76 100644 --- a/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs +++ b/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs @@ -48,15 +48,13 @@ public void AfterClusterTime_should_be_empty_on_the_first_operation() { RequireServer.Check().SupportsCausalConsistency(); - var events = new EventCapturer().Capture(x => x.CommandName == "count"); + var events = new EventCapturer().Capture(x => x.CommandName == "aggregate"); using (var client = GetClient(events)) using (var session = client.StartSession()) { -#pragma warning disable 618 client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) - .Count(session, FilterDefinition.Empty); -#pragma warning restore + .CountDocuments(session, FilterDefinition.Empty); var commandStartedEvent = (CommandStartedEvent)events.Next(); commandStartedEvent.Command.GetValue("readConcern", null).Should().BeNull(); @@ -69,16 +67,14 @@ public void Session_OperationTime_should_get_updated_after_an_operation() RequireServer.Check().SupportsCausalConsistency(); var events = new EventCapturer() - .Capture(x => x.CommandName == "count") - .Capture(x => x.CommandName == "count"); + .Capture(x => x.CommandName == "aggregate") + .Capture(x => x.CommandName == "aggregate"); using (var client = GetClient(events)) using (var session = client.StartSession()) { -#pragma warning disable 618 client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) - .Count(session, FilterDefinition.Empty); -#pragma warning restore + .CountDocuments(session, FilterDefinition.Empty); var commandStartedEvent = (CommandStartedEvent)events.Next(); commandStartedEvent.Command.GetValue("readConcern", null).Should().BeNull(); @@ -94,7 +90,7 @@ public void AfterClusterTime_should_be_sent_after_the_first_read_operation() RequireServer.Check().SupportsCausalConsistency(); var events = new EventCapturer() - .Capture(x => x.CommandName == "count") + .Capture(x => x.CommandName == "aggregate") .Capture(x => x.CommandName == "find"); using (var client = GetClient(events)) using (var session = client.StartSession()) @@ -107,11 +103,9 @@ public void AfterClusterTime_should_be_sent_after_the_first_read_operation() session.OperationTime.Should().Be(commandSucceededEvent.Reply.GetValue("operationTime")); var operationTime = session.OperationTime; -#pragma warning disable 618 client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) - .Count(session, FilterDefinition.Empty); -#pragma warning restore + .CountDocuments(session, FilterDefinition.Empty); var commandStartedEvent = (CommandStartedEvent)events.Next(); commandStartedEvent.Command["readConcern"]["afterClusterTime"].AsBsonTimestamp.Should().Be(operationTime); @@ -124,7 +118,7 @@ public void AfterClusterTime_should_be_sent_after_the_first_write_operation() RequireServer.Check().SupportsCausalConsistency(); var events = new EventCapturer() - .Capture(x => x.CommandName == "count") + .Capture(x => x.CommandName == "aggregate") .Capture(x => x.CommandName == "insert"); using (var client = GetClient(events)) using (var session = client.StartSession()) @@ -137,11 +131,9 @@ public void AfterClusterTime_should_be_sent_after_the_first_write_operation() session.OperationTime.Should().Be(commandSucceededEvent.Reply.GetValue("operationTime")); var operationTime = session.OperationTime; -#pragma warning disable 618 client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) - .Count(session, FilterDefinition.Empty); -#pragma warning restore + .CountDocuments(session, FilterDefinition.Empty); var commandStartedEvent = (CommandStartedEvent)events.Next(); commandStartedEvent.Command["readConcern"]["afterClusterTime"].AsBsonTimestamp.Should().Be(operationTime); @@ -154,15 +146,13 @@ public void AfterClusterTime_should_not_be_sent_when_the_session_is_not_causally RequireServer.Check().SupportsCausalConsistency(); var events = new EventCapturer() - .Capture(x => x.CommandName == "count"); + .Capture(x => x.CommandName == "aggregate"); using (var client = GetClient(events)) using (var session = client.StartSession(new ClientSessionOptions { CausalConsistency = false })) { -#pragma warning disable 618 client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) - .Count(session, FilterDefinition.Empty); -#pragma warning restore + .CountDocuments(session, FilterDefinition.Empty); var commandStartedEvent = (CommandStartedEvent)events.Next(); commandStartedEvent.Command.Contains("readConcern").Should().BeFalse(); @@ -175,7 +165,7 @@ public void ReadConcern_should_not_include_level_when_using_the_server_default() RequireServer.Check().SupportsCausalConsistency(); var events = new EventCapturer() - .Capture(x => x.CommandName == "count"); + .Capture(x => x.CommandName == "aggregate"); using (var client = GetClient(events)) using (var session = client.StartSession()) { @@ -183,12 +173,10 @@ public void ReadConcern_should_not_include_level_when_using_the_server_default() .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) .InsertOne(session, new BsonDocument("x", 1)); -#pragma warning disable 618 client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) .WithReadConcern(ReadConcern.Default) - .Count(session, FilterDefinition.Empty); -#pragma warning restore + .CountDocuments(session, FilterDefinition.Empty); var commandStartedEvent = (CommandStartedEvent)events.Next(); commandStartedEvent.Command["readConcern"].AsBsonDocument.Contains("level").Should().BeFalse(); @@ -201,7 +189,7 @@ public void ReadConcern_should_include_level_when_not_using_the_server_default() RequireServer.Check().SupportsCausalConsistency(); var events = new EventCapturer() - .Capture(x => x.CommandName == "count"); + .Capture(x => x.CommandName == "aggregate"); using (var client = GetClient(events)) using (var session = client.StartSession()) { @@ -209,12 +197,10 @@ public void ReadConcern_should_include_level_when_not_using_the_server_default() .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) .InsertOne(session, new BsonDocument("x", 1)); -#pragma warning disable 618 client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName) .WithReadConcern(ReadConcern.Majority) - .Count(session, FilterDefinition.Empty); -#pragma warning restore + .CountDocuments(session, FilterDefinition.Empty); var commandStartedEvent = (CommandStartedEvent)events.Next(); commandStartedEvent.Command["readConcern"].AsBsonDocument.Contains("level").Should().BeTrue(); diff --git a/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs b/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs index 10dd96160bc..e47d689ae24 100644 --- a/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs +++ b/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs @@ -44,12 +44,10 @@ public void TestNoCredentials() Assert.Throws(() => { -#pragma warning disable 618 client .GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName) .GetCollection(__collectionName) - .Count(new BsonDocument()); -#pragma warning restore + .CountDocuments(new BsonDocument()); }); } diff --git a/tests/MongoDB.Driver.Tests/Core/Bindings/CoreServerSessionPoolTests.cs b/tests/MongoDB.Driver.Tests/Core/Bindings/CoreServerSessionPoolTests.cs index 86f17bdc563..0206939f555 100644 --- a/tests/MongoDB.Driver.Tests/Core/Bindings/CoreServerSessionPoolTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Bindings/CoreServerSessionPoolTests.cs @@ -191,7 +191,6 @@ private CoreServerSessionPool CreateSubject(ClusterType clusterType = ClusterTyp logicalSessionTimeout: TimeSpan.FromMinutes(30), state: ServerState.Connected, type: ServerType.ShardRouter, - version: new SemanticVersion(3, 6, 0), wireVersionRange: new Range(6, 14)); var clusterDescription = new ClusterDescription(clusterId, false, null, clusterType, [serverDescription]); diff --git a/tests/MongoDB.Driver.Tests/Core/Bindings/CoreSessionTests.cs b/tests/MongoDB.Driver.Tests/Core/Bindings/CoreSessionTests.cs index 03c33383b39..e406ff0da0b 100644 --- a/tests/MongoDB.Driver.Tests/Core/Bindings/CoreSessionTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Bindings/CoreSessionTests.cs @@ -386,7 +386,7 @@ private IClusterInternal CreateMockReplicaSetCluster() var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var maxWireVersion = WireVersion.SupportedWireVersionRange.Min; - var servers = new[] { new ServerDescription(serverId, endPoint, state: ServerState.Connected, type: ServerType.ReplicaSetPrimary, version: WireVersion.ToServerVersion(maxWireVersion), wireVersionRange: new Range(0, maxWireVersion)) }; + var servers = new[] { new ServerDescription(serverId, endPoint, state: ServerState.Connected, type: ServerType.ReplicaSetPrimary, wireVersionRange: new Range(0, maxWireVersion)) }; var clusterDescription = new ClusterDescription(clusterId, false, null, ClusterType.ReplicaSet, servers); var mockCluster = new Mock(); mockCluster.SetupGet(m => m.Description).Returns(clusterDescription); @@ -404,8 +404,7 @@ private ServerDescription CreateServerDescription( serverId = serverId ?? new ServerId(new ClusterId(1), endPoint); maxWireVersion = maxWireVersion ?? WireVersion.Server40; - var approximateServerVersion = WireVersion.ToServerVersion(maxWireVersion.Value); - return new ServerDescription(serverId, endPoint, state: state, type: type, version: approximateServerVersion, wireVersionRange: new Optional>(new Range(0, maxWireVersion.Value))); + return new ServerDescription(serverId, endPoint, state: state, type: type, wireVersionRange: new Optional>(new Range(0, maxWireVersion.Value))); } private CoreSession CreateSubject( diff --git a/tests/MongoDB.Driver.Tests/Core/Clusters/MultiServerClusterTests.cs b/tests/MongoDB.Driver.Tests/Core/Clusters/MultiServerClusterTests.cs index bf08a207179..619795f5d66 100644 --- a/tests/MongoDB.Driver.Tests/Core/Clusters/MultiServerClusterTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Clusters/MultiServerClusterTests.cs @@ -1231,7 +1231,6 @@ private void PublishDescription(IClusterInternal cluster, EndPoint endPoint, Ser state: ServerState.Connected, tags: null, type: serverType, - version: new SemanticVersion(3, 6, 0), wireVersionRange: new Range(0, int.MaxValue)); var currentClusterDescription = cluster.Description; diff --git a/tests/MongoDB.Driver.Tests/Core/Configuration/ConnectionStringTests.cs b/tests/MongoDB.Driver.Tests/Core/Configuration/ConnectionStringTests.cs index 289140353bb..1c10201c70f 100644 --- a/tests/MongoDB.Driver.Tests/Core/Configuration/ConnectionStringTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Configuration/ConnectionStringTests.cs @@ -385,10 +385,6 @@ public void When_nothing_is_specified(string connectionString) subject.LocalThreshold.Should().Be(null); subject.SocketTimeout.Should().Be(null); subject.ServerMonitoringMode.Should().Be(null); -#pragma warning disable 618 - subject.Ssl.Should().Be(null); - subject.SslVerifyCertificate.Should().Be(null); -#pragma warning restore 618 subject.Timeout.Should().Be(null); subject.Tls.Should().Be(null); subject.TlsInsecure.Should().Be(null); @@ -490,10 +486,6 @@ public void When_everything_is_specified() subject.LocalThreshold.Should().Be(TimeSpan.FromMilliseconds(50)); subject.SocketTimeout.Should().Be(TimeSpan.FromMilliseconds(40)); subject.ServerMonitoringMode.Should().Be(ServerMonitoringMode.Stream); -#pragma warning disable 618 - subject.Ssl.Should().BeFalse(); - subject.SslVerifyCertificate.Should().Be(true); -#pragma warning restore 618 #if DEBUG // TODO: CSOT: Make it public when CSOT will be ready for GA subject.Timeout.Should().Be(TimeSpan.FromMilliseconds(42)); #endif @@ -1084,9 +1076,8 @@ public void When_ssl_is_specified(string connectionString, bool ssl) { var subject = new ConnectionString(connectionString); -#pragma warning disable 618 - subject.Ssl.Should().Be(ssl); -#pragma warning restore 618 + // the ssl keyword remains supported and is an alias for tls + subject.Tls.Should().Be(ssl); } [Theory] @@ -1096,9 +1087,8 @@ public void When_sslVerifyCertificate_is_specified(string connectionString, bool { var subject = new ConnectionString(connectionString); -#pragma warning disable 618 - subject.SslVerifyCertificate.Should().Be(sslVerifyCertificate); -#pragma warning restore 618 + // the sslVerifyCertificate keyword remains supported and is the inverse of tlsInsecure + subject.TlsInsecure.Should().Be(!sslVerifyCertificate); } #if DEBUG // TODO: CSOT: Make it public when CSOT will be ready for GA diff --git a/tests/MongoDB.Driver.Tests/Core/Connections/ConnectionIdTests.cs b/tests/MongoDB.Driver.Tests/Core/Connections/ConnectionIdTests.cs index 860d654b00e..94fc04351c3 100644 --- a/tests/MongoDB.Driver.Tests/Core/Connections/ConnectionIdTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Connections/ConnectionIdTests.cs @@ -92,16 +92,6 @@ public void LongLocalValue_should_be_what_was_specified_in_the_constructor(long subject.LongLocalValue.Should().Be(localValue); } - [Fact] - public void ServerValue_should_return_null_when_null() - { - var subject = new ConnectionId(__serverId, 10); - -#pragma warning disable CS0618 // Type or member is obsolete - subject.ServerValue.ShouldBeEquivalentTo(null); -#pragma warning restore CS0618 // Type or member is obsolete - } - [Theory] [InlineData(0)] [InlineData(int.MaxValue)] diff --git a/tests/MongoDB.Driver.Tests/Core/DatabaseNamespaceTests.cs b/tests/MongoDB.Driver.Tests/Core/DatabaseNamespaceTests.cs index f6496a91181..04f7013f0bc 100644 --- a/tests/MongoDB.Driver.Tests/Core/DatabaseNamespaceTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/DatabaseNamespaceTests.cs @@ -71,28 +71,6 @@ public void DatabaseName_should_report_the_provided_database_name() subject.DatabaseName.Should().Be("test"); } - [Fact] - public void SystemIndexesCollection_should_return_the_system_indexes_collection() - { - var subject = new DatabaseNamespace("test"); - -#pragma warning disable CS0618 // Type or member is obsolete - var commandCollection = subject.SystemIndexesCollection; -#pragma warning restore CS0618 // Type or member is obsolete - commandCollection.FullName.Should().Be("test.system.indexes"); - } - - [Fact] - public void SystemNamespacesCollection_should_return_the_system_namespaces_collection() - { - var subject = new DatabaseNamespace("test"); - -#pragma warning disable CS0618 // Type or member is obsolete - var commandCollection = subject.SystemNamespacesCollection; -#pragma warning restore CS0618 // Type or member is obsolete - commandCollection.FullName.Should().Be("test.system.namespaces"); - } - [Theory] [InlineData("one", "one", true)] [InlineData("one", "two", false)] diff --git a/tests/MongoDB.Driver.Tests/Core/Helpers/ServerDescriptionHelper.cs b/tests/MongoDB.Driver.Tests/Core/Helpers/ServerDescriptionHelper.cs index 1725495723f..4b1bd12748e 100644 --- a/tests/MongoDB.Driver.Tests/Core/Helpers/ServerDescriptionHelper.cs +++ b/tests/MongoDB.Driver.Tests/Core/Helpers/ServerDescriptionHelper.cs @@ -37,7 +37,6 @@ public static ServerDescription Connected(ClusterId clusterId, EndPoint endPoint state: ServerState.Connected, tags: tags, type: serverType, - version: new SemanticVersion(3, 6, 0), wireVersionRange: wireVersionRange ?? Cluster.SupportedWireVersionRange); } } diff --git a/tests/MongoDB.Driver.Tests/Core/Operations/AggregateOperationTests.cs b/tests/MongoDB.Driver.Tests/Core/Operations/AggregateOperationTests.cs index d3f97137ce4..cbbb87964e6 100644 --- a/tests/MongoDB.Driver.Tests/Core/Operations/AggregateOperationTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Operations/AggregateOperationTests.cs @@ -51,9 +51,6 @@ public void Constructor_with_database_should_create_a_valid_instance() subject.MaxAwaitTime.Should().NotHaveValue(); subject.MaxTime.Should().NotHaveValue(); subject.ReadConcern.IsServerDefault.Should().BeTrue(); -#pragma warning disable 618 - subject.UseCursor.Should().NotHaveValue(); -#pragma warning restore 618 subject.RetryRequested.Should().BeFalse(); } @@ -110,9 +107,6 @@ public void Constructor_with_collection_should_create_a_valid_instance() subject.MaxAwaitTime.Should().NotHaveValue(); subject.MaxTime.Should().NotHaveValue(); subject.ReadConcern.IsServerDefault.Should().BeTrue(); -#pragma warning disable 618 - subject.UseCursor.Should().NotHaveValue(); -#pragma warning restore 618 subject.RetryRequested.Should().BeFalse(); } @@ -287,19 +281,6 @@ public void RetryRequested_get_and_set_should_work( result.Should().Be(value); } - [Fact] - public void UseCursor_get_and_set_should_work() - { - var subject = new AggregateOperation(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); - -#pragma warning disable 618 - subject.UseCursor = true; - var result = subject.UseCursor; -#pragma warning restore 618 - - result.Should().BeTrue(); - } - [Fact] public void CreateCommand_should_return_the_expected_result() { @@ -892,30 +873,6 @@ public void Execute_should_return_expected_result_when_ReadConcern_is_set( result.Should().HaveCount(1); } - [Theory] - [ParameterAttributeData] - public void Execute_should_return_expected_result_when_UseCursor_is_set( - [Values(null, false, true)] - bool? useCursor, - [Values(false, true)] - bool async) - { - RequireServer.Check(); - EnsureTestData(); - var subject = new AggregateOperation(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) - { -#pragma warning disable 618 - UseCursor = useCursor -#pragma warning restore 618 - }; - - var cursor = ExecuteOperation(subject, async); - var result = ReadCursorToEnd(cursor, async); - - result.Should().NotBeNull(); - result.Should().HaveCount(1); - } - [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( diff --git a/tests/MongoDB.Driver.Tests/Core/Operations/CreateIndexRequestTests.cs b/tests/MongoDB.Driver.Tests/Core/Operations/CreateIndexRequestTests.cs index b320220608a..826f0d90a84 100644 --- a/tests/MongoDB.Driver.Tests/Core/Operations/CreateIndexRequestTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Operations/CreateIndexRequestTests.cs @@ -67,22 +67,6 @@ public void Bits_get_and_set_should_work( result.Should().Be(value); } - [Theory] - [ParameterAttributeData] - public void BucketSize_get_and_set_should_work( - [Values(null, 1.0, 2.0)] - double? value) - { - var subject = new CreateIndexRequest(new BsonDocument("x", 1)); - -#pragma warning disable 618 - subject.BucketSize = value; - var result = subject.BucketSize; -#pragma warning restore 618 - - result.Should().Be(value); - } - [Theory] [ParameterAttributeData] public void Collation_get_and_set_should_work( @@ -110,9 +94,6 @@ public void constructor_should_initialize_subject() subject.AdditionalOptions.Should().BeNull(); subject.Background.Should().NotHaveValue(); subject.Bits.Should().NotHaveValue(); -#pragma warning disable 618 - subject.BucketSize.Should().NotHaveValue(); -#pragma warning restore 618 subject.Collation.Should().BeNull(); subject.DefaultLanguage.Should().BeNull(); subject.ExpireAfter.Should().NotHaveValue(); @@ -228,31 +209,6 @@ public void CreateIndexDocument_should_return_expected_result_when_Bits_is_set( result.Should().Be(expectedResult); } - [Theory] - [ParameterAttributeData] - public void CreateIndexDocument_should_return_expected_result_when_BucketSize_is_set( - [Values(null, 1.0, 2.0)] - double? bucketSize) - { - var keys = new BsonDocument("x", 1); - var subject = new CreateIndexRequest(keys) - { -#pragma warning disable 618 - BucketSize = bucketSize -#pragma warning restore 618 - }; - - var result = subject.CreateIndexDocument(); - - var expectedResult = new BsonDocument - { - { "key", keys }, - { "name", "x_1" }, - { "bucketSize", () => bucketSize.Value, bucketSize.HasValue } - }; - result.Should().Be(expectedResult); - } - [Theory] [ParameterAttributeData] public void CreateIndexDocument_should_return_expected_result_when_Collation_is_set( diff --git a/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionTests.cs b/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionTests.cs index d013497a819..771c98e1a18 100644 --- a/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionTests.cs @@ -57,9 +57,6 @@ public void Constructor_with_serverId_and_endPoint_only_should_return_disconnect subject.State.Should().Be(ServerState.Disconnected); subject.Tags.Should().BeNull(); subject.Type.Should().Be(ServerType.Unknown); -#pragma warning disable CS0618 // Type or member is obsolete - subject.Version.Should().BeNull(); -#pragma warning restore CS0618 // Type or member is obsolete subject.WireVersionRange.Should().BeNull(); } @@ -79,7 +76,6 @@ public void Constructor_with_multiple_parameters_should_return_properly_initiali var state = ServerState.Connected; var tags = new TagSet(new[] { new Tag("x", "a") }); var type = ServerType.ReplicaSetPrimary; - var version = new SemanticVersion(3, 6, 0); var wireVersionRange = new Range(6, 14); var subject = new ServerDescription( @@ -94,7 +90,6 @@ public void Constructor_with_multiple_parameters_should_return_properly_initiali logicalSessionTimeout: logicalSessionTimeout, replicaSetConfig: replicaSetConfig, tags: tags, - version: version, wireVersionRange: wireVersionRange); subject.AverageRoundTripTime.Should().Be(TimeSpan.FromSeconds(1)); @@ -162,7 +157,6 @@ public static IEnumerable Exception_equals_test_cases() [InlineData("State")] [InlineData("Tags")] [InlineData("Type")] - [InlineData("Version")] [InlineData("WireVersionRange")] public void Equals_should_return_false_when_any_field_is_not_equal(string notEqualField) { @@ -182,7 +176,6 @@ public void Equals_should_return_false_when_any_field_is_not_equal(string notEqu var state = ServerState.Connected; var tags = new TagSet(new[] { new Tag("x", "a") }); var type = ServerType.ReplicaSetPrimary; - var version = new SemanticVersion(3, 6, 0); var wireVersionRange = new Range(6, 14); var subject = new ServerDescription( @@ -198,7 +191,6 @@ public void Equals_should_return_false_when_any_field_is_not_equal(string notEqu logicalSessionTimeout: logicalSessionTimeout, replicaSetConfig: replicaSetConfig, tags: tags, - version: version, wireVersionRange: wireVersionRange); switch (notEqualField) @@ -214,7 +206,6 @@ public void Equals_should_return_false_when_any_field_is_not_equal(string notEqu case "ServerId": serverId = new ServerId(new ClusterId(), endPoint); break; case "Tags": tags = new TagSet(new[] { new Tag("x", "b") }); break; case "Type": type = ServerType.ReplicaSetSecondary; break; - case "Version": version = new SemanticVersion(version.Major, version.Minor, version.Patch + 1); break; case "WireVersionRange": wireVersionRange = new Range(0, 0); break; } @@ -231,7 +222,6 @@ public void Equals_should_return_false_when_any_field_is_not_equal(string notEqu logicalSessionTimeout: logicalSessionTimeout, replicaSetConfig: replicaSetConfig, tags: tags, - version: version, wireVersionRange: wireVersionRange); subject.Equals(serverDescription2).Should().BeFalse(); @@ -335,7 +325,6 @@ public void SdamEquals_should_return_false_when_any_sdam_field_is_not_equal(stri [InlineData("AverageRoundTripTime")] [InlineData("LastUpdateTimestamp")] [InlineData("State")] - [InlineData("Version")] [InlineData("MaxBatchCount")] [InlineData("MaxDocumentSize")] [InlineData("MaxMessageSize")] @@ -351,7 +340,6 @@ public void SdamEquals_should_return_true_when_any_non_sdam_field_is_not_equal(s var averageRoundTripTime = TimeSpan.FromSeconds(1); var lastUpdateTimestamp = DateTime.UtcNow; var state = ServerState.Connected; - var version = new SemanticVersion(3, 6, 0); var maxBatchCount = 1000; var maxDocumentSize = 16000000; var maxMessageSize = 48000000; @@ -366,7 +354,6 @@ public void SdamEquals_should_return_true_when_any_non_sdam_field_is_not_equal(s averageRoundTripTime: averageRoundTripTime, lastUpdateTimestamp: lastUpdateTimestamp, state: state, - version: version, maxBatchCount: maxBatchCount, maxDocumentSize: maxDocumentSize, maxMessageSize: maxMessageSize, @@ -380,7 +367,6 @@ public void SdamEquals_should_return_true_when_any_non_sdam_field_is_not_equal(s case "AverageRoundTripTime": averageRoundTripTime = averageRoundTripTime.Add(TimeSpan.FromSeconds(1)); break; case "LastUpdateTimestamp": lastUpdateTimestamp = lastUpdateTimestamp.Add(TimeSpan.FromSeconds(1)); break; case "State": state = ServerState.Disconnected; break; - case "Version": version = new SemanticVersion(version.Major, version.Minor, version.Patch + 1); break; case "MaxBatchCount": maxBatchCount += 1; break; case "MaxDocumentSize": maxDocumentSize += 1; break; case "MaxMessageSize": maxMessageSize += 1; break; @@ -397,7 +383,6 @@ public void SdamEquals_should_return_true_when_any_non_sdam_field_is_not_equal(s averageRoundTripTime: averageRoundTripTime, lastUpdateTimestamp: lastUpdateTimestamp, state: state, - version: version, maxBatchCount: maxBatchCount, maxDocumentSize: maxDocumentSize, maxMessageSize: maxMessageSize, @@ -576,7 +561,6 @@ public void MaxWireVersion_should_be_the_same_as_wireVersionRange_max() [InlineData("State")] [InlineData("Tags")] [InlineData("Type")] - [InlineData("Version")] [InlineData("WireVersionRange")] public void With_should_return_new_instance_when_a_field_is_not_equal(string notEqualField) { @@ -601,7 +585,6 @@ public void With_should_return_new_instance_when_a_field_is_not_equal(string not var state = ServerState.Connected; var tags = new TagSet(new[] { new Tag("x", "a") }); var type = ServerType.ReplicaSetPrimary; - var version = new SemanticVersion(3, 6, 0); var wireVersionRange = new Range(6, 14); var subject = new ServerDescription( @@ -624,7 +607,6 @@ public void With_should_return_new_instance_when_a_field_is_not_equal(string not state: state, tags: tags, type: type, - version: version, wireVersionRange: wireVersionRange); switch (notEqualField) @@ -646,7 +628,6 @@ public void With_should_return_new_instance_when_a_field_is_not_equal(string not case "State": state = ServerState.Disconnected; break; case "Tags": tags = new TagSet(new[] { new Tag("x", "b") }); break; case "Type": type = ServerType.ReplicaSetSecondary; break; - case "Version": version = new SemanticVersion(version.Major, version.Minor, version.Patch + 1); break; case "WireVersionRange": wireVersionRange = new Range(0, 0); break; } @@ -668,7 +649,6 @@ public void With_should_return_new_instance_when_a_field_is_not_equal(string not state: state, tags: tags, type: type, - version: version, wireVersionRange: wireVersionRange); result.Should().NotBeSameAs(subject); @@ -691,7 +671,6 @@ public void With_should_return_same_instance_when_all_fields_are_equal() var state = ServerState.Connected; var tags = new TagSet(new[] { new Tag("x", "a") }); var type = ServerType.ReplicaSetPrimary; - var version = new SemanticVersion(3, 6, 0); var wireVersionRange = new Range(6, 14); var subject = new ServerDescription( @@ -704,7 +683,6 @@ public void With_should_return_same_instance_when_all_fields_are_equal() state: state, tags: tags, type: type, - version: version, wireVersionRange: wireVersionRange); var result = subject.With( @@ -715,7 +693,6 @@ public void With_should_return_same_instance_when_all_fields_are_equal() state: ServerState.Connected, tags: tags, type: type, - version: version, wireVersionRange: wireVersionRange); result.ShouldBeEquivalentTo(subject); diff --git a/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionWithSimilarLastUpdateTimestampEqualityComparer.cs b/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionWithSimilarLastUpdateTimestampEqualityComparer.cs index af26e88fa40..1a534e1cdb8 100644 --- a/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionWithSimilarLastUpdateTimestampEqualityComparer.cs +++ b/tests/MongoDB.Driver.Tests/Core/Servers/ServerDescriptionWithSimilarLastUpdateTimestampEqualityComparer.cs @@ -47,9 +47,6 @@ public bool Equals(ServerDescription x, ServerDescription y) x.State.Equals(y.State) && object.Equals(x.Tags, y.Tags) && x.Type.Equals(y.Type) && -#pragma warning disable CS0618 // Type or member is obsolete - object.Equals(x.Version, y.Version) && -#pragma warning restore CS0618 // Type or member is obsolete object.Equals(x.WireVersionRange, y.WireVersionRange); } diff --git a/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs b/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs index 1c3a1c0b330..7e475623c47 100644 --- a/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs +++ b/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs @@ -94,20 +94,6 @@ public async Task CreateEncryptedCollection_should_handle_input_arguments() ShouldBeArgumentNullException(Record.Exception(() => subject.CreateEncryptedCollection(database, collectionName: collectionName, createCollectionOptions, kmsProvider: null, masterKey)), expectedParamName: "kmsProvider"); ShouldBeArgumentNullException(await Record.ExceptionAsync(() => subject.CreateEncryptedCollectionAsync(database, collectionName, createCollectionOptions, kmsProvider: null, masterKey)), expectedParamName: "kmsProvider"); - - var invalidDataKeyOptions = new DataKeyOptions(alternateKeyNames: Optional.Create(Mock.Of>())); -#pragma warning disable CS0618 // Type or member is obsolete - Record.Exception(() => subject.CreateEncryptedCollection(database, collectionName: collectionName, createCollectionOptions, kmsProvider, dataKeyOptions: invalidDataKeyOptions)) - .Should().BeOfType().Which.Message.Should().Be("CreateEncryptedCollection supports only MasterKey in DataKeyOptions."); - (await Record.ExceptionAsync(() => subject.CreateEncryptedCollectionAsync(database, collectionName, createCollectionOptions, kmsProvider, dataKeyOptions: invalidDataKeyOptions))) - .Should().BeOfType().Which.Message.Should().Be("CreateEncryptedCollection supports only MasterKey in DataKeyOptions."); - - invalidDataKeyOptions = new DataKeyOptions(keyMaterial: new BsonBinaryData(new byte[0])); - Record.Exception(() => subject.CreateEncryptedCollection(database, collectionName: collectionName, createCollectionOptions, kmsProvider, dataKeyOptions: invalidDataKeyOptions)) - .Should().BeOfType().Which.Message.Should().Be("CreateEncryptedCollection supports only MasterKey in DataKeyOptions."); - (await Record.ExceptionAsync(() => subject.CreateEncryptedCollectionAsync(database, collectionName, createCollectionOptions, kmsProvider, dataKeyOptions: invalidDataKeyOptions))) - .Should().BeOfType().Which.Message.Should().Be("CreateEncryptedCollection supports only MasterKey in DataKeyOptions."); -#pragma warning restore CS0618 // Type or member is obsolete } } diff --git a/tests/MongoDB.Driver.Tests/Encryption/EncryptOptionsTests.cs b/tests/MongoDB.Driver.Tests/Encryption/EncryptOptionsTests.cs index f720e3f42e8..a234a2bc677 100644 --- a/tests/MongoDB.Driver.Tests/Encryption/EncryptOptionsTests.cs +++ b/tests/MongoDB.Driver.Tests/Encryption/EncryptOptionsTests.cs @@ -15,6 +15,7 @@ using System; using FluentAssertions; +using MongoDB.Bson; using MongoDB.Driver.Encryption; using Xunit; @@ -176,11 +177,6 @@ public void Constructor_should_fail_when_suffix_queryType_without_suffixOptions( // String algorithm [InlineData(EncryptionAlgorithm.String, "String")] [InlineData("String", "String")] - // TextPreview is a deprecated alias and is translated to the String algorithm -#pragma warning disable CS0618 - [InlineData(EncryptionAlgorithm.TextPreview, "String")] -#pragma warning restore CS0618 - [InlineData("TextPreview", "String")] public void Constructor_should_support_different_algorithm_representations(object algorithm, string expectedAlgorithmRepresentation) { var alternateKeyName = "test"; @@ -216,20 +212,35 @@ public void With_stringOptions_should_create_new_instance_with_updated_stringOpt } [Fact] - public void With_textOptions_should_create_new_instance_with_updated_textOptions() + public void StringOptions_should_render_all_query_type_options() { -#pragma warning disable CS0618 // intentionally exercising the deprecated TextOptions API - var originalTextOptions = new TextOptions(true, true, prefixOptions: new PrefixOptions(10, 2)); - var newTextOptions = new TextOptions(false, false, substringOptions: new SubstringOptions(10, 8, 2)); + var subject = new StringOptions( + caseSensitive: true, + diacriticSensitive: false, + prefixOptions: new PrefixOptions(10, 2), + substringOptions: new SubstringOptions(20, 10, 2), + suffixOptions: new SuffixOptions(8, 3)); - var subject = new EncryptOptions(algorithm: EncryptionAlgorithm.TextPreview, keyId: Guid.NewGuid(), textOptions: originalTextOptions); + var result = subject.CreateDocument(); - var updated = subject.With(textOptions: newTextOptions); + result.Should().Be(BsonDocument.Parse(@" + { + caseSensitive : true, + diacriticSensitive : false, + prefix : { strMaxQueryLength : 10, strMinQueryLength : 2 }, + substring : { strMaxLength : 20, strMaxQueryLength : 10, strMinQueryLength : 2 }, + suffix : { strMaxQueryLength : 8, strMinQueryLength : 3 } + }")); + } - updated.TextOptions.Should().BeSameAs(newTextOptions); - updated.Algorithm.Should().Be(subject.Algorithm); - updated.KeyId.Should().Be(subject.KeyId); -#pragma warning restore CS0618 + [Fact] + public void StringOptions_should_omit_query_type_options_that_are_not_set() + { + var subject = new StringOptions(caseSensitive: false, diacriticSensitive: true); + + var result = subject.CreateDocument(); + + result.Should().Be(BsonDocument.Parse("{ caseSensitive : false, diacriticSensitive : true }")); } [Fact] diff --git a/tests/MongoDB.Driver.Tests/FindFluentTests.cs b/tests/MongoDB.Driver.Tests/FindFluentTests.cs index 78faff1ec9b..358411ead1f 100644 --- a/tests/MongoDB.Driver.Tests/FindFluentTests.cs +++ b/tests/MongoDB.Driver.Tests/FindFluentTests.cs @@ -73,92 +73,6 @@ public void As_should_change_the_result_type( } } - [Theory] - [ParameterAttributeData] - public void Count_should_call_collection_Count( - [Values(false, true)] bool usingSession, - [Values(false, true)] bool async) - { - var session = CreateSession(usingSession); - var filter = new BsonDocumentFilterDefinition(new BsonDocument("filter", 1)); - var hint = new BsonDocument("hint", 1); - var findOptions = new FindOptions - { - Collation = new Collation("en-us"), - Hint = hint, - Limit = 1, - MaxTime = TimeSpan.FromSeconds(2), - Skip = 3 - }; - var subject = CreateSubject(session: session, filter: filter, options: findOptions); - using var cancellationTokenSource = new CancellationTokenSource(); - var cancellationToken = cancellationTokenSource.Token; - - Predicate matchesExpectedOptions = countOptions => - countOptions.Collation.Equals(findOptions.Collation) && - countOptions.Hint.Equals(hint) && - countOptions.Limit.Equals((long?)findOptions.Limit) && - countOptions.MaxTime.Equals(findOptions.MaxTime) && - countOptions.Skip.Equals((long?)findOptions.Skip); - - if (async) - { - if (usingSession) - { -#pragma warning disable 618 - subject.CountAsync(cancellationToken).GetAwaiter().GetResult(); - _mockCollection.Verify( - m => m.CountAsync( - session, - filter, - It.Is(o => matchesExpectedOptions(o)), - cancellationToken), - Times.Once); -#pragma warning restore - } - else - { -#pragma warning disable 618 - subject.CountAsync(cancellationToken).GetAwaiter().GetResult(); - _mockCollection.Verify( - m => m.CountAsync( - filter, - It.Is(o => matchesExpectedOptions(o)), - cancellationToken), - Times.Once); - } -#pragma warning restore - } - else - { - if (usingSession) - { -#pragma warning disable 618 - subject.Count(cancellationToken); - _mockCollection.Verify( - m => m.Count( - session, - filter, - It.Is(o => matchesExpectedOptions(o)), - cancellationToken), - Times.Once); -#pragma warning restore - } - else - { -#pragma warning disable 618 - subject.Count(cancellationToken); - _mockCollection.Verify( - m => m.Count( - filter, - It.Is(o => matchesExpectedOptions(o)), - cancellationToken), - Times.Once); -#pragma warning restore - } - } - } - [Theory] [ParameterAttributeData] public void CountDocuments_should_call_collection_CountDocuments( diff --git a/tests/MongoDB.Driver.Tests/GridFS/GridFSFileInfoTests.cs b/tests/MongoDB.Driver.Tests/GridFS/GridFSFileInfoTests.cs index c9f0d692405..077dbef6e43 100644 --- a/tests/MongoDB.Driver.Tests/GridFS/GridFSFileInfoTests.cs +++ b/tests/MongoDB.Driver.Tests/GridFS/GridFSFileInfoTests.cs @@ -145,35 +145,6 @@ public void Id_should_be_deserialized_correctly() var result = DeserializeFilesCollectionDocument(document); result.Id.Should().Be(document["_id"].AsObjectId); -#pragma warning disable 618 - result.IdAsBsonValue.Should().Be(document["_id"]); -#pragma warning restore - } - - [Fact] - public void Id_should_be_deserialized_correctly_when_id_is_not_an_ObjectId() - { - var document = CreateFilesCollectionDocument(); - document["_id"] = 123; - - var result = DeserializeFilesCollectionDocument(document); - -#pragma warning disable 618 - result.IdAsBsonValue.Should().Be(document["_id"]); -#pragma warning restore - } - - [Fact] - public void IdAsBsonValue_get_should_return_the_expected_result() - { - var value = (BsonValue)123; - var subject = CreateSubject(idAsBsonValue: value); - -#pragma warning disable 618 - var result = subject.IdAsBsonValue; -#pragma warning restore - - result.Should().Be(value); } [Fact] diff --git a/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs b/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs index 643e501ab32..d2a701bca48 100644 --- a/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs +++ b/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs @@ -81,56 +81,6 @@ public void AsQueryable_should_return_expected_result( provider._session().Should().BeSameAs(session); } - [Theory] - [ParameterAttributeData] - public void Count_should_call_collection_with_expected_arguments( - [Values(false, true)] bool usingSession, - [Values(false, true)] bool async) - { - var mockCollection = CreateMockCollection(); - var collection = mockCollection.Object; - var session = new Mock().Object; - var filterExpression = (Expression>)(x => x.FirstName == "Jack"); - var options = new CountOptions(); - using var cancellationTokenSource = new CancellationTokenSource(); - var cancellationToken = cancellationTokenSource.Token; - - if (usingSession) - { - if (async) - { -#pragma warning disable 618 - IMongoCollectionExtensions.CountAsync(collection, session, filterExpression, options, cancellationToken); - mockCollection.Verify(s => s.CountAsync(session, It.IsAny>(), options, cancellationToken), Times.Once); -#pragma warning restore - } - else - { -#pragma warning disable 618 - IMongoCollectionExtensions.Count(collection, session, filterExpression, options, cancellationToken); - mockCollection.Verify(s => s.Count(session, It.IsAny>(), options, cancellationToken), Times.Once); -#pragma warning restore - } - } - else - { - if (async) - { -#pragma warning disable 618 - IMongoCollectionExtensions.CountAsync(collection, filterExpression, options, cancellationToken); - mockCollection.Verify(s => s.CountAsync(It.IsAny>(), options, cancellationToken), Times.Once); -#pragma warning restore - } - else - { -#pragma warning disable 618 - IMongoCollectionExtensions.Count(collection, filterExpression, options, cancellationToken); - mockCollection.Verify(s => s.Count(It.IsAny>(), options, cancellationToken), Times.Once); -#pragma warning restore - } - } - } - [Theory] [ParameterAttributeData] public void CountDocuments_should_call_collection_with_expected_arguments( diff --git a/tests/MongoDB.Driver.Tests/IndexKeysDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/IndexKeysDefinitionBuilderTests.cs index f63b22592d1..2be6a9940f2 100644 --- a/tests/MongoDB.Driver.Tests/IndexKeysDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/IndexKeysDefinitionBuilderTests.cs @@ -132,29 +132,6 @@ public void Geo2D_Typed() Assert(subject.Geo2D("FirstName"), "{fn: '2d'}"); } - [Fact] - public void GeoHaystack() - { - var subject = CreateSubject(); - -#pragma warning disable 618 - Assert(subject.GeoHaystack("a"), "{a: 'geoHaystack'}"); - Assert(subject.GeoHaystack("a", "b"), "{a: 'geoHaystack', b: 1 }"); -#pragma warning restore 618 - } - - [Fact] - public void GeoHaystack_Typed() - { - var subject = CreateSubject(); - -#pragma warning disable 618 - Assert(subject.GeoHaystack(x => x.FirstName), "{fn: 'geoHaystack'}"); - Assert(subject.GeoHaystack(x => x.FirstName, x => x.LastName), "{fn: 'geoHaystack', ln: 1}"); - Assert(subject.GeoHaystack("FirstName", "LastName"), "{fn: 'geoHaystack', ln: 1}"); -#pragma warning restore 618 - } - [Fact] public void Geo2DSphere() { diff --git a/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenCountTest.cs b/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenCountTest.cs deleted file mode 100644 index 4bc1bb92799..00000000000 --- a/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenCountTest.cs +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright 2018-present MongoDB Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using FluentAssertions; -using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.JsonDrivenTests; - -namespace MongoDB.Driver.Tests.JsonDrivenTests -{ - public sealed class JsonDrivenCountTest : JsonDrivenCollectionTest - { - // private fields - private FilterDefinition _filter = new BsonDocument(); - private CountOptions _options = new CountOptions(); - private long _result; - private IClientSessionHandle _session; - - // public constructors - public JsonDrivenCountTest(IMongoCollection collection, Dictionary objectMap) - : base(collection, objectMap) - { - } - - // public methods - public override void Arrange(BsonDocument document) - { - JsonDrivenHelper.EnsureAllFieldsAreValid(document, "name", "object", "collectionOptions", "arguments", "result", "error"); - base.Arrange(document); - } - - // protected methods - protected override void AssertResult() - { - _result.Should().Be(_expectedResult.ToInt64()); - } - - protected override void CallMethod(CancellationToken cancellationToken) - { - if (_session == null) - { -#pragma warning disable 618 - _result = _collection.Count(_filter, _options, cancellationToken); -#pragma warning restore - } - else - { -#pragma warning disable 618 - _result = _collection.Count(_session, _filter, _options, cancellationToken); -#pragma warning restore - } - } - - protected override async Task CallMethodAsync(CancellationToken cancellationToken) - { - if (_session == null) - { -#pragma warning disable 618 - _result = await _collection.CountAsync(_filter, _options, cancellationToken).ConfigureAwait(false); -#pragma warning restore - } - else - { -#pragma warning disable 618 - _result = await _collection.CountAsync(_session, _filter, _options, cancellationToken).ConfigureAwait(false); -#pragma warning restore - } - } - - protected override void SetArgument(string name, BsonValue value) - { - switch (name) - { - case "filter": - _filter = new BsonDocumentFilterDefinition(value.AsBsonDocument); - return; - - case "session": - _session = (IClientSessionHandle)_objectMap[value.AsString]; - return; - } - - base.SetArgument(name, value); - } - } -} diff --git a/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs b/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs index 0b28834b5ca..51ac873e5b4 100644 --- a/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs +++ b/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs @@ -153,7 +153,6 @@ public JsonDrivenTest CreateTest(string receiver, string name) { case "aggregate": return new JsonDrivenAggregateTest(collection, _objectMap); case "bulkWrite": return new JsonDrivenBulkWriteTest(collection, _objectMap); - case "count": return new JsonDrivenCountTest(collection, _objectMap); case "countDocuments": return new JsonDrivenCountDocumentsTest(collection, _objectMap); case "createIndex": return new JsonDrivenCreateIndexTest(collection, _objectMap); case "deleteMany": return new JsonDrivenDeleteManyTest(collection, _objectMap); diff --git a/tests/MongoDB.Driver.Tests/Linq/Integration/GridFSFileInfoFindProjectionTests.cs b/tests/MongoDB.Driver.Tests/Linq/Integration/GridFSFileInfoFindProjectionTests.cs index 2f3588b5c5e..de35196d3a4 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Integration/GridFSFileInfoFindProjectionTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Integration/GridFSFileInfoFindProjectionTests.cs @@ -49,27 +49,6 @@ public void Project_Id_should_work() result.Should().Be(ObjectId.Parse("111111111111111111111111")); } -#pragma warning disable CS0618 // Type or member is obsolete - [Fact] - public void Project_IdAsBsonValue_should_work() - { - var collection = Fixture.Collection; - - var find = collection - .Find(Builders.Filter.Where(x => x.IdAsBsonValue == new BsonObjectId(ObjectId.Parse("111111111111111111111111")))) - .Project(x => x.IdAsBsonValue); - - var filter = TranslateFindFilter(collection, find); - filter.Should().Be("{ _id : { $oid : '111111111111111111111111' } }"); - - var projection = TranslateFindProjection(collection, find); - projection.Should().Be("{ _id : 1 }"); - - var result = find.Single(); - result.Should().Be(ObjectId.Parse("111111111111111111111111")); - } -#pragma warning restore CS0618 // Type or member is obsolete - public sealed class ClassFixture : MongoCollectionFixture { protected override IEnumerable InitialData => diff --git a/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs b/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs index d66bd7e703e..758eafb051e 100644 --- a/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs @@ -339,13 +339,8 @@ public void TestDefaults() Assert.Equal(MongoDefaults.SocketTimeout, settings.SocketTimeout); Assert.Equal(null, settings.Socks5ProxySettings); Assert.Null(settings.SslSettings); -#pragma warning disable 618 - Assert.Equal(false, settings.UseSsl); -#pragma warning restore 618 Assert.Equal(false, settings.UseTls); -#pragma warning disable 618 - Assert.Equal(true, settings.VerifySslCertificate); -#pragma warning restore 618 + Assert.Equal(false, settings.AllowInsecureTls); #pragma warning disable 618 Assert.Equal(MongoDefaults.ComputedWaitQueueSize, settings.WaitQueueSize); #pragma warning restore 618 @@ -527,20 +522,12 @@ public void TestEquals() clone.SslSettings = new SslSettings { CheckCertificateRevocation = false }; Assert.False(clone.Equals(settings)); - clone = settings.Clone(); -#pragma warning disable 618 - clone.UseSsl = !settings.UseSsl; -#pragma warning restore 618 - Assert.False(clone.Equals(settings)); - clone = settings.Clone(); clone.UseTls = !settings.UseTls; Assert.False(clone.Equals(settings)); clone = settings.Clone(); -#pragma warning disable 618 - clone.VerifySslCertificate = !settings.VerifySslCertificate; -#pragma warning restore 618 + clone.AllowInsecureTls = !settings.AllowInsecureTls; Assert.False(clone.Equals(settings)); clone = settings.Clone(); @@ -717,14 +704,8 @@ public void TestFromUrl() Assert.Equal(url.ProxyPort, settings.Socks5ProxySettings.Port); Assert.Equal(url.ProxyUsername, ((Socks5AuthenticationSettings.UsernamePasswordAuthenticationSettings)settings.Socks5ProxySettings.Authentication).Username); Assert.Equal(url.ProxyPassword, ((Socks5AuthenticationSettings.UsernamePasswordAuthenticationSettings)settings.Socks5ProxySettings.Authentication).Password); -#pragma warning disable 618 Assert.Equal(url.TlsDisableCertificateRevocationCheck, !settings.SslSettings.CheckCertificateRevocation); - Assert.Equal(url.UseSsl, settings.UseSsl); -#pragma warning restore 618 Assert.Equal(url.UseTls, settings.UseTls); -#pragma warning disable 618 - Assert.Equal(url.VerifySslCertificate, settings.VerifySslCertificate); -#pragma warning restore 618 #pragma warning disable 618 Assert.Equal(url.ComputedWaitQueueSize, settings.WaitQueueSize); @@ -1333,23 +1314,6 @@ public void TestSslSettings() Assert.Throws(() => { settings.SslSettings = sslSettings; }); } - [Fact] - public void TestUseSsl() - { -#pragma warning disable 618 - var settings = new MongoClientSettings(); - Assert.Equal(false, settings.UseSsl); - - var useSsl = true; - settings.UseSsl = useSsl; - Assert.Equal(useSsl, settings.UseSsl); - - settings.Freeze(); - Assert.Equal(useSsl, settings.UseSsl); - Assert.Throws(() => { settings.UseSsl = useSsl; }); -#pragma warning restore 618 - } - [Fact] public void TestUseTls() { @@ -1365,24 +1329,6 @@ public void TestUseTls() Assert.Throws(() => { settings.UseTls = useTls; }); } - [Fact] - public void TestVerifySslCertificate() - { -#pragma warning disable 618 - var settings = new MongoClientSettings(); - Assert.Equal(true, settings.VerifySslCertificate); - - var verifySslCertificate = false; - settings.VerifySslCertificate = verifySslCertificate; - Assert.Equal(verifySslCertificate, settings.VerifySslCertificate); - settings.SslSettings.CheckCertificateRevocation.Should().BeFalse(); - - settings.Freeze(); - Assert.Equal(verifySslCertificate, settings.VerifySslCertificate); - Assert.Throws(() => { settings.VerifySslCertificate = verifySslCertificate; }); -#pragma warning restore 618 - } - [Fact] public void TestWaitQueueSize() { diff --git a/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs b/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs index 24ee6fb8487..2c44ff65f76 100644 --- a/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs @@ -94,9 +94,6 @@ public void Aggregate_should_execute_an_AggregateOperation_when_out_is_not_speci Let = new BsonDocument("y", "z"), MaxAwaitTime = TimeSpan.FromSeconds(4), MaxTime = TimeSpan.FromSeconds(3), -#pragma warning disable 618 - UseCursor = false -#pragma warning restore 618 }; using var cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = cancellationTokenSource.Token; @@ -142,9 +139,6 @@ public void Aggregate_should_execute_an_AggregateOperation_when_out_is_not_speci operation.ReadConcern.Should().Be(_readConcern); operation.RetryRequested.Should().BeTrue(); operation.ResultSerializer.Should().BeSameAs(renderedPipeline.OutputSerializer); -#pragma warning disable 618 - operation.UseCursor.Should().Be(options.UseCursor); -#pragma warning restore 618 } [Theory] @@ -174,9 +168,6 @@ public void Aggregate_should_execute_an_AggregateToCollectionOperation_and_a_Fin Hint = new BsonDocument("x", 1), Let = new BsonDocument("y", "z"), MaxTime = TimeSpan.FromSeconds(3), -#pragma warning disable 618 - UseCursor = false -#pragma warning restore 618 }; using var cancellationTokenSource1 = new CancellationTokenSource(); @@ -346,9 +337,6 @@ public void AggregateToCollection_should_execute_an_AggregateToCollectionOperati Hint = new BsonDocument("x", 1), Let = new BsonDocument("y", "z"), MaxTime = TimeSpan.FromSeconds(3), -#pragma warning disable 618 - UseCursor = false -#pragma warning restore 618 }; using var cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = cancellationTokenSource.Token; @@ -800,72 +788,6 @@ public void BulkWrite_should_throw_if_model_is_invalid([Values(false, true)] boo } } - [Theory] - [ParameterAttributeData] - public void Count_should_execute_a_CountOperation( - [Values(false, true)] bool usingSession, - [Values(false, true)] bool async) - { - var subject = CreateSubject(); - var session = CreateSession(usingSession); - var filter = new BsonDocument("x", 1); - var options = new CountOptions - { - Collation = new Collation("en_US"), - Hint = "funny", - Limit = 10, - MaxTime = TimeSpan.FromSeconds(20), - Skip = 30 - }; - using var cancellationTokenSource = new CancellationTokenSource(); - var cancellationToken = cancellationTokenSource.Token; - - if (usingSession) - { - if (async) - { -#pragma warning disable 618 - subject.CountAsync(session, filter, options, cancellationToken).GetAwaiter().GetResult(); -#pragma warning restore - } - else - { -#pragma warning disable 618 - subject.Count(session, filter, options, cancellationToken); -#pragma warning restore - } - } - else - { - if (async) - { -#pragma warning disable 618 - subject.CountAsync(filter, options, cancellationToken).GetAwaiter().GetResult(); -#pragma warning restore - } - else - { -#pragma warning disable 618 - subject.Count(filter, options, cancellationToken); -#pragma warning restore - } - } - - var call = _operationExecutor.GetReadCall(); - VerifySessionAndCancellationToken(call, session, cancellationToken); - - var operation = call.Operation.Should().BeOfType().Subject; - operation.Collation.Should().BeSameAs(options.Collation); - operation.CollectionNamespace.Should().Be(subject.CollectionNamespace); - operation.Filter.Should().Be(filter); - operation.Hint.Should().Be(options.Hint); - operation.Limit.Should().Be(options.Limit); - operation.MaxTime.Should().Be(options.MaxTime); - operation.ReadConcern.Should().Be(_readConcern); - operation.RetryRequested.Should().BeTrue(); - operation.Skip.Should().Be(options.Skip); - } - [Theory] [ParameterAttributeData] public void CountDocuments_should_execute_a_CountDocumentsOperation( @@ -2100,9 +2022,6 @@ public void Indexes_CreateOne_should_execute_a_CreateIndexesOperation( { Background = true, Bits = 10, -#pragma warning disable 618 - BucketSize = 20, -#pragma warning restore 618 Collation = new Collation("en_US"), DefaultLanguage = "en", ExpireAfter = TimeSpan.FromSeconds(20), @@ -2166,9 +2085,6 @@ public void Indexes_CreateOne_should_execute_a_CreateIndexesOperation( request.AdditionalOptions.Should().BeNull(); request.Background.Should().Be(options.Background); request.Bits.Should().Be(options.Bits); -#pragma warning disable 618 - request.BucketSize.Should().Be(options.BucketSize); -#pragma warning restore 618 request.Collation.Should().BeSameAs(options.Collation); request.DefaultLanguage.Should().Be(options.DefaultLanguage); request.ExpireAfter.Should().Be(options.ExpireAfter); @@ -2236,9 +2152,6 @@ public void Indexes_CreateMany_should_execute_a_CreateIndexesOperation( { Background = true, Bits = 10, -#pragma warning disable 618 - BucketSize = 20, -#pragma warning restore 618 Collation = new Collation("en_US"), DefaultLanguage = "en", ExpireAfter = TimeSpan.FromSeconds(20), @@ -2303,9 +2216,6 @@ public void Indexes_CreateMany_should_execute_a_CreateIndexesOperation( request1.AdditionalOptions.Should().BeNull(); request1.Background.Should().Be(options.Background); request1.Bits.Should().Be(options.Bits); -#pragma warning disable 618 - request1.BucketSize.Should().Be(options.BucketSize); -#pragma warning restore 618 request1.Collation.Should().BeSameAs(options.Collation); request1.DefaultLanguage.Should().Be(options.DefaultLanguage); request1.ExpireAfter.Should().Be(options.ExpireAfter); @@ -2343,9 +2253,6 @@ public void Indexes_CreateMany_should_execute_a_CreateIndexesOperation( request2.AdditionalOptions.Should().BeNull(); request2.Background.Should().NotHaveValue(); request2.Bits.Should().NotHaveValue(); -#pragma warning disable 618 - request2.BucketSize.Should().NotHaveValue(); -#pragma warning restore 618 request2.Collation.Should().BeNull(); request2.DefaultLanguage.Should().BeNull(); request2.ExpireAfter.Should().NotHaveValue(); diff --git a/tests/MongoDB.Driver.Tests/MongoCredentialTests.cs b/tests/MongoDB.Driver.Tests/MongoCredentialTests.cs index 65bc3016d43..0987a74f340 100644 --- a/tests/MongoDB.Driver.Tests/MongoCredentialTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoCredentialTests.cs @@ -113,9 +113,8 @@ public void TestEquals() public void TestPassword() { var credentials = MongoCredential.CreateCredential("database", "username", "password"); -#pragma warning disable 618 - Assert.Equal("password", credentials.Password); -#pragma warning restore 618 + var passwordEvidence = credentials.Evidence.Should().BeOfType().Subject; + Assert.Equal("password", passwordEvidence.ToInsecureString()); } [Fact] diff --git a/tests/MongoDB.Driver.Tests/MongoDatabaseTests.cs b/tests/MongoDB.Driver.Tests/MongoDatabaseTests.cs index 45ce1436646..fc03df63cfa 100644 --- a/tests/MongoDB.Driver.Tests/MongoDatabaseTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoDatabaseTests.cs @@ -87,9 +87,6 @@ public void Aggregate_should_execute_an_AggregateOperation_when_out_is_not_speci Let = new BsonDocument("y", "z"), MaxAwaitTime = TimeSpan.FromSeconds(4), MaxTime = TimeSpan.FromSeconds(3), -#pragma warning disable 618 - UseCursor = false -#pragma warning restore 618 }; using var cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = cancellationTokenSource.Token; @@ -136,9 +133,6 @@ public void Aggregate_should_execute_an_AggregateOperation_when_out_is_not_speci operation.ReadConcern.Should().Be(subject.Settings.ReadConcern); operation.RetryRequested.Should().BeTrue(); operation.ResultSerializer.Should().BeSameAs(renderedPipeline.OutputSerializer); -#pragma warning disable 618 - operation.UseCursor.Should().Be(options.UseCursor); -#pragma warning restore 618 } [Theory] @@ -166,9 +160,6 @@ public void Aggregate_should_execute_an_AggregateToCollectionOperation_and_a_Fin Hint = new BsonDocument("x", 1), Let = new BsonDocument("y", "z"), MaxTime = TimeSpan.FromSeconds(3), -#pragma warning disable 618 - UseCursor = false -#pragma warning restore 618 }; var cancellationToken1 = new CancellationTokenSource().Token; var cancellationToken2 = new CancellationTokenSource().Token; @@ -282,9 +273,6 @@ public void AggregateToCollection_should_execute_an_AggregateToCollectionOperati Hint = new BsonDocument("x", 1), Let = new BsonDocument("y", "z"), MaxTime = TimeSpan.FromSeconds(3), -#pragma warning disable 618 - UseCursor = false -#pragma warning restore 618 }; using var cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = cancellationTokenSource.Token; diff --git a/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs b/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs index 5d42bbadb52..5ede33caf68 100644 --- a/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs @@ -101,13 +101,7 @@ public void TestAll() Timeout = TimeSpan.FromSeconds(13), #endif Username = "username", -#pragma warning disable 618 - UseSsl = true, -#pragma warning restore 618 UseTls = true, -#pragma warning disable 618 - VerifySslCertificate = false, -#pragma warning restore 618 W = 2, #pragma warning disable 618 WaitQueueSize = 123, @@ -202,13 +196,7 @@ public void TestAll() Assert.Equal(TimeSpan.FromSeconds(13), builder.Timeout); #endif Assert.Equal("username", builder.Username); -#pragma warning disable 618 - Assert.Equal(true, builder.UseSsl); -#pragma warning restore 618 Assert.Equal(true, builder.UseTls); -#pragma warning disable 618 - Assert.Equal(false, builder.VerifySslCertificate); -#pragma warning restore 618 Assert.Equal(2, ((WriteConcern.WCount)builder.W).Value); #pragma warning disable 618 Assert.Equal(0.0, builder.WaitQueueMultiple); @@ -462,13 +450,7 @@ public void TestDefaults() Assert.Equal(null, builder.Timeout); Assert.Equal(MongoInternalDefaults.MongoClientSettings.SrvServiceName, builder.SrvServiceName); Assert.Equal(null, builder.Username); -#pragma warning disable 618 - Assert.Equal(false, builder.UseSsl); -#pragma warning restore 618 Assert.Equal(false, builder.UseTls); -#pragma warning disable 618 - Assert.Equal(true, builder.VerifySslCertificate); -#pragma warning restore 618 Assert.Equal(null, builder.W); #pragma warning disable 618 Assert.Equal(MongoDefaults.WaitQueueMultiple, builder.WaitQueueMultiple); diff --git a/tests/MongoDB.Driver.Tests/MongoUrlTests.cs b/tests/MongoDB.Driver.Tests/MongoUrlTests.cs index a6200efb790..55dfef98e7c 100644 --- a/tests/MongoDB.Driver.Tests/MongoUrlTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoUrlTests.cs @@ -292,13 +292,7 @@ public void TestAll() #endif Assert.Equal(true, url.TlsDisableCertificateRevocationCheck); Assert.Equal("username", url.Username); -#pragma warning disable 618 - Assert.Equal(true, url.UseSsl); -#pragma warning restore 618 Assert.Equal(true, url.UseTls); -#pragma warning disable 618 - Assert.Equal(false, url.VerifySslCertificate); -#pragma warning restore 618 Assert.Equal(2, ((WriteConcern.WCount)url.W).Value); #pragma warning disable 618 Assert.Equal(0.0, url.WaitQueueMultiple); diff --git a/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs b/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs index b89f33ffa31..80354d8afdd 100644 --- a/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs +++ b/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs @@ -465,42 +465,6 @@ public async Task BulkWrite_with_UpdateOne( } } - [Theory] - [ParameterAttributeData] - public async Task Count_should_include_the_filter( - [Values(false, true)] bool async) - { - var subject = CreateSubject(); - var options = new CountOptions(); - - if (async) - { -#pragma warning disable 618 - await subject.CountAsync(_providedFilter, options, CancellationToken.None); - - _mockDerivedCollection.Verify( - c => c.CountAsync( - It.Is>(f => RenderFilter(f).Equals(_expectedFilter)), - options, - CancellationToken.None), - Times.Once); -#pragma warning restore - } - else - { -#pragma warning disable 618 - subject.Count(_providedFilter, options, CancellationToken.None); - - _mockDerivedCollection.Verify( - c => c.Count( - It.Is>(f => RenderFilter(f).Equals(_expectedFilter)), - options, - CancellationToken.None), - Times.Once); -#pragma warning restore - } - } - [Theory] [ParameterAttributeData] public async Task CountDocuments_should_include_the_filter( @@ -1020,7 +984,7 @@ public OfTypeCollectionIntegrationTests() [Theory] [ParameterAttributeData] - public void Count_should_only_count_derived_types( + public void CountDocuments_should_only_count_derived_types( [Values(false, true)] bool async) { var subject = CreateSubject(); @@ -1028,17 +992,13 @@ public void Count_should_only_count_derived_types( long result1, result2; if (async) { -#pragma warning disable 618 - result1 = subject.CountAsync("{}").GetAwaiter().GetResult(); - result2 = subject.OfType().CountAsync("{}").GetAwaiter().GetResult(); -#pragma warning restore + result1 = subject.CountDocumentsAsync("{}").GetAwaiter().GetResult(); + result2 = subject.OfType().CountDocumentsAsync("{}").GetAwaiter().GetResult(); } else { -#pragma warning disable 618 - result1 = subject.Count("{}"); - result2 = subject.OfType().Count("{}"); -#pragma warning restore + result1 = subject.CountDocuments("{}"); + result2 = subject.OfType().CountDocuments("{}"); } result1.Should().Be(6); @@ -1047,7 +1007,7 @@ public void Count_should_only_count_derived_types( [Theory] [ParameterAttributeData] - public void Count_should_only_count_derived_types_with_a_filter( + public void CountDocuments_should_only_count_derived_types_with_a_filter( [Values(false, true)] bool async) { var subject = CreateSubject(); @@ -1055,15 +1015,11 @@ public void Count_should_only_count_derived_types_with_a_filter( long result; if (async) { -#pragma warning disable 618 - result = subject.CountAsync(x => x.PropB > 2).GetAwaiter().GetResult(); -#pragma warning restore + result = subject.CountDocumentsAsync(x => x.PropB > 2).GetAwaiter().GetResult(); } else { -#pragma warning disable 618 - result = subject.Count(x => x.PropB > 2); -#pragma warning restore + result = subject.CountDocuments(x => x.PropB > 2); } result.Should().Be(4); diff --git a/tests/MongoDB.Driver.Tests/ServerSessionTests.cs b/tests/MongoDB.Driver.Tests/ServerSessionTests.cs index 7d99b8ab3e1..778e1e5501c 100644 --- a/tests/MongoDB.Driver.Tests/ServerSessionTests.cs +++ b/tests/MongoDB.Driver.Tests/ServerSessionTests.cs @@ -71,20 +71,6 @@ public void LastUsedAt_should_call_coreServerSession_LastUsedAt() mockCoreServerSession.VerifyGet(m => m.LastUsedAt, Times.Once); } - [Fact] - public void AdvanceTransactionNumber_should_do_nothing() - { - Mock mockCoreServerSession; - var subject = CreateSubject(out mockCoreServerSession); - -#pragma warning disable 618 - var result = subject.AdvanceTransactionNumber(); -#pragma warning restore - - result.Should().Be(-1); - mockCoreServerSession.Verify(m => m.AdvanceTransactionNumber(), Times.Never); - } - [Fact] public void Dispose_should_not_call_coreServerSession_Dispose() { @@ -96,19 +82,6 @@ public void Dispose_should_not_call_coreServerSession_Dispose() mockCoreServerSession.Verify(m => m.Dispose(), Times.Never); } - [Fact] - public void WasUsed_should_do_nothing() - { - Mock mockCoreServerSession; - var subject = CreateSubject(out mockCoreServerSession); - -#pragma warning disable 618 - subject.WasUsed(); -#pragma warning restore - - mockCoreServerSession.Verify(m => m.WasUsed(), Times.Never); - } - // private methods private ServerSession CreateSubject(out Mock mockCoreServerSession) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs index 5da19ac0723..bbc3a9b1dd5 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs @@ -55,6 +55,7 @@ public UnifiedTestSpecRunner(ITestOutputHelper testOutputHelper) [UnifiedTestsTheory("client_side_operations_timeout.tests")] public void ClientSideOperationsTimeout(JsonDrivenTestCase testCase) { + SkipNotSupportedTestCases(testCase, "count on collection"); // .NET/C# driver does not implement a Count helper SkipNotSupportedTestCases(testCase, "dropIndexes"); SkipNotSupportedTestCases(testCase, "findOne"); SkipNotSupportedTestCases(testCase, "listIndexNames"); @@ -385,6 +386,17 @@ private static void SkipNotSupportedTestCases(JsonDrivenTestCase testCase, strin "legacy hello with speculative authenticate", "legacy hello without speculative authenticate is not redacted", + // crud + // .NET/C# driver does not implement a Count helper. These files also cover CountDocuments and + // EstimatedDocumentCount, so only the Count test cases are excluded. + "Deprecated count without a filter", + "Deprecated count with a filter", + "Deprecated count with skip and limit", + "Deprecated count with empty collection", + "Deprecated count with collation", + "Deprecated count with rawData option", + "Deprecated count with rawData option on less than 8.2.0 - ignore argument", + // retryableReads "collection.findOne succeeds after retryable handshake network error", "collection.findOne succeeds after retryable handshake server error (ShutdownInProgress)", @@ -418,12 +430,17 @@ private static void SkipNotSupportedTestCases(JsonDrivenTestCase testCase, strin "findOne.json", "findOne-serverErrors.json", "listCollectionObjects.json", - "listCollectionObjects.json", "listCollectionObjects-serverErrors.json", "listDatabaseObjects.json", "listDatabaseObjects-serverErrors.json", "listIndexNames.json", - "listIndexNames-serverErrors.json" + "listIndexNames-serverErrors.json", + + // .NET/C# driver does not implement a Count helper. + // Qualified by resource namespace because other specs have files of the same name that must keep running. + "retryable_reads.tests.unified.count.json", + "retryable_reads.tests.unified.count-serverErrors.json", + "transactions.tests.unified.count.json" ]); #region CMAP helpers diff --git a/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs index 67194200a53..df243e3d462 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs @@ -119,9 +119,8 @@ private void AssertValid(IAuthenticator authenticator, MongoCredential mongoCred { JsonDrivenHelper.EnsureAllFieldsAreValid(expectedCredential, "username", "password", "source", "mechanism", "mechanism_properties"); mongoCredential.Username.Should().Be(ValueToString(expectedCredential["username"])); -#pragma warning disable 618 - mongoCredential.Password.Should().Be(ValueToString(expectedCredential["password"])); -#pragma warning restore 618 + var actualPassword = (mongoCredential.Evidence as PasswordEvidence)?.ToInsecureString(); + actualPassword.Should().Be(ValueToString(expectedCredential["password"])); mongoCredential.Source.Should().Be(ValueToString(expectedCredential["source"])); mongoCredential.Mechanism.Should().Be(ValueToString(expectedCredential["mechanism"])); diff --git a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs index bfd46017416..032e4346f4d 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs @@ -24,6 +24,7 @@ using MongoDB.TestHelpers.XunitExtensions; using Xunit; using Xunit.Abstractions; +using Xunit.Sdk; namespace MongoDB.Driver.Tests.Specifications.client_side_encryption { @@ -59,6 +60,11 @@ public void Run(JsonDrivenTestCase testCase) RequireEnvironment.Check().EnvironmentVariable("KMS_MOCK_SERVERS_ENABLED"); } + if (testCase.Name.Contains("legacy.count.json")) + { + throw new SkipException(".NET/C# driver does not implement a Count helper."); + } + RequirePlatform .Check() .SkipWhen( diff --git a/tests/MongoDB.Driver.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs index 77b10f6ee35..8e064c3f2e6 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs @@ -176,9 +176,8 @@ private void AssertOptions(ConnectionString connectionString, BsonDocument defin connectionString.SrvServiceName.Should().Be(expectedOption.Value.AsString); break; case "ssl": -#pragma warning disable 618 - AssertBoolean(connectionString.Ssl, expectedOption.Value); -#pragma warning restore 618 + // the ssl option is an alias for tls and is surfaced through Tls + AssertBoolean(connectionString.Tls, expectedOption.Value); break; case "timeoutms": //Ignored for now as this is used by CSOT. break; diff --git a/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs b/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs index 7d099e02e8d..c7275e42eb4 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs @@ -129,7 +129,6 @@ private static ServerDescription BuildServerDescription( var maxWireVersion = serverData.maxWireVersion ?? 9; var wireVersionRange = new Range(0, maxWireVersion); - var serverVersion = new SemanticVersion(4, 4, 0); var serverId = new ServerId(clusterId, endPoint); return new ServerDescription( @@ -141,7 +140,6 @@ private static ServerDescription BuildServerDescription( lastWriteTimestamp: lastWriteTimestamp, heartbeatInterval: heartbeatInterval, wireVersionRange: wireVersionRange, - version: serverVersion, tags: tagSet, state: ServerState.Connected); } diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedCountOperation.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedCountOperation.cs deleted file mode 100644 index 56c9d67d52f..00000000000 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedCountOperation.cs +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright 2021-present MongoDB Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Threading; -using System.Threading.Tasks; -using MongoDB.Bson; - -namespace MongoDB.Driver.Tests.UnifiedTestOperations -{ - public class UnifiedCountOperation : IUnifiedEntityTestOperation - { - private readonly IMongoCollection _collection; - private readonly FilterDefinition _filter; - private readonly CountOptions _options; - private readonly IClientSessionHandle _session; - - public UnifiedCountOperation( - IMongoCollection collection, - FilterDefinition filter, - CountOptions options, - IClientSessionHandle session) - { - _collection = collection; - _filter = filter; - _options = options; - _session = session; - } - - public OperationResult Execute(CancellationToken cancellationToken) - { - try - { -#pragma warning disable CS0618 // Type or member is obsolete - var result = _session == null - ? _collection.Count(_filter, _options, cancellationToken) - : _collection.Count(_session, _filter, _options, cancellationToken); -#pragma warning restore CS0618 // Type or member is obsolete - - return OperationResult.FromResult(result); - } - catch (Exception exception) - { - return OperationResult.FromException(exception); - } - } - - public async Task ExecuteAsync(CancellationToken cancellationToken) - { - try - { -#pragma warning disable CS0618 // Type or member is obsolete - var result = _session == null - ? await _collection.CountAsync(_filter, _options, cancellationToken) - : await _collection.CountAsync(_session, _filter, _options, cancellationToken); -#pragma warning restore CS0618 // Type or member is obsolete - - return OperationResult.FromResult(result); - } - catch (Exception exception) - { - return OperationResult.FromException(exception); - } - } - } - - public class UnifiedCountOperationBuilder - { - private readonly UnifiedEntityMap _entityMap; - - public UnifiedCountOperationBuilder(UnifiedEntityMap entityMap) - { - _entityMap = entityMap; - } - - public UnifiedCountOperation Build(string targetCollectionId, BsonDocument arguments) - { - var collection = _entityMap.Collections[targetCollectionId]; - - FilterDefinition filter = null; - CountOptions options = null; - IClientSessionHandle session = null; - - foreach (var argument in arguments) - { - switch (argument.Name) - { - case "collation": - options ??= new CountOptions(); - options.Collation = Collation.FromBsonDocument(argument.Value.AsBsonDocument); - break; - case "comment": - options ??= new CountOptions(); - options.Comment = argument.Value; - break; - case "filter": - filter = new BsonDocumentFilterDefinition(argument.Value.AsBsonDocument); - break; - case "limit": - options ??= new CountOptions(); - options.Limit = argument.Value.AsInt32; - break; - case "maxTimeMS": - options ??= new CountOptions(); - options.MaxTime = TimeSpan.FromMilliseconds(argument.Value.AsInt32); - break; - case "session": - session = _entityMap.Sessions[argument.Value.AsString]; - break; - case "skip": - options ??= new CountOptions(); - options.Skip = argument.Value.AsInt32; - break; - case "timeoutMS": - options ??= new CountOptions(); - options.Timeout = UnifiedEntityMap.ParseTimeout(argument.Value); - break; - default: - throw new FormatException($"Invalid CountOperation argument name: '{argument.Name}'."); - } - } - - return new UnifiedCountOperation(collection, filter, options, session); - } - } -} diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestOperationFactory.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestOperationFactory.cs index ae64a0eb443..12d6b4e8955 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestOperationFactory.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestOperationFactory.cs @@ -90,7 +90,6 @@ public IUnifiedTestOperation CreateOperation(string operationName, string target { "aggregate" => new UnifiedAggregateOperationBuilder(_entityMap).BuildCollectionOperation(targetEntityId, operationArguments), "bulkWrite" => new UnifiedBulkWriteOperationBuilder(_entityMap).Build(targetEntityId, operationArguments), - "count" => new UnifiedCountOperationBuilder(_entityMap).Build(targetEntityId, operationArguments), "countDocuments" => new UnifiedCountDocumentsOperationBuilder(_entityMap).Build(targetEntityId, operationArguments), "createChangeStream" => new UnifiedCreateChangeStreamOnCollectionOperationBuilder(_entityMap).Build(targetEntityId, operationArguments), "createFindCursor" => new UnifiedCreateFindCursorOperationBuilder(_entityMap).Build(targetEntityId, operationArguments), diff --git a/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/LibmongocryptTests.cs b/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/LibmongocryptTests.cs index 0aab076d304..a6012a4ed7a 100644 --- a/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/LibmongocryptTests.cs +++ b/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/LibmongocryptTests.cs @@ -15,9 +15,7 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Threading; -using FluentAssertions; using Microsoft.Extensions.Logging; using MongoDB.Bson; using MongoDB.Driver.Core.Configuration; @@ -110,21 +108,6 @@ public void Explicit_encryption_with_libmongocrypt_package_works() var result = collection.Find(FilterDefinition.Empty).First(); _output.WriteLine(result.ToJson()); } - catch (Exception ex) - { - // SERVER-106469 -#pragma warning disable CS0618 // Type or member is obsolete - var serverVersion = client.Cluster.Description.Servers[0].Version; -#pragma warning restore CS0618 // Type or member is obsolete - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - serverVersion >= new SemanticVersion(8, 1, 9999)) - { - ex.Should().BeOfType(); - return; - } - - throw; - } finally { ClusterRegistry.Instance.UnregisterAndDisposeCluster(client.Cluster);