-
Notifications
You must be signed in to change notification settings - Fork 153
Add missing contracts in System.Linq.Expressions.Expression and derived types #171
Add missing contracts in System.Linq.Expressions.Expression and derived types #171
Conversation
|
@fedotovalex This is great! 😄 Note that I'm hand reviewing every added contract for accuracy, so please do not rebase, squash, or amend any commits in this pull request (doing so will force me to start over). I have not found any mistakes yet, but even if I do please just correct them as new commits. |
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.
Does it mean that arguments could be null?
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.
Yep, it seems that argument could be null. This is a valid case.
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.
💭 Just because the implementation doesn't crash when arguments is null doesn't mean the contract needs to allow null.
|
Review from Expression.cs:
|
|
Outstanding work overall @fedotovalex. You'll definitely need to update the items marked with ❗ since they are incorrect and the documentation explicitly covers the case. Let me know if you have any questions. |
|
@sharwell, thanks for the thorough review. Most of the items from the Expression.cs list are done. Here are some comments:
Everything else on the list should be addressed. |
|
Can we use PEX or similar to automatically generate tests for the framework, watch for exceptions and autogenerate contracts based on these? From: Alex Fedotov [mailto:notifications@github.com] @sharwellhttps://github.com/sharwell, thanks for the thorough review. Most of the items from the Expression.cs list are done. Here are some comments: · An attempt to compile an expression with Default(null) results in ArgumentNullException deep in the code when it tries to insert a null type value into a dictionary, so I added a precondition for type != null. Perhaps Microsoft guys can file an internal ticket to have it checked at runtime. · I did not include a precondition for type != typeof(void) in Parameter overloads because it cannot be proven by the static checker in the simplest cases. Contract.Assert(typeof(string) != typeof(void)); // CodeContracts: assert unproven
Everything else on the list should be addressed. — |
I was referring to Edit: I see you meant to say |
Okay, I updated the comment in the code and also submitted feedback on the corresponding MSDN page. Let me know if there are any other issues I need to address before this PR can move forward. |
|
I think everything is looking good and feature is ready for merging. Any objections? @fedotovalex, @sharwell? |
|
👍 |
Add missing contracts in System.Linq.Expressions.Expression and derived types
|
Merged. Thanks a lot, @sharwell, @fedotovalex! |
This addresses #170. Adds contracts for: