Bug 29167 - Update System.Data to .NET 4.5.1 APIs
Summary: Update System.Data to .NET 4.5.1 APIs
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Alexander Köplinger [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-04-16 17:05 UTC by Brice Lambson
Modified: 2016-10-20 15:57 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Brice Lambson 2015-04-16 17:05:39 UTC
The following (non-breaking) changes were made to the System.Data APIs in the .NET Framework 4.5.1 release. Mono also needs to be updated so that technologies depending on them (like Entity Framework 7) will also work on Mono.

The following member were added.
- System.Data.Common.DbParameter.Precision
- System.Data.Common.DbParameter.Scale
- System.Data.SqlClient.SqlConnectionStringBuilder.ConnectRetryCount
- System.Data.SqlClient.SqlConnectionStringBuilder.ConnectRetryInterval
 
The following member were changed from abstract to virtual.
- System.Data.Common.DbDataReader.Close
- System.Data.Common.DbDataReader.GetSchemaTable
- System.Data.Common.DbParameter.SourceVersion
- System.Data.Common.DbParameterCollection.IsFixedSize
- System.Data.Common.DbParameterCollection.IsReadOnly
- System.Data.Common.DbParameterCollection.IsSynchronized
Comment 1 Brice Lambson 2015-04-16 17:12:27 UTC
(More information from Deigo Vega)

Before .NET 4.5.1 Precision and Scale properties were only implemented explicitly as part of the IDbParameter interface in DbParameter. We didn’t want to keep the interface in System.Data.Common therefore we wanted to have an implementation of the properties as part of the DbParameter in System.Data.

However, since System.Data is required to remain compatible with existing (already compiled) providers it wasn’t possible to just turn the explicit implementation into implicit. Instead, we wrap the explicit implementation like this:

    byte IDbDataParameter.Precision { 
        get { return 0; }
        set { }
    }

    byte IDbDataParameter.Scale {
        get { return 0; }
        set { }
    }

    public virtual byte Precision {
        get { return ((IDbDataParameter)this).Precision; }
        set { ((IDbDataParameter)this).Precision = value; }
    }

    public virtual byte Scale {
        get { return ((IDbDataParameter)this).Scale; }
        set { ((IDbDataParameter)this).Scale = value; }
    }

With this design, existing providers will still implement the interface, and new provider can simply override the virtual properties, but client code calling the virtual properties will always do the same.

It is also worth noting that many of the providers in .NET actually exposed properties Precision and Scale on their provider specific parameter class. E.g. SqlParameter does this. This can cause a compile time compatibility issue. You need to either add the new “new” keyword to hide the Scale and Precision virtual properties in DbParameter, switch to overriding the new virtual properties.

I believe although Mono might be somewhat different it may share the same compatibility concerns.

Hope this helps,
Diego
Comment 2 Marek Safar 2016-10-20 06:59:54 UTC
@alexander I think we implemented most recently, could you check
Comment 3 Alexander Köplinger [MSFT] 2016-10-20 15:57:42 UTC
Most of System.Data was replaced with referencesource code in https://github.com/mono/mono/commit/3d46f1d9c74231936899c11dd336715111a2008f last year.

This includes all the types mentioned above: System.Data.Common.DbParameter, System.Data.SqlClient.SqlConnectionStringBuilder, System.Data.Common.DbDataReader, System.Data.Common.DbParameter and System.Data.Common.DbParameterCollection should be fine since that commit.

If you find additional things that don't work please file a separate issue, thank you!