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
Hello! It's me again. Found a new defect with the same problem.
Sorry for the spam, added comment to the previose bug last week
but decided to open a new defect.
Unhandled exception. System.ArgumentException: Argument types do not match
at System.Linq.Expressions.Expression.Constant(Object value, Type type)
at AgileObjects.ReadableExpressions.Translations.MemberAccessTranslation.For(MemberExpression memberAccess, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetDefaultTranslation(Expression expression)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetTranslationFor(Expression expression)
at AgileObjects.ReadableExpressions.Translations.BinaryTranslation..ctor(BinaryExpression binary, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.BinaryTranslation.For(BinaryExpression binary, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetDefaultTranslation(Expression expression)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetTranslationFor(Expression expression)
at AgileObjects.ReadableExpressions.Extensions.PublicTranslationContextExtensions.GetCodeBlockTranslationFor(ITranslationContext context, Expression expression)
at AgileObjects.ReadableExpressions.Translations.LambdaTranslation..ctor(LambdaExpression lambda, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetDefaultTranslation(Expression expression)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetTranslationFor(Expression expression)
at AgileObjects.ReadableExpressions.Translations.ParameterSetTranslation.GetParameterTranslation(Expression parameter, IParameter info, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ParameterSetTranslation.<>c__DisplayClass7_0.<.ctor>b__0(Expression p, Int32 index)
at AgileObjects.ReadableExpressions.Extensions.InternalEnumerableExtensions.Project[TItem,TResult](IEnumerable`1 items, Func`3 projector)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at AgileObjects.ReadableExpressions.Translations.ParameterSetTranslation..ctor(IMethodBase method, IEnumerable`1 parameters, Boolean showParameterTypeNames, Int32 count, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ParameterSetTranslation.For[TParameterExpression](IMethodBase method, ICollection`1 parameters, Boolean showParameterTypeNames, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ParameterSetTranslation.For[TParameterExpression](IMethod method, ICollection`1 parameters, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.MethodCallTranslation.For(MethodCallExpression methodCall, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetDefaultTranslation(Expression expression)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetTranslationFor(Expression expression)
at AgileObjects.ReadableExpressions.Extensions.PublicTranslationContextExtensions.GetCodeBlockTranslationFor(ITranslationContext context, Expression expression)
at AgileObjects.ReadableExpressions.Translations.LambdaTranslation..ctor(LambdaExpression lambda, ITranslationContext context)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetDefaultTranslation(Expression expression)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetTranslationFor(Expression expression)
at AgileObjects.ReadableExpressions.Translations.ExpressionTranslation.GetTranslation()
at AgileObjects.ReadableExpressions.ExpressionExtensions.ToReadableString(Expression expression, Func`2 configuration)
at ConsoleApp2.LambdaExpressionExtension.GetMember(LambdaExpression memberSelector) in C:\Users\EV\source\repos\ConsoleApp2\Program.cs:line 97
at ConsoleApp2.ResponseValidator`1.ResponseValue[TProperty](Expression`1 property) in C:\Users\EV\source\repos\ConsoleApp2\Program.cs:line 60
at ConsoleApp2.Program.Main(String[] args) in C:\Users\EV\source\repos\ConsoleApp2\Program.cs:line 40
namespace ConsoleApp2
{
internal class Program
{
private static void Main(string[] args)
{
var source = new BalanceSource
{
Currency = new List<ExcludedCurrency>
{
new()
{
Code = CurrencyType.USD
}
}
};
var balances = new List<BalanceModel>
{
new()
{
Amount = 1,
Currency = CurrencyType.EUR
},
new()
{
Amount = 5,
Currency = CurrencyType.USD
},
new()
{
Amount = 10,
Currency = CurrencyType.GBP
}
};
new ResponseValidator<List<BalanceModel>>(balances)
.ResponseValue(x => x.Any(c => c.Currency == source.Currency.First().Code));
}
}
public class ResponseValidator<T>
{
private readonly T _response;
public ResponseValidator(T response)
{
_response = response;
}
public ResponseValidator<T> ResponseValue<TProperty>(Expression<Func<T, TProperty>> property)
{
var member = property.GetMember();
var compiledProperty = property.Compile()(_response);
Console.WriteLine($"{member}: {compiledProperty}");
return this;
}
}
public class BalanceModel
{
public double Amount { get; set; }
public CurrencyType Currency { get; set; }
}
public class BalanceSource
{
public List<ExcludedCurrency> Currency { get; set; }
}
public class ExcludedCurrency
{
public CurrencyType Code { get; set; }
}
public enum CurrencyType
{
EUR,
GBP,
USD
}
public static class LambdaExpressionExtension
{
public static string GetMember(this LambdaExpression memberSelector)
{
var i = new Func<ITranslationSettings, ITranslationSettings>(s => s.ShowCapturedValues);
return memberSelector.ToReadableString(i);
}
}
}
The text was updated successfully, but these errors were encountered:
Hello! It's me again. Found a new defect with the same problem.
Sorry for the spam, added comment to the previose bug last week
but decided to open a new defect.
The text was updated successfully, but these errors were encountered: