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

Cannot create computed property with bool return type #25

Open
JasonRodman opened this issue Mar 11, 2013 · 1 comment
Open

Cannot create computed property with bool return type #25

JasonRodman opened this issue Mar 11, 2013 · 1 comment

Comments

@JasonRodman
Copy link

For some reason any computed properties that return bool cause the ko.Initialize() method call to fail. For example this fails:

[Computed]
public bool HasExpirationDate { get { return true; } }

This will cause this call to fail:

@ko.Initialize(Model)

With the following error:

No coercion operator is defined between types 'System.Int32' and 'System.Boolean'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: No coercion operator is defined between types 'System.Int32' and 'System.Boolean'.

Source Error:

Line 7: {
Line 8: @Scripts.Render("~/bundles/scripts/datepicker")
Line 9: @ko.Initialize(Model)
Line 10:
Line 11: <script>

Source File: c:\Development\Projects\Base House Contracting\Dev\Website\Views\TradeReview\Index.cshtml Line: 9

Stack Trace:

[InvalidOperationException: No coercion operator is defined between types 'System.Int32' and 'System.Boolean'.]
System.Linq.Expressions.Expression.Convert(Expression expression, Type type, MethodInfo method) +6156301
DelegateDecompiler.MethodBodyDecompiler.Decompile() +297
DelegateDecompiler.Cache2.GetOrAdd(TKey key, Func2 func) +247
DelegateDecompiler.DecompileExtensions.Decompile(MethodInfo method) +127
DelegateDecompiler.DecompileExpressionVisitor.Decompile(MethodInfo method, Expression instance, IList1 arguments) +36 PerpetuumSoft.Knockout.KnockoutJsModelBuilder.AddComputedToModel(Type modelType, Object model, String modelName) +321 PerpetuumSoft.Knockout.KnockoutContext1.GetInitializeData(TModel model, Boolean needBinding) +526
PerpetuumSoft.Knockout.KnockoutContext1.Initialize(TModel model) +14 ASP.<>c__DisplayClass4.<Execute>b__2() in c:\Development\Projects\Base House Contracting\Dev\Website\Views\TradeReview\Index.cshtml:9 System.Web.WebPages.<>c__DisplayClassb.<RenderSection>b__9(TextWriter tw) +289 System.Web.WebPages.WebPageBase.Write(HelperResult result) +89 ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:\Development\Projects\Base House Contracting\Dev\Website\Views\Shared\_Layout.cshtml:74 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196 System.Web.WebPages.WebPageBase.Write(HelperResult result) +89 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) +233
System.Web.WebPages.WebPageBase.PopContext() +291
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
System.Web.Mvc.<>c__DisplayClass1a.b__17() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +613
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +263
System.Web.Mvc.Async.<>c__DisplayClass25.b__22(IAsyncResult asyncResult) +240
System.Web.Mvc.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15
System.Web.Mvc.<>c__DisplayClass8.b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +282

@hazzik
Copy link
Contributor

hazzik commented May 25, 2015

Fixed in DelegateDecompiler 0.8.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants