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

Use StringSyntaxAttribute to provide IDE support for proper reasons #2630

Open
psychotoad opened this issue Apr 29, 2024 · 2 comments
Open
Labels
api-approved API was approved, it can be implemented enhancement

Comments

@psychotoad
Copy link

Background and motivation

I suggest that you add the StringSyntaxAttribute to the because parameter so I get a suggestion when I miss a format item that corresponds to each object argument or vice versa.

API Proposal

public class EnumAssertions<TEnum, TAssertions>
{
    public AndConstraint<TAssertions> BeDefined([StringSyntax("CompositeFormat")] string because = "", params object[] becauseArgs);
    public AndConstraint<TAssertions> NotBeDefined([StringSyntax("CompositeFormat")] string because = "", params object[] becauseArgs);
}

API Usage

var dayOfWeek = (DayOfWeek)1;
var foo = "foo";
dayOfWeek.Should().BeDefined("Foo {0}", foo);

Alternative Designs

No response

Risks

No response

Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?

Yes, please assign this issue to me.

@psychotoad psychotoad added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Apr 29, 2024
@dennisdoomen dennisdoomen changed the title [API Proposal]: Use StringSyntaxAttribute to provide IDE support for proper reasons May 3, 2024
@dennisdoomen
Copy link
Member

I like that. It is even supported by PolySharp.

@jnyrup you agree?

@jnyrup
Copy link
Member

jnyrup commented May 6, 2024

@jnyrup you agree?

I agree, go ahead.

@jnyrup jnyrup removed the api-suggestion Early API idea and discussion, it is NOT ready for implementation label May 7, 2024
@dennisdoomen dennisdoomen added the api-approved API was approved, it can be implemented label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved, it can be implemented enhancement
Projects
None yet
Development

No branches or pull requests

3 participants