From c56a71a8822822bd61c3fa9badf193345896631b Mon Sep 17 00:00:00 2001 From: John Weber Date: Wed, 7 Jan 2015 10:04:37 -0800 Subject: [PATCH 1/2] Fixes issue #12 Checking for null response before attempting to determine type of response --- .../ProxyTests.cs | 34 +++++++++++++++++++ .../RetryingWcfActionInvoker.cs | 4 +-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/source/WcfClientProxyGenerator.Tests/ProxyTests.cs b/source/WcfClientProxyGenerator.Tests/ProxyTests.cs index eaea219..d09ff98 100644 --- a/source/WcfClientProxyGenerator.Tests/ProxyTests.cs +++ b/source/WcfClientProxyGenerator.Tests/ProxyTests.cs @@ -88,6 +88,40 @@ public void Proxy_CanCallVoidMethod() Assert.Fail("Timeout occurred when waiting for callback"); } + [Test, Description("github issue #12")] + public void Proxy_CanCallServiceMethod_ThatReturnsNull() + { + var mockService = new Mock(); + mockService + .Setup(m => m.TestMethod(It.IsAny())) + .Returns(() => null); + + var serviceHost = InProcTestFactory.CreateHost(new TestServiceImpl(mockService)); + + var proxy = WcfClientProxy.Create(c => c.SetEndpoint(serviceHost.Binding, serviceHost.EndpointAddress)); + + string response = proxy.TestMethod("input"); + + Assert.That(response, Is.Null); + } + + [Test, Description("github issue #12")] + public async Task AsyncProxy_CanCallServiceMethod_ThatReturnsNull() + { + var mockService = new Mock(); + mockService + .Setup(m => m.TestMethod(It.IsAny())) + .Returns(() => null); + + var serviceHost = InProcTestFactory.CreateHost(new TestServiceImpl(mockService)); + + var proxy = WcfClientProxy.CreateAsyncProxy(c => c.SetEndpoint(serviceHost.Binding, serviceHost.EndpointAddress)); + + string response = await proxy.CallAsync(m => m.TestMethod("input")); + + Assert.That(response, Is.Null); + } + [Test] public void MultipleProxies_ReturnExpectedValues_WhenCallingServices() { diff --git a/source/WcfClientProxyGenerator/RetryingWcfActionInvoker.cs b/source/WcfClientProxyGenerator/RetryingWcfActionInvoker.cs index e6e592a..ac71de7 100644 --- a/source/WcfClientProxyGenerator/RetryingWcfActionInvoker.cs +++ b/source/WcfClientProxyGenerator/RetryingWcfActionInvoker.cs @@ -358,7 +358,7 @@ private void HandleOnBeforeInvoke(int retryCounter, InvokeInfo invokeInfo) private void HandleOnAfterInvoke(int retryCounter, object response, InvokeInfo invokeInfo) { // set return value if non-void - if (invokeInfo != null && response.GetType() != typeof(VoidReturnType)) + if (invokeInfo != null && response != null && response.GetType() != typeof(VoidReturnType)) { invokeInfo.MethodHasReturnValue = true; invokeInfo.ReturnValue = response; @@ -374,7 +374,7 @@ private void HandleOnAfterInvoke(int retryCounter, object response, InvokeInfo i private void HandleOnCallSuccess(TimeSpan callDuration, object response, int requestAttempts, InvokeInfo invokeInfo) { - if (invokeInfo != null && response.GetType() != typeof (VoidReturnType)) + if (invokeInfo != null && response != null && response.GetType() != typeof (VoidReturnType)) { invokeInfo.MethodHasReturnValue = true; invokeInfo.ReturnValue = response; From a8a129d01839d26fbd39f844f27d1c5c3cf9cf3c Mon Sep 17 00:00:00 2001 From: John Weber Date: Wed, 7 Jan 2015 10:04:58 -0800 Subject: [PATCH 2/2] Incrementing version --- .semver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semver b/.semver index 4b3e029..c8cec4b 100644 --- a/.semver +++ b/.semver @@ -1,5 +1,5 @@ --- :major: 2 :minor: 1 -:patch: 0 +:patch: 1 :special: ''