Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add tests for invalid inputs to Expression.New#10952

Merged
stephentoub merged 3 commits intodotnet:masterfrom
hughbe:new-expression-tests
Aug 19, 2016
Merged

Add tests for invalid inputs to Expression.New#10952
stephentoub merged 3 commits intodotnet:masterfrom
hughbe:new-expression-tests

Conversation

@hughbe
Copy link

@hughbe hughbe commented Aug 18, 2016

Also adds some param names that were brought up from these tests

Contributes to #1198 (~1% increase in CC)

/cc @stephentoub @VSadov

Also adds some param names that were brought up from these tests
Expression arg = arguments[i];
ParameterInfo pi = pis[i];
arg = ValidateOneArgument(method, nodeKind, arg, pi);
arg = ValidateOneArgument(method, nodeKind, arg, pi, methodParamName, $"{nameof(arguments)}[{i}]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite some additional string allocations here. I'd stick with a constant string, if any at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'm not sure how large the perf impact is, but maybe just a nameof() is good. I do think that it is important to have the param name, however.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nameof() is cheap, as it's just a const string in the compiled IL. String interpolation involves a String.Format call and associated allocations/work.

@hughbe
Copy link
Author

hughbe commented Aug 18, 2016

Thanks for the nameof comments, chaps. I've removed the string interpolation

@stephentoub
Copy link
Member

LGTM. Thanks, Hugh.

@stephentoub stephentoub merged commit c91aa58 into dotnet:master Aug 19, 2016
@hughbe hughbe deleted the new-expression-tests branch September 5, 2016 04:33
@karelz karelz modified the milestone: 1.1.0 Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Add tests for invalid inputs to Expression.New

Also adds some param names that were brought up from these tests


Commit migrated from dotnet/corefx@c91aa58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants