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

Idea / Feature #2061

Closed
8 tasks
94sedighi opened this issue Dec 5, 2022 · 1 comment
Closed
8 tasks

Idea / Feature #2061

94sedighi opened this issue Dec 5, 2022 · 1 comment

Comments

@94sedighi
Copy link
Contributor

Idea / Feature

We have a bunch of Properties and Methods in PropertyInfoExtensions.cs, PropertyInfoSelector.cs, MethodInfoSelector.cs, TypeSelector.cs in pending PRs. We can easily use them to extend to following Assertions:

PropertyInfoAssertions.cs and PropertyInfoSelectorAssertions.cs with:

  • [Not]BeAbstract()
  • [Not]BeStatic()

TypeSelectorAssertions:cs with:

  • [Not]BeAbstract()
  • [Not]BeSealed()
  • [Not]BeStructs()
  • [Not]BeInterfaces()

MethodInfoSelector.cs with:

  • [Not]BeAbstract()

Some other ideas would be:
PropertyInfoSelector.cs and MethodInfoSelector.cs with:

  • ThatAre[Not]Overridable

What do you guys think?

@jnyrup jnyrup added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Dec 5, 2022
@jnyrup
Copy link
Member

jnyrup commented Dec 5, 2022

As with PRs, please use an single issue per proposed API - but read the rest of this comment before you open six new issues.

This issue proposes 6 different kinds of APIs (abstract, static, sealed, structs, interfaces, overridable) which makes it harder to discuss (and eventually approve) each API separately.
If the proposals were split into separate issues, it will also be easier for you to come up with a more descriptive title than "Idea / Feature" which is, I'm sorry to say, unusable.

Also an API needs to "pull its own weight".
It means that we don't want to include everything in FluentAssertions just because "we can" or "it's easy to implement".
E.g. #1886 is a prime example of a proposed API that is both well-defined in terms of shape and implementation and don't have any edge cases, but we find the use-cases are so limited, so we're hesitant to approving it.
A better argument to add an API is, like I mentioned in #2054, if it brings consistency between our assertions, e.g. PropertyInfoSelector and MethodInfoSelector.

So a good API proposal needs to describe a use-cases and if possible what pitfalls/limitations there are.
E.g. in #2056 you're excluding decimal for the check if a Type is to be considered a struct.
I don't immediately know why that is, but it looks like a concern that could influence whether an API should be added and hence should be discussed in the issue instead of a PR.

Two examples of how to improve a proposal.
#1884 suggested to add BeDefined and listed two possible workarounds that he can use today.
#1886 describes in words a use-case for the proposed Implies and a code snippet of how to use it.

We will help with the exact shape of the API, but the proposer needs to do some of the work as well.

@jnyrup jnyrup closed this as completed Dec 5, 2022
@jnyrup jnyrup removed the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Dec 5, 2022
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

No branches or pull requests

2 participants