Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add DataSet, DataTable, and much more to corefx - #12426

Merged
stephentoub merged 1 commit into
dotnet:masterfrom
stephentoub:add_datacommon
Oct 13, 2016
Merged

stephentoub merged 1 commit into
dotnet:masterfrom
stephentoub:add_datacommon

Conversation

@stephentoub

@stephentoub stephentoub commented Oct 6, 2016 •

Copy link
Copy Markdown
Member
  • Ports src from desktop
  • Ports tests from Mono
  • Upgrades System.Data.SqlClient projects to netstandard 1.7

Some notes:

  • This adds ~120 public types and ~3800 public members to System.Data.Common. It includes all of the non-provider-specific types from System.Data.dll with the exception of permissions-related types (e.g. DbDataPermissionAttribute) and configuration-related types (e.g. DbProviderFactories).
  • I've done close to zero cleanup in the tests ported from Mono. There is a sizeable amount of work there to bring it into conformance with our normal usage of xunit, and I'll open an issue for that to be done subsequently. I did the minimal work necessary to bring the tests over, convert them to xunit, and get them passing.
  • I've done some cleanup/formatting/scrubbing/etc. in the product source, but there's still plenty more we could do if we want to, more application of C# features added since this code was written, etc.
  • I type-forwarded the SqlTypes down from System.Data.SqlClient into System.Data.Common, as they need to be known by DataSet and friends. SqlClient was accessing some internals of these types, so I put some workarounds in place to enable it to continue functioning without measurable performance loss and with the same behavior. They're slightly hacky, but they get the job done.

cc: @weshaggard, @ericstj, @terrajobst, @saurabh500, @YoungGah, @FransBouma
Fixes https://github.com/dotnet/corefx/issues/8622
Fixes https://github.com/dotnet/corefx/issues/2065
Related to https://github.com/dotnet/corefx/issues/4571 (DbProviderFactory is included, but DbProviderFactories is not)

@FransBouma

Copy link
Copy Markdown

Excellent! Thanks for the hard work so far! :)

Comment thread src/System.Data.Common/ref/project.json Outdated
"System.Runtime": "4.0.0",
"System.Threading.Tasks": "4.0.0",
"System.IO": "4.0.0"
"Microsoft.Win32.Primitives": "4.3.0-beta-24604-02",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you haven't pruned this dependency list yet? As I hope this doesn't depend on all these.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually did prune the list, based on looking at the compiled assembly and its dependencies. Is that an inaccurate approach? Which dependencies would you expect to see go away?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes looking at the assembly references is a good way to prune. What in the ref depends on System.Diagnostics.FileVersionInfo or System.Diagnostics.TraceSource? I wouldn't expect those to be used by any of the public APIs. They might be used by the implementation perhaps.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought this comment was on the src. I expect the ref can be trimmed. I'll do that.

@stephentoub stephentoub Oct 7, 2016 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the ref list is much shorter:
System.Collections.NonGeneric
System.ComponentModel
System.ComponentModel.Primitives
System.ComponentModel.TypeConverter
System.IO
System.ObjectModel
System.Runtime
System.Transactions
System.Xml.ReaderWriter

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also, there are several entries from the src that can actually be removed as well, e.g. CodeDom; I'd pruned the list prior to trimming out some implementation, and now those entries are no longer needed. I'll do that as well.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System.Transactions is not part of netstandard so that will become an issue when trying to add these APIs to netstandard. We will either need to add them as well or remove the dependent APIs. cc @terrajobst

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will either need to add them as well or remove the dependent APIs.

@weshaggard, removing System.Transactions would mean removing this method:

public abstract partial class DbConnection : System.ComponentModel.Component, System.Data.IDbConnection, System.IDisposable
{
    public virtual void EnlistTransaction(System.Transactions.Transaction transaction);
}

To be clear, though, you're not actually talking about removing it from this ref, right? You're instead talking about not having it in netstandard when the rest of these APIs are added there? My understanding is there's nothing wrong with having additional members here, and this one seems fairly important to expose, at least in core.

{
internal const string EcmaPublicKey = "b77a5c561934e089";
internal const string SystemDrawing = "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
internal const string MicrosoftVSDesigner = "Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope we don't really need to keep these strings for the attributes they are applied to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't need the attributes, I can remove these. I thought we would need them if we cared to support the designer scenarios... maybe we don't?

@weshaggard

Copy link
Copy Markdown
Member
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataColumnEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

I suspect we don't really need these attributes.

Particularly in the reference assemblies we can remove the majority of these ComponentModel attributes. You can see the list I used to pass to GenAPI to exclude a lot of these type of attributes from the ref. https://github.com/dotnet/standard/blob/master/platforms/attributeExcludeList.txt.


Refers to: src/System.Data.Common/ref/System.Data.Common.cs:115 in 23c9d86. [](commit_id = 23c9d86, deletion_comment = False)

@stephentoub

Copy link
Copy Markdown
Member Author

I suspect we don't really need these attributes. Particularly in the reference assemblies we can remove the majority of these ComponentModel attributes. You can see the list I used to pass to GenAPI to exclude a lot of these type of attributes from the ref. https://github.com/dotnet/standard/blob/master/platforms/attributeExcludeList.txt.

We don't need them because we don't care about them? Some of those in the list, like EditorBrowsable, would actually be necessary in the ref assembly if we wanted them to do their job. I'm happy to remove any such attributes if we no longer care about them, of course.

@weshaggard

Copy link
Copy Markdown
Member

like EditorBrowsable,

EditorBrowsable isn't in the list as you are correct that is interesting for the ref.

As for the others I don't think any of them are really interesting for refs and just cause noise.

@stephentoub

Copy link
Copy Markdown
Member Author

EditorBrowsable isn't in the list as you are correct that is interesting for the ref.

Ah, I misread EditorAttribute as EditorBrowsableAttribute.

As for the others I don't think any of them are really interesting for refs and just cause noise.

Do we not care about designers? If we do, I'd think we'd want those attributes included in the refs. If we don't, I'll strip them from the PR. Seems like those would need to be in the ref or they might as well be removed from the implementation as well.

@weshaggard

Copy link
Copy Markdown
Member

Do we not care about designers?

At this point we haven't cared and most things don't have this stuff applied throughout corefx. That's not to say it we won't start caring in the future but if we do I suspect we have more work to do. From past experience designers cannot work well with just refs as they also try to get resources and such which means we have other work to do for that scenario.

@stephentoub

Copy link
Copy Markdown
Member Author

At this point we haven't cared and most things don't have this stuff applied throughout corefx. That's not to say it we won't start caring in the future but if we do I suspect we have more work to do. From past experience designers cannot work well with just refs as they also try to get resources and such which means we have other work to do for that scenario.

Fair enough. So... delete the attributes throughout both ref and src (which also means I can remove those string resources)?

@weshaggard

Copy link
Copy Markdown
Member

Fair enough. So... delete the attributes throughout both ref and src (which also means I can remove those string resources)?

Yes I would clean those things up.

"4.1.0.0": "4.1.0",
"4.1.1.0": "4.3.0",
"4.1.2.0": "4.4.0"
"4.2.0.0": "4.4.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change do ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is maintained automatically by running msbuild /t:UpdatePackageIndex on the relevant package (and not running that when a change is needed results in build errors). 4.1.2 was never a stable/published version in the package, it was just a placeholder version number that was set after we shipped 4.1.1, so that we wouldn't inadvertently add to the same version. But since new APIs are being added, which necessitates bumping the minor version, we changed the version number to 4.2.0 instead of to 4.1.2, and this reflects that.

@saurabh500

Copy link
Copy Markdown
Contributor

For some reason, codeflow is not showing the file System.Data.SqlClient/ref/System.Data.SqlClient.cs b/src/System.Data.SqlClient/ref/System.Data.SqlClient.cs

However it shows up in the Diff.

In the SqlClient contracts, you have type forwarded all the SqlTypes to System.Data.Common

Two questions:

  1. Is the type forward for backward compatibility? In case a library depends on SqlClient and consumes the SqlTypes, they will continue to function?
  2. Will the SqlClient contracts still show the SqlTypes data types in tooling? I want to understand if this will cause any duplication.

@stephentoub

Copy link
Copy Markdown
Member Author
  1. Is the type forward for backward compatibility? In case a library depends on SqlClient and consumes the SqlTypes, they will continue to function?

Yes, it's for compat. If a binary was built against SqlClient and was trying to find the types there, the runtime will redirect them to System.Data.Common where the types are now defined. In general we do this any time we move a type from one assembly to another, essentially leaving breadcrumbs for existing code to follow.

  1. Will the SqlClient contracts still show the SqlTypes data types in tooling? I want to understand if this will cause any duplication.

No, there won't be duplication.

@saurabh500 saurabh500 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @stephentoub Can you verify that the manual tests of SqlClient run with 100% success rate before merging this PR?

@stephentoub

stephentoub commented Oct 13, 2016 •

Copy link
Copy Markdown
Member Author

Thanks for reviewing, @saurabh500! I've run the SqlClient manual tests, and they all passed successfully:

=== TEST EXECUTION SUMMARY ===
     System.Data.SqlClient.ManualTesting.Tests  Total: 80, Errors: 0, Failed: 0, Skipped: 0

- Ports src from desktop corefx
- Ports tests from Mono
- Upgrades the System.Data.SqlClient project to netstandard 1.7

Some notes:
- This adds ~120 public types and ~3800 public members to System.Data.Common. It includes all of the non-provider-specific types from System.Data.dll with the exception of permissions-related types (e.g. DbDataPermissionAttribute) and configuration-related types (e.g. DbProviderFactories).
- I've done close to zero cleanup in the tests ported from Mono.  There is a sizeable amount of work there to bring it into conformance with our normal usage of xunit, and I'll open an issue for that to be done subsequently.  I did the minimal work necessary to bring the tests over, convert them to xunit, and get them passing.
- I've done some cleanup/formatting/etc. in the product source, but there's still plenty more we could do if we want to, more application of C# features added since this code was written, etc.
- I type-forwarded the SqlTypes down from System.Data.SqlClient into System.Data.Common, as they need to be known by DataSet and friends.  SqlClient was accessing some internals of these types, so I put some workarounds in place to enable it to continue functioning without measurable performance loss and with the same behavior.  They're slightly hacky, but they get the job done.
@Gander7

Gander7 commented Aug 2, 2017 •

Copy link
Copy Markdown

Thanks for all the hard work,
I just installed 2.0.0-preview2-006497
but unfortunately DataTable dt = new DataTable(); and System.Data.DataTable dt = new DataTable();
generates 'DataTable' does not contain a constructor that takes 0 arguments

@PremSha20

Copy link
Copy Markdown

Does Dataset/DataTable/DataView Support INotifyPropertyChanged/INotifyCollectionChanged Interface in dot net core 3.0

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Add DataSet, DataTable, and much more to corefx

Commit migrated from dotnet/corefx@c5c75db
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataTable like API in .Net Core Are DataColumn, DataTable and DescriptionAttribute supported with ASP .Net Core ?

10 participants