Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DataSourceAttribute on .NET 6 and later #4074

Closed
wants to merge 5 commits into from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Nov 18, 2024

Fixes #233

Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

My idea for .NET Core support was to ship extra NuGet packages to not force deps on things most devs would not use. Furthermore, the current System.Data.* packages are windows only and it's possible we would want to ship some different implementation. Something along the lines of MSTest.DataSource.Oledb or MSTest.Data.Oledb

WDYT?

@Youssef1313
Copy link
Member Author

I'll need to investigate a bit how we can have this kind of extensibility. This needs a bit of design.

To move the logic to a separate package and have the dependency inverted, the new package has to somehow tell the TestAdapter what it needs to do. For example, the new package could say, SomeHelperClassInTestAdapter.RegisterDataSourceResolver(dataSourceAttribute => TryResolveDataSource(dataSourceAttribute) where TryResolveDataSource is defined in the new package.

Then when we encounter a DataSourceAttribute in TestAdapter, we could look over the registered lambdas and try one by one until one resolver succeeds.

The question is, what's the best way to have this new package do the registration. Or maybe there is a completely different approach that is better than what I have in mind? @Evangelink what do you think?

@nohwnd
Copy link
Member

nohwnd commented Nov 20, 2024

I agree with Amaury here. I also don't think we should need anything special from the nuget, it should just normally extend the ITestDataSource interface, like DataRow or DynamicData does: e.g. public class MySqlDataSourceAttribute : Attribute, ITestDataSource

This allows us to split the deps among their respective nugets, and the nuget is super standard, it just brings the lib into compilation, and is "registered" by being used on a test.

@Youssef1313
Copy link
Member Author

Youssef1313 commented Nov 20, 2024

@nohwnd The problem with that is it's not going to be compatible with what's already working on .NET Framework (i.e, it will be a new attribute)

@nohwnd
Copy link
Member

nohwnd commented Nov 20, 2024

I don't see the problem in that, it has not been working on .NET core until now, so users either don't have a solution or will have to do some change. And it is a design that is more aligned with what we have right now.

But feel free to prove me wrong :)

@Youssef1313
Copy link
Member Author

Starting discussion in #4092

Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

Requesting changes as we are going into a different direction. Let me know if you want to keep this one open for some time while we define the rest of the work.

@Youssef1313
Copy link
Member Author

I think we can close for now yes. If we wanted it back, it's there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support DataSourceAttribute in .Net Core.
3 participants