You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Additional methods in fluent syntax causes exception 'variable referenced from scope ... but it is not defined' #251
Effectively, putting the additional methods "WithCoverage" and "OverSite" causes BDDFY to fail with exception:
An exception of type 'System.InvalidOperationException' occurred in System.Core.dll but was not handled in user code
Additional information: variable 'x' of type '' referenced from scope '', but it is not defined
Removing the fluent extensions I created for my types allows it to work.
But the alternative of complex unreadable constructors for all my permutations is wrong (shouldn't have to change the object under test). Is there a way to achieve what I'm trying to achieve here?
at System.Linq.Expressions.Compiler.VariableBinder.Reference(ParameterExpression node, VariableStorageKind storage)
at System.Linq.Expressions.Compiler.VariableBinder.VisitParameter(ParameterExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.Compiler.VariableBinder.VisitUnary(UnaryExpression node)
at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection1 nodes) at System.Linq.Expressions.Compiler.VariableBinder.VisitLambda[T](Expression1 node)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
at TestStack.BDDfy.ExpressionExtensions.ArgumentExtractorVisitor.GetValue(Expression a)
at TestStack.BDDfy.ExpressionExtensions.ArgumentExtractorVisitor.ExtractStepArgument(Expression a)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection) at TestStack.BDDfy.ExpressionExtensions.ArgumentExtractorVisitor.VisitMethodCall(MethodCallExpression node) at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression1 node)
at TestStack.BDDfy.ExpressionExtensions.ExtractArguments[T](LambdaExpression expression, T value)
at TestStack.BDDfy.FluentScanner1.AddStep(Action1 action, LambdaExpression stepAction, String stepTextTemplate, Boolean includeInputsInStepTitle, Boolean reports, ExecutionOrder executionOrder, Boolean asserts, String stepPrefix)
at TestStack.BDDfy.FluentStepBuilder1.And(Expression1 step)
I suspect the offending code is the fact that the ExpressionExtensions.ArgumentExtractorVisitor.GetValue() method assumes a Func<object> when in fact the first call in my method chain returns an object as well.
I added another method onto the chain that returned the current TScenario, and then called yet another method from TScenario (which did nothing) and it now works. Having these two extra methods is a bit lame. Also it sees that last method in the call chain as the one doing the work so it pulls name information from that one, rather than the first one (no problem on that, can specify the string to show).
Activity
develorem commentedon Jun 5, 2017
Sorry, stack trace would have been helpful:
at System.Linq.Expressions.Compiler.VariableBinder.Reference(ParameterExpression node, VariableStorageKind storage)
at System.Linq.Expressions.Compiler.VariableBinder.VisitParameter(ParameterExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.Compiler.VariableBinder.VisitUnary(UnaryExpression node)
at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection
1 nodes) at System.Linq.Expressions.Compiler.VariableBinder.VisitLambda[T](Expression1 node)at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
at TestStack.BDDfy.ExpressionExtensions.ArgumentExtractorVisitor.GetValue(Expression a)
at TestStack.BDDfy.ExpressionExtensions.ArgumentExtractorVisitor.ExtractStepArgument(Expression a)
at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection) at TestStack.BDDfy.ExpressionExtensions.ArgumentExtractorVisitor.VisitMethodCall(MethodCallExpression node) at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression1 node)at TestStack.BDDfy.ExpressionExtensions.ExtractArguments[T](LambdaExpression expression, T value)
at TestStack.BDDfy.FluentScanner
1.AddStep(Action1 action, LambdaExpression stepAction, String stepTextTemplate, Boolean includeInputsInStepTitle, Boolean reports, ExecutionOrder executionOrder, Boolean asserts, String stepPrefix)at TestStack.BDDfy.FluentStepBuilder
1.And(Expression1 step)develorem commentedon Jun 5, 2017
I suspect the offending code is the fact that the
ExpressionExtensions.ArgumentExtractorVisitor.GetValue()method assumes aFunc<object>when in fact the first call in my method chain returns an object as well.I added another method onto the chain that returned the current TScenario, and then called yet another method from TScenario (which did nothing) and it now works. Having these two extra methods is a bit lame. Also it sees that last method in the call chain as the one doing the work so it pulls name information from that one, rather than the first one (no problem on that, can specify the string to show).
SonOfSardaar commentedon May 30, 2026
this should be addressed by #307 . If it does not , then please re-open it with good example that can explain setup and expectation better.