-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: v1.7
Are you sure you want to change the base?
Conversation
@@ -1,4 +1,4 @@ | |||
// Copyright (c) Andrew Arnott. All rights reserved. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
/// 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. |
There was a problem hiding this comment.
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.
/// 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<>)) |
There was a problem hiding this comment.
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<>
?
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.