Skip to content

Commit

Permalink
Merge pull request #4021 from StephenBonikowsky/stebon/3.1.0/cherrypi…
Browse files Browse the repository at this point in the history
…ckfrommaster

Stebon/3.1.0/cherrypickfrommaster
  • Loading branch information
StephenBonikowsky authored Nov 4, 2019
2 parents d3d3352 + f9ab67a commit 1806261
Show file tree
Hide file tree
Showing 25 changed files with 668 additions and 494 deletions.
2 changes: 2 additions & 0 deletions eng/Versioning.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project>
<PropertyGroup>
<GenerateAssemblyInfo Condition="'$(GenerateAssemblyInfo)'==''">true</GenerateAssemblyInfo>
<Ship_SvcUtilXmlSerPackages Condition="'$(Ship_SvcUtilXmlSerPackages)'==''">false</Ship_SvcUtilXmlSerPackages>
<Ship_WcfPackages Condition="'$(Ship_WcfPackages)'==''">true</Ship_WcfPackages>
</PropertyGroup>

<PropertyGroup Condition="'$(GenerateAssemblyInfo)'=='true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<CLSCompliant>true</CLSCompliant>
<IsImplementationAssembly>true</IsImplementationAssembly>
<IsPackable>true</IsPackable>
<IsShipping>$(Ship_WcfPackages)</IsShipping>
</PropertyGroup>

<!-- [todo:arcade] Added this because our released S.P.SM package includes the "_BlockReflectionAttribute" but it is included not only in the UAP* assembly but also the other shipped assembly, should this only be in the binary built for uap? -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

using System.Diagnostics.Contracts;
using System.Reflection;
using System.Runtime;
using System.ServiceModel.Description;

namespace System.ServiceModel.Channels
{
// MethodCall associates a MethodBase with the arguments to pass to it.
internal class MethodCall
{
private object[] _inArgs;

public MethodCall(object[] args)
{
Contract.Assert(args != null);
Expand All @@ -21,10 +25,44 @@ public MethodCall(MethodBase methodBase, object[] args) : this(args)
{
Contract.Assert(methodBase != null);
MethodBase = methodBase;
CreateInArgs();
}

public MethodBase MethodBase { get; private set; }

public object[] Args { get; private set; }

public object[] InArgs => _inArgs ?? Args;

private void CreateInArgs()
{
var parameters = MethodBase.GetParameters();
int inCount = 0;
foreach(var param in parameters)
{
if (ServiceReflector.FlowsIn(param))
{
inCount++;
}
}

if (inCount == Args.Length) // All parameters are InArgs so do nothing and fallback to returning Args
{
return;
}

_inArgs = new object[inCount];
int inPos = 0;
for(int argPos = 0; argPos < parameters.Length; argPos++)
{
if (ServiceReflector.FlowsIn(parameters[argPos]))
{
_inArgs[inPos] = Args[argPos];
inPos++;
}
}

Fx.Assert((inPos - 1) != (inCount), $"Incorrect number of arguments put into _inArgs array, expected {inCount} and copied {inPos - 1}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ public static Task CreateTask(ServiceChannel channel, MethodCall methodCall, Pro
{
if (operation.TaskTResult == ServiceReflector.VoidType)
{
return TaskCreator.CreateTask(channel, operation, methodCall.Args);
return TaskCreator.CreateTask(channel, operation, methodCall.InArgs);
}
return TaskCreator.CreateGenericTask(channel, operation, methodCall.Args);
return TaskCreator.CreateGenericTask(channel, operation, methodCall.InArgs);
}

private static Task CreateGenericTask(ServiceChannel channel, ProxyOperationRuntime operation, object[] inputParameters)
Expand Down
Loading

0 comments on commit 1806261

Please sign in to comment.