From cbe9eacb0df1f1e702e6f27009f956cdcc72ad31 Mon Sep 17 00:00:00 2001 From: Toby Henderson Date: Wed, 16 Dec 2015 16:31:28 +0000 Subject: [PATCH] Added a better message than - The operation is not ready for invocation. - like what and who --- .../OperationModel/MethodBased/MethodBasedOperation.cs | 5 ++++- src/OpenRasta/OperationModel/OperationExtensions.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/OpenRasta/OperationModel/MethodBased/MethodBasedOperation.cs b/src/OpenRasta/OperationModel/MethodBased/MethodBasedOperation.cs index 20355015..8bb383b4 100644 --- a/src/OpenRasta/OperationModel/MethodBased/MethodBasedOperation.cs +++ b/src/OpenRasta/OperationModel/MethodBased/MethodBasedOperation.cs @@ -53,7 +53,10 @@ public IEnumerable FindAttributes() where T : class public IEnumerable Invoke() { if (!Inputs.AllReady()) - throw new InvalidOperationException("The operation is not ready for invocation."); + { + var notReady = Inputs.WhosNotReady(); + throw new InvalidOperationException(string.Format("The operation {0} for {1} is not ready for invocation. These members are not ready; {2}", _method.Name, _method.Owner.Name, notReady.Select(x => x.Name).JoinString(", "))); + } var handler = CreateInstance(_ownerType, Resolver); diff --git a/src/OpenRasta/OperationModel/OperationExtensions.cs b/src/OpenRasta/OperationModel/OperationExtensions.cs index 22ff22f2..5ece7836 100644 --- a/src/OpenRasta/OperationModel/OperationExtensions.cs +++ b/src/OpenRasta/OperationModel/OperationExtensions.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.Linq; +using OpenRasta.TypeSystem; + namespace OpenRasta.OperationModel { public static class OperationExtensions @@ -10,7 +12,12 @@ public static bool AllReady(this IEnumerable members) return members.All(x => x.IsReadyForAssignment); } - /// + public static IEnumerable WhosNotReady(this IEnumerable members) + { + return members.Where(x => x.IsReadyForAssignment == false).Select(x => x.Member); + } + + /// /// Returns the number of members ready for invocation (aka either having a default value or having had a value assigned to them). /// ///