Open CREFaulk opened 3 years ago
System.ArgumentException
HResult=0x80070057
Message=Contract Assume failed
Source=Linq2RestANC
StackTrace:
at Linq2Rest.CustomContract.Assume(Boolean cond, String msg)
at Linq2Rest.CustomContract.Assume(Boolean cond)
at Linq2Rest.Parser.Readers.EnumExpressionFactory.Convert(String token)
at Linq2Rest.Parser.Readers.ParameterValueReader.Read(Type type, String token, IFormatProvider formatProvider)
at Linq2Rest.Parser.FilterExpressionFactory.GetParameterExpression(String filter, Type type, IFormatProvider formatProvider)
at Linq2Rest.Parser.FilterExpressionFactory.CreateExpression[T](String filter, ParameterExpression sourceParameter, ICollection1 lambdaParameters, Type type, IFormatProvider formatProvider) at Linq2Rest.Parser.FilterExpressionFactory.GetTokenExpression[T](ParameterExpression parameter, ICollection
1 lambdaParameters, Type type, IFormatProvider formatProvider, ICollection1 tokens) at Linq2Rest.Parser.FilterExpressionFactory.CreateExpression[T](String filter, ParameterExpression sourceParameter, ICollection
1 lambdaParameters, Type type, IFormatProvider formatProvider)
at Linq2Rest.Parser.FilterExpressionFactory.Create[T](String filter, IFormatProvider formatProvider)
at Linq2Rest.Parser.FilterExpressionFactory.Create[T](String filter)
at Linq2Rest.Parser.ParameterParser1.Parse(NameValueCollection queryParameters) at Linq2Rest.ModelFilterExtensions.Filter[T](IEnumerable
1 source, NameValueCollection query)
at CREngland.CareerTemplate.TemplateHandlebars.Fragment(EncodedTextWriter output, Context context, Arguments arguments) in D:\git\cre_service_career_template\CareerTemplate\TemplateHandlebars.cs:line 654
I think I see why. The library with the eNum definitions is based on .net classic 4.6.2 while the new build is .Net Core 3.1 which prevents GetTypes from working.
So, this fails on GetTypes for any assembly not part of .net Core.
return AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes())
.FirstOrDefault(t => t.FullName == arg);
This project doesn't seem to be maintained anymore but now I get "Contract Assume Failed" on all of my filter operations after upgrading a project to .net core. These filters previously worked with the original linq2rest.
The data set is a class/entity with many other class entities as properties when I try to filter on eNum property values.
A filter might look like
(Application/ApplicationType/Value ne CRM.Templates.Xrm.application+eApplicationType'V_VeteranTuitionWaiver')
If I intentionally cause an error by comparing the eNum value to a string I get the expected response:
The binary operator NotEqual is not defined for the types 'CRM.Templates.Xrm.application+eApplicationType' and 'System.String'.
The issue appears to be in converting the specified comparison value to the eNum type and happens in every case where this is attempted.