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

Better solution for lambda argument name #1

Open
pmacn opened this issue Jan 3, 2014 · 0 comments
Open

Better solution for lambda argument name #1

pmacn opened this issue Jan 3, 2014 · 0 comments

Comments

@pmacn
Copy link
Owner

pmacn commented Jan 3, 2014

The test WhenStatementWithSingleArgument_ParamNameIsEmptyString exposes a weakness in the current implementation. It's by no means a terrible bug but it's there and it should probably go away.

The problem here is that all we have access too is simple reflection on the class generated by the compiler to handle the lambda closure. This gives us no information as to what the method in the lambda actually does.

Options

  • Find a way to get the IL or some other representation of the method that can be parsed.
  • Use the much slower approach of passing an Expression<Func<T>> that requires compiling the method every time even when the requirement is met.
  • Make a separate package for RequireThat.Lambda using platform specific implementations. Using either the hack version or Expression<Func<T>> on the platforms that do not support GetMethodBody()

However, as long as the library is used as intended this should never show it's face and maybe it should just be documented as a known flaw and we move on.

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

1 participant