The MongoOptionsExtension copy constructor (MongoOptionsExtension(MongoOptionsExtension copyFrom)) copies most configuration fields (ConnectionString, ClientSettings, MongoClient, DatabaseName, CryptProvider, CryptProviderPath, KeyVaultNamespace, KmsProviders, QueryMode) but omits two: CryptExtraOptions and QueryableEncryptionSchemaMode.
Because every With* method clones via this copy constructor, chaining any With* call after one that set those fields silently loses them.
Repro
var ext = new MongoOptionsExtension() .WithCryptProvider(provider, extraOptions: someExtraOptions) // sets CryptExtraOptions .WithQueryMode(MongoQueryMode.DriverLinq); // clones via copy ctor -> CryptExtraOptions LOST // ext.CryptExtraOptions is now null
Same for QueryableEncryptionSchemaMode set via WithQueryableEncryptionSchemaMode(...) followed by any other With*.
Impact
Silent loss of Queryable Encryption configuration (extra crypt options + schema mode) depending on the order of fluent option calls — a data-fidelity / config-correctness bug in the encryption surface.
Fix
- Add CryptExtraOptions = copyFrom.CryptExtraOptions; and QueryableEncryptionSchemaMode = copyFrom.QueryableEncryptionSchemaMode; to the copy constructor.
- Add a clone-fidelity round-trip test asserting that every field survives an arbitrary chain of With* calls (guards against future omissions).