Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2220

ISupportInitialize ignored on some versions of .NET

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5
    • Component/s: BSON
    • None
    • Environment:
      .NET Core 2.0

      The source code (BsonClassMapSerializer.cs) appears to have the following statement around .BeginInit and .EngInit calls:
      #if NET45
      ...
      #endif

      The #if statement was added to avoid dependency on unsupported API where it's not available, but in my case, where NETCOREAPP2_0 is defined instead of NET45, casting document to ISupportInitialize then calling InitBeginand InitEnd seems to work perfectly fine.

      Can we change the #if condition to something that captures more version that support the feature, or is there another reason to keep it? (If so - would be nice to document it)

      This created a lot of confusion for me since the docs don't specify version requirement for this feature to work, so I couldn't figure out why EndInit wasn't being called.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            ytaben Yaroslav Taben
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: