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

Add generic attributes and add class data attribute #99

Open
wants to merge 3 commits into
base: v1.7
Choose a base branch
from

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.

@@ -1,4 +1,4 @@
// Copyright (c) Andrew Arnott. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There seems to be a "Zero Width No-Break Space" here, which shows up as a line change. That shouldn't be there, right?

Copy link
Owner

Choose a reason for hiding this comment

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

That's probably the UTF-8 BOM, which shows up and disappears seemingly randomly in some text files. I wouldn't worry about it either way.

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.

@@ -1,4 +1,4 @@
// Copyright (c) Andrew Arnott. All rights reserved.
Copy link
Owner

Choose a reason for hiding this comment

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

That's probably the UTF-8 BOM, which shows up and disappears seemingly randomly in some text files. I wouldn't worry about it either way.


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.

namespace Xunit;

/// <summary>
/// Specifies a class that provides the values for a combinatorial test.
Copy link
Owner

Choose a reason for hiding this comment

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

nit: can we lose the extra indentation of the text within the summary tag?

Suggested change
/// Specifies a class that provides the values for a combinatorial test.
/// Specifies a class that provides the values for a combinatorial test.

namespace Xunit;

/// <summary>
/// Defines a class that provides values for a parameter on a test method.
Copy link
Owner

Choose a reason for hiding this comment

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

This isn't a class.

Suggested change
/// Defines a class that provides values for a parameter on a test method.
/// An interface that provides values for a parameter on a test method.

@@ -75,19 +82,10 @@ public CombinatorialMemberDataAttribute(string memberName, params object?[]? arg
/// <returns>The generic type argument for (one of) the <see cref="IEnumerable{T}"/> interface)s) implemented by the <paramref name="enumerableType"/>.</returns>
private static TypeInfo? GetEnumeratedType(Type enumerableType)
{
if (enumerableType.IsGenericType)
if (enumerableType.IsGenericType && enumerableType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
Copy link
Owner

Choose a reason for hiding this comment

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

Does this get rid of support for TheoryData<>?

@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
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