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 syntax option to be more grammatically correct #1591

Closed
RexTremendae opened this issue Jun 6, 2019 · 8 comments
Closed

Add syntax option to be more grammatically correct #1591

RexTremendae opened this issue Jun 6, 2019 · 8 comments

Comments

@RexTremendae
Copy link

My understanding of this library is that it should be possible to write code that can be read almost like natural language, i.e. A<string>... can be read as "A string..." etc.

Writing A<int>... would read "A int..." which is grammatically incorrect. It should read "An int" in natural language.

Suggestion: Add an An class which can be used totally interchangeable with the A class.

@thomaslevesque
Copy link
Member

Hi @RexTremendae,

Thanks for the suggestion. To be honest I'm a little torn on this... One one hand, it's true that it would be more correct grammatically. On the other, I don't like the idea of having another class that does exactly the same thing.

I think the idea came up before, but I can't find the issue if it exists.

@blairconrad what do you think?

@thomaslevesque
Copy link
Member

thomaslevesque commented Jun 7, 2019

BTW @RexTremendae, if it bothers you to write A<int>, you can just create an alias:

using An = FakeItEasy.A;

This will give you exactly the syntax you want.

Scratch that. You can't make a generic alias (which is a shame; vote on this issue to change it!)

@blairconrad
Copy link
Member

blairconrad commented Jun 8, 2019 via email

@thomaslevesque
Copy link
Member

M. Levesque, your suggestion is excellent. Shall we create an issue to find a spot in the docs and add it as an official recommendation?

Looks like you answered by mail, so you didn't see my edit. This suggestion doesn't actually work, because you can't make a generic alias, unfortunately.

@blairconrad
Copy link
Member

Too bad. In that case, how about creating a tiny tiny class that delegates to A?

@thomaslevesque
Copy link
Member

In that case, how about creating a tiny tiny class that delegates to A?

I assume you mean in user code, not in FakeItEasy? In that case: 👍

@RexTremendae if you need this, here's the code:

public static class An<T>
{
    public static INegatableArgumentConstraintManager<T> That => A<T>.That;
    public static T _ => A<T>._;
    public static T Ignored => A<T>.Ignored
}

@RexTremendae
Copy link
Author

@thomaslevesque thanks for the input.

But I still don't really understand what would be the harm adding it to FakeItEasy? From a user perspective I would really like to use this feature out-of-the-box without having to add it in the client code.

@thomaslevesque
Copy link
Member

But I still don't really understand what would be the harm adding it to FakeItEasy?

There would be no harm, but that's not enough for a feature to be considered useful. In this case, very few people actually want this feature, and there's an easy workaround if you want it. So we'd rather not add clutter to the API surface for very little added value.

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

3 participants