-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
Summary
The bug is very obvious, the equality does not work because you forgot to implement an equality operator for the WriteConcern class and you are using the equality operator inside the Equals method of the MongoClientSettings.
therefore it uses the default equality (by reference) and fails.
You might be fooled to think that the equality by reference will still work because you have declared all your WriteConcern types static and use only those.
but in MongoUrl.GetWriteConcern function
you are creating a new instance of WriteConcern out side of the "if".
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
version 2.18.0
How to Reproduce
Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.
```
var settings1 = MongoClientSettings.FromConnectionString("mongodb+srv://arik:arik123@test.abcd.mongodb.net/?w=majority"); var settings2 = MongoClientSettings.FromConnectionString("mongodb+srv://arik:arik123@test.abcd.mongodb.net/?w=majority"); Console.WriteLine(settings1 == settings2);
```
Result is false.
Additional Background
Please provide any additional background information that may be helpful in diagnosing the bug.