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

Unify API methods to check for attribute (GH-731) #1095

Merged
merged 2 commits into from Aug 26, 2019

Conversation

Evangelink
Copy link
Contributor

Fix #731

I have marked the old methods as obsolete but depending on your preferences, I could get rid of them (breaking changes).

I decided to name the methods XXXOrInherit not XXXOrInherits as recommended to follow the convention used by already implemented methods.

Some of the tests are failing because of my changes on PropertyInfoSelector.cs but I can't figure out what's wrong with my change. I'd be grateful for some fresh eyes because I am likely missing something obvious.

@dennisdoomen dennisdoomen changed the title [GH-731] Unify API methods to check for attribute Unify API methods to check for attribute (GH-731) Jul 10, 2019
@dennisdoomen
Copy link
Member

Hmm, the code you touched is supposed to be used internally and should not have been public in the first place.

@Evangelink
Copy link
Contributor Author

@dennisdoomen Which strategy do you want to go for? Breaking change, in which case we can change the accessibility, current option (with Obsolete) or shall I remove the Obsolete?

@@ -65,7 +66,18 @@ public PropertyInfoSelector ThatAreDecoratedWith<TAttribute>()
public PropertyInfoSelector ThatAreDecoratedWithOrInherit<TAttribute>()
where TAttribute : Attribute
{
selectedProperties = selectedProperties.Where(property => CustomAttributeExtensions.GetCustomAttributes(property, true).OfType<TAttribute>().Any());
// TODO: There seems to be a bug with `GetCustomAttributes` when used as extension method
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that there is a bug with GetCustomAttributes, I'll file an issue on Microsoft side.

@jnyrup
Copy link
Member

jnyrup commented Jul 11, 2019

@Evangelink If I remember correct GetCustomAttributes behaves differently for net45.
I'm on mobile for the next two weeks, so can't look it up at the moment, but I think I also commented it in some other FA issue/PR.

@dennisdoomen
Copy link
Member

I think we can make all of these internal. They were never supposed to be used outside the assembly.

@Evangelink
Copy link
Contributor Author

@jnyrup it seems that the bug only happens when using the method as extension method so I did a change in the code and left a message to explain why,

@dennisdoomen Just to be sure, are you referring to HasAttribute and the new methods added? All the methods of the TypeExtensions class or something else?

@dennisdoomen
Copy link
Member

All the methods of the TypeExtensions class. In fact, anything under Common is for internal use.

@Evangelink
Copy link
Contributor Author

Do you want me to do it in this PR or to create a new one?

@dennisdoomen
Copy link
Member

Do you want me to do it in this PR or to create a new one?

Whatever you like ;-)

@Evangelink
Copy link
Contributor Author

@dennisdoomen Are you okay with InternalsVisibleTo? Because a lot of the extension methods are used in the unit tests

@Evangelink
Copy link
Contributor Author

ping @dennisdoomen

@jnyrup
Copy link
Member

jnyrup commented Aug 23, 2019

I like the PR as it is right now.
We are not currently consistent in when types in FluentAssertions.Common should be internal
E.g. CSharpAccessModifier is inside FluentAssertions.Common, but public and used for HaveAccessModifier.

@Evangelink
Copy link
Contributor Author

I'll try to push a rebase before the week-end. Thank you for the review :)

@Evangelink
Copy link
Contributor Author

@dennisdoomen @jnyrup PR ready to be merged!

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.

Consistency in Attribute assertions
3 participants