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

Introduce CombinatorialClassDataAttribute #99

Merged
merged 6 commits into from
Dec 30, 2024

Conversation

siewers
Copy link
Contributor

@siewers siewers commented Oct 2, 2024

Fixes #95 and introduces support for combinatorial class data.

This PR is all over the place, but I think it provides improvements overall.

There are many tests that could or should be cleaned up. I tried my best to keep things together, but the mix of generic attributes and different ways of accessing data makes it hard to organize. Any ideas are welcome.

I also resolved some rebasing conflicts with my branch, which seems fine since all tests are still passing.
However, I might have missed some cases, in which case more tests should be added.
It might also be related to some cleanup done recently, which I haven't kept up with - I'll fix all of those if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Introducing this interface is technically a breaking change since the Values property on the attributes has been replaced with the GetValues method.

Copy link
Owner

@AArnott AArnott left a comment

Choose a reason for hiding this comment

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

I like the changes, generally. A few comments to resolve before we merge.


namespace Xunit;

#if NETSTANDARD2_0_OR_GREATER
Copy link
Owner

Choose a reason for hiding this comment

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

Generic attributes cannot be reflected over (with standard .NET reflection APIs) on .NET Framework.
If we are to add this attribute, I believe we should only declare it when targeting .NET.

It appears the value-add of this class is to add a generic type constraint. We could achieve a similar guard for the non-generic attribute type (and drop the need for this generic one) by adding an analyzer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. The usefulness of generic attributes is rather slim. I've tried to come up with good use cases, but I always seem to fall back on ones using Type instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear, are you suggesting we drop the idea of generic attributes, or should I change the condition?

Copy link
Owner

Choose a reason for hiding this comment

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

I'd go either way, but I'm leaning toward "less is more", so I'd mildly prefer we drop the generic attributes.
Then, if we want to add compile-time enforcement of the types provided, we can add an analyzer. But I'm guessing that's not worth the effort if a runtime exception will get the point across soon enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'm fine dropping the generic attributes as well. However, the PR and branch names should be changed then, or what do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

I don't care about the branch name. But the PR title can be edited, sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright! I've removed the two generic attributes and renamed the PR.

src/Xunit.Combinatorial/CombinatorialClassDataAttribute.cs Outdated Show resolved Hide resolved
src/Xunit.Combinatorial/ICombinatorialValuesProvider.cs Outdated Show resolved Hide resolved
@AArnott AArnott changed the base branch from main to v1.6 December 28, 2024 03:27
@AArnott AArnott changed the base branch from v1.6 to v1.7 December 28, 2024 03:28
@siewers siewers changed the title Add generic attributes and add class data attribute Introduce CombinatorialClassDataAttribute Dec 30, 2024
@siewers
Copy link
Contributor Author

siewers commented Dec 30, 2024

I noticed the readme might need an update. Should I do that, or would you instead do that yourself?

@AArnott
Copy link
Owner

AArnott commented Dec 30, 2024

By all means I'd welcome you updating the docs. But don't update the README for the v1.7 branch, since no one reads that.
Instead, the main branch has moved almost all docs to the docfx folder. So that'll require another pull request to update that, and probably after I merge v1.7 into main (which I'll do after completing this PR).

So if you can update the docs after that's been done, I'd appreciate it.

@AArnott AArnott merged commit 41b6f39 into AArnott:v1.7 Dec 30, 2024
3 checks passed
@AArnott AArnott mentioned this pull request Dec 30, 2024
@siewers siewers deleted the generic_combinatorial_attributes branch December 31, 2024 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add generic combinatorial attributes
2 participants