-
Notifications
You must be signed in to change notification settings - Fork 32
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
Introduce ConstraintExpression #174
Conversation
Thanks for supplying this @Dreamescaper. I'm been busy due to the holidays, but hopefully I can give this a proper look tomorrow. |
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.
At first when I read the above description I thought that ConstraintPartExpression
should be named ConstraintExpressionPart
, but looking through the code I think that ConstraintPartExpression
is the right choice.
I like that we are removing some of the technical details from the analyzers and into classes that represents concepts, and I think that this is a step in the right direction, so I very much think that the approach makes sense (and hopefully we can simplify more in later PRs).
I've left some minor comments - mostly nitpick.
src/nunit.analyzers/SameAsIncompatibleTypes/SameAsIncompatibleTypesAnalyzer.cs
Outdated
Show resolved
Hide resolved
bf5f297
to
ec424cd
Compare
Updated PR with tests, added docs, minor changes. Happy New Year :) |
Also Happy new year from my end. I'll take a look at this PR next year :) |
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 just corrected one typo. Otherwise, I think it looks great. Thanks
Created classes
ConstraintExpression
andConstraintPartExpression
, and moved methods fromAssertExpressionHelper
there.ConstraintExpression
represents the whole constraint expression (e.g.Is.Not.Null & Is.EqualTo("1").Or.EqualTo("A").IgnoreCase
), and has propertyConstraintPartExpression[] ConstraintParts
.ConstraintPartExpression
represents single part of constraint expression, which are combined using binary operators (|
or&
) or constraint expression operator properties (.And
or.Or
).(e.g.
Is.Not.Null
,Is.EqualTo("1")
,EqualTo("A").IgnoreCase
)ConstraintPartExpression
has three main properties:PrefixExpressions
- expressions which go before actual constraint method/property expression (Not
,None
,Count
,Property(...)
etc).RootExpression
- actual constraint method/property expression (Null
,EqualTo("1")
etc.)SuffixExpressions
- expressions which go after actual constraint expression (IgnoreCase
,Within(...)
,Using(...)
etc)Created draft PR to show idea and for discussion. If suggested approach makes sense, I will add tests, add docs, etc.