Remove unreachable from production code MongoDB.Driver.Core.WireProtocol.Messages.Encoders.JsonEncoders namespace

XMLWordPrintableJSON

    • None
    • Fully Compatible
    • Dotnet Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      The namespace contains 10 classes. Outside of tests, only JsonMessageEncoderFactory is used — and even then only within the namespace itself (CompressedMessageJsonEncoder calls it internally).

       The full picture

       - JsonMessageEncoderFactory is the single entry point — it implements IMessageEncoderFactory and is the only way to reach the concrete encoders. But even this factory is never instantiated in production src/ code outside the namespace.
       - The only non-test, non-namespace reference is in tests/MongoDB.Driver.Tests/Core/Helpers/MessageHelper.cs (TranslateMessagesToBsonDocuments), which is a test helper. However it looks wrong to use the separate encoder to test the actual encoder behavior/output. The helper method should be rewritten to go through binary encoding instead - serialize via BinaryMessageEncoderFactory into a MemoryStream, then deserialize back to BsonDocument.
       - All 10 classes are internal, so they're invisible outside the assembly entirely.

      Bottom line: The entire JsonEncoders namespace is only consumed by tests. It has no production call sites outside its own directory.

            Assignee:
            Oleksandr Poliakov
            Reporter:
            Oleksandr Poliakov
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: