diff --git a/src/CI/azp-initialization.yaml b/src/CI/azp-initialization.yaml index 9d38650a..2fd099a2 100644 --- a/src/CI/azp-initialization.yaml +++ b/src/CI/azp-initialization.yaml @@ -28,11 +28,11 @@ steps: env: DotNet_MainProjectPath: $(DotNet_MainProjectPath) - # If $(PublishRelease) != "true" then compute $(FullVersion) as $(Version)-20210811-12-fix + # If $(PublishRelease) != "true" then compute $(FullVersion) as $(Version)-$(Build.BuildNumber) - task: VariableTransformTask@1 displayName: '$(Label_Initialization) Compute $[FullVersion] when $[PublishRelease] is not true' inputs: - value: '$(Version)-20210811-12-fix' + value: '$(Version)-$(Build.BuildNumber)' variableName: 'FullVersion' IsSecret: false transformAction: 'none' diff --git a/src/IpcSample.ConsoleClient/Client.cs b/src/IpcSample.ConsoleClient/Client.cs index 36515be2..6cdacf6d 100644 --- a/src/IpcSample.ConsoleClient/Client.cs +++ b/src/IpcSample.ConsoleClient/Client.cs @@ -32,7 +32,7 @@ private static async Task RunTestsAsync(CancellationToken cancellationToken) var serviceProvider = ConfigureServices(); var callback = new ComputingCallback { Id = "custom made" }; var computingClientBuilder = new NamedPipeClientBuilder("test", serviceProvider) - .SerializeParametersAsObjects().CallbackInstance(callback).AllowImpersonation().RequestTimeout(TimeSpan.FromSeconds(2)); + .CallbackInstance(callback).AllowImpersonation().RequestTimeout(TimeSpan.FromSeconds(2)); var stopwatch = Stopwatch.StartNew(); int count = 0; try @@ -40,7 +40,6 @@ private static async Task RunTestsAsync(CancellationToken cancellationToken) var computingClient = computingClientBuilder.ValidateAndBuild(); var systemClient = new NamedPipeClientBuilder("test") - .SerializeParametersAsObjects() .RequestTimeout(TimeSpan.FromSeconds(2)) .Logger(serviceProvider) .AllowImpersonation() diff --git a/src/IpcSample.ConsoleClient/TcpClient.cs b/src/IpcSample.ConsoleClient/TcpClient.cs index 0768ebc6..3a82b449 100644 --- a/src/IpcSample.ConsoleClient/TcpClient.cs +++ b/src/IpcSample.ConsoleClient/TcpClient.cs @@ -35,7 +35,7 @@ private static async Task RunTestsAsync(CancellationToken cancellationToken) var serviceProvider = ConfigureServices(); var callback = new ComputingCallback { Id = "custom made" }; var computingClientBuilder = new TcpClientBuilder(SystemEndPoint, serviceProvider) - .SerializeParametersAsObjects().CallbackInstance(callback)/*.EncryptAndSign("localhost")*/.RequestTimeout(TimeSpan.FromSeconds(2)); + .CallbackInstance(callback)/*.EncryptAndSign("localhost")*/.RequestTimeout(TimeSpan.FromSeconds(2)); var stopwatch = Stopwatch.StartNew(); int count = 0; try @@ -43,7 +43,6 @@ private static async Task RunTestsAsync(CancellationToken cancellationToken) var computingClient = computingClientBuilder.ValidateAndBuild(); var systemClient = new TcpClientBuilder(SystemEndPoint) - .SerializeParametersAsObjects() //.EncryptAndSign("localhost") .RequestTimeout(TimeSpan.FromSeconds(2)) .Logger(serviceProvider) diff --git a/src/IpcSample.ConsoleClient/WebSocketClient.cs b/src/IpcSample.ConsoleClient/WebSocketClient.cs index e6c93422..34d77ad1 100644 --- a/src/IpcSample.ConsoleClient/WebSocketClient.cs +++ b/src/IpcSample.ConsoleClient/WebSocketClient.cs @@ -32,7 +32,7 @@ private static async Task RunTestsAsync(CancellationToken cancellationToken) Uri uri = new("ws://localhost:1212/wsDemo/"); var serviceProvider = ConfigureServices(); var callback = new ComputingCallback { Id = "custom made" }; - var computingClientBuilder = new WebSocketClientBuilder(uri, serviceProvider).SerializeParametersAsObjects() + var computingClientBuilder = new WebSocketClientBuilder(uri, serviceProvider) .CallbackInstance(callback)/*.EncryptAndSign("localhost")*/.RequestTimeout(TimeSpan.FromSeconds(2)); var stopwatch = Stopwatch.StartNew(); int count = 0; @@ -40,7 +40,7 @@ private static async Task RunTestsAsync(CancellationToken cancellationToken) { var computingClient = computingClientBuilder.ValidateAndBuild(); var systemClient = - new WebSocketClientBuilder(uri).SerializeParametersAsObjects() + new WebSocketClientBuilder(uri) //.EncryptAndSign("localhost") .RequestTimeout(TimeSpan.FromSeconds(2)) .Logger(serviceProvider) diff --git a/src/UiPath.CoreIpc.Tests/ComputingTests.cs b/src/UiPath.CoreIpc.Tests/ComputingTests.cs index 6c562dd9..5ab5ccbf 100644 --- a/src/UiPath.CoreIpc.Tests/ComputingTests.cs +++ b/src/UiPath.CoreIpc.Tests/ComputingTests.cs @@ -14,7 +14,7 @@ public ComputingTests() .AddEndpoint() .ValidateAndBuild(); _computingHost.RunAsync(GuiScheduler); - _computingClient = ComputingClientBuilder(GuiScheduler).SerializeParametersAsObjects().ValidateAndBuild(); + _computingClient = ComputingClientBuilder(GuiScheduler).ValidateAndBuild(); } protected abstract TBuilder ComputingClientBuilder(TaskScheduler taskScheduler = null); [Fact] @@ -58,7 +58,7 @@ public async Task ClientCancellation() [Fact] public async Task ClientTimeout() { - var proxy = ComputingClientBuilder().SerializeParametersAsObjects().RequestTimeout(TimeSpan.FromMilliseconds(10)).ValidateAndBuild(); + var proxy = ComputingClientBuilder().RequestTimeout(TimeSpan.FromMilliseconds(10)).ValidateAndBuild(); proxy.Infinite().ShouldThrow().Message.ShouldBe($"{nameof(_computingClient.Infinite)} timed out."); await proxy.GetCallbackThreadName(new Message { RequestTimeout = RequestTimeout }); ((IDisposable)proxy).Dispose(); diff --git a/src/UiPath.CoreIpc.Tests/EndpointTests.cs b/src/UiPath.CoreIpc.Tests/EndpointTests.cs index e62db908..01b47e47 100644 --- a/src/UiPath.CoreIpc.Tests/EndpointTests.cs +++ b/src/UiPath.CoreIpc.Tests/EndpointTests.cs @@ -34,13 +34,11 @@ private NamedPipeClientBuilder ComputingC .AllowImpersonation() .RequestTimeout(RequestTimeout) .CallbackInstance(_computingCallback) - .SerializeParametersAsObjects() .TaskScheduler(taskScheduler); private ISystemService CreateSystemService() => SystemClientBuilder().ValidateAndBuild(); private NamedPipeClientBuilder SystemClientBuilder() => new NamedPipeClientBuilder(PipeName, _serviceProvider) .CallbackInstance(_systemCallback) - .SerializeParametersAsObjects() .RequestTimeout(RequestTimeout) .AllowImpersonation(); public void Dispose() @@ -66,7 +64,7 @@ public async Task Callback() private async Task CallbackCore() { var proxy = new NamedPipeClientBuilder(PipeName) - .SerializeParametersAsObjects().RequestTimeout(RequestTimeout).AllowImpersonation().ValidateAndBuild(); + .RequestTimeout(RequestTimeout).AllowImpersonation().ValidateAndBuild(); var message = new SystemMessage { Text = Guid.NewGuid().ToString() }; var computingTask = _computingClient.SendMessage(message); var systemTask = _systemClient.SendMessage(message); diff --git a/src/UiPath.CoreIpc.Tests/NamedPipeTests.cs b/src/UiPath.CoreIpc.Tests/NamedPipeTests.cs index 9a7b80de..ab68028a 100644 --- a/src/UiPath.CoreIpc.Tests/NamedPipeTests.cs +++ b/src/UiPath.CoreIpc.Tests/NamedPipeTests.cs @@ -47,11 +47,16 @@ public async Task PipeSecurityForWindows() [InlineData(10, 10, 10, 10)] public async Task PipeCancelIoOnServer_AnyNoOfTimes(params int[] msDelays) { + bool cancelIoResult = false; + // Any number of kernel32.CancelIoEx calls should not cause the client to give up on the connection. - (await _systemClient.CancelIoPipe(new() { MsDelays = msDelays })).ShouldBeTrue(); + var act = async () => cancelIoResult = await _systemClient.CancelIoPipe(new() { MsDelays = msDelays }); + await act.ShouldNotThrowAsync(); //Make sure the connection is still working (await _systemClient.Delay()).ShouldBeTrue(); + + cancelIoResult.ShouldBeTrue(); } [Fact] diff --git a/src/UiPath.CoreIpc.Tests/SystemTests.cs b/src/UiPath.CoreIpc.Tests/SystemTests.cs index cf9a97e1..8609f826 100644 --- a/src/UiPath.CoreIpc.Tests/SystemTests.cs +++ b/src/UiPath.CoreIpc.Tests/SystemTests.cs @@ -194,7 +194,7 @@ public async Task DownloadNoRead() await Guid(); } protected abstract TBuilder CreateSystemClientBuilder(); - protected TBuilder SystemClientBuilder() => CreateSystemClientBuilder().SerializeParametersAsObjects().RequestTimeout(RequestTimeout).Logger(_serviceProvider); + protected TBuilder SystemClientBuilder() => CreateSystemClientBuilder().RequestTimeout(RequestTimeout).Logger(_serviceProvider); [Fact] public async Task BeforeCall() { diff --git a/src/UiPath.CoreIpc/Client/ServiceClient.cs b/src/UiPath.CoreIpc/Client/ServiceClient.cs index 8ee847f5..064088ec 100644 --- a/src/UiPath.CoreIpc/Client/ServiceClient.cs +++ b/src/UiPath.CoreIpc/Client/ServiceClient.cs @@ -24,9 +24,8 @@ class ServiceClient : IServiceClient, IConnectionKey where TInterfac private Server _server; private ClientConnection _clientConnection; - internal ServiceClient(ISerializer serializer, TimeSpan requestTimeout, ILogger logger, ConnectionFactory connectionFactory, string sslServer = null, BeforeCallHandler beforeCall = null, bool objectParameters = false, EndpointSettings serviceEndpoint = null) + internal ServiceClient(ISerializer serializer, TimeSpan requestTimeout, ILogger logger, ConnectionFactory connectionFactory, string sslServer = null, BeforeCallHandler beforeCall = null, EndpointSettings serviceEndpoint = null) { - ObjectParameters = objectParameters; _serializer = serializer; _requestTimeout = requestTimeout; _logger = logger; @@ -40,7 +39,6 @@ internal ServiceClient(ISerializer serializer, TimeSpan requestTimeout, ILogger public virtual string Name => _connection?.Name; private bool LogEnabled => _logger.Enabled(); Connection IServiceClient.Connection => _connection; - public bool ObjectParameters { get; init; } public TInterface CreateProxy() { @@ -48,7 +46,7 @@ public TInterface CreateProxy() (proxy as IpcProxy).ServiceClient = this; return proxy; } - + public override int GetHashCode() => HashCode; private void OnNewConnection(Connection connection, bool alreadyHasServer = false) @@ -98,7 +96,7 @@ async Task Invoke() await _beforeCall(new(newConnection, method, args), token); } var requestId = _connection.NewRequestId(); - var request = new Request(typeof(TInterface).Name, requestId, methodName, serializedArguments, ObjectParameters ? args : null, messageTimeout.TotalSeconds) + var request = new Request(typeof(TInterface).Name, requestId, methodName, serializedArguments, messageTimeout.TotalSeconds) { UploadStream = uploadStream }; @@ -106,17 +104,12 @@ async Task Invoke() { Log($"IpcClient calling {methodName} {requestId} {Name}."); } - if (ObjectParameters && !method.ReturnType.IsGenericType) - { - await _connection.Send(request, token); - return default; - } var response = await _connection.RemoteCall(request, token); if (LogEnabled) { Log($"IpcClient called {methodName} {requestId} {Name}."); } - return response.Deserialize(_serializer, ObjectParameters); + return response.Deserialize(_serializer); } catch (Exception ex) { @@ -129,10 +122,8 @@ async Task Invoke() } void SerializeArguments() { - if (!ObjectParameters) - { - serializedArguments = new string[args.Length]; - } + serializedArguments = new string[args.Length]; + for (int index = 0; index < args.Length; index++) { switch (args[index]) @@ -150,10 +141,8 @@ void SerializeArguments() args[index] = ""; break; } - if (!ObjectParameters) - { - serializedArguments[index] = _serializer.Serialize(args[index]); - } + + serializedArguments[index] = _serializer.Serialize(args[index]); } } } diff --git a/src/UiPath.CoreIpc/Client/ServiceClientBuilder.cs b/src/UiPath.CoreIpc/Client/ServiceClientBuilder.cs index db59c9f7..d25fab17 100644 --- a/src/UiPath.CoreIpc/Client/ServiceClientBuilder.cs +++ b/src/UiPath.CoreIpc/Client/ServiceClientBuilder.cs @@ -14,7 +14,6 @@ public abstract class ServiceClientBuilder where TInterfac protected object _callbackInstance; protected TaskScheduler _taskScheduler; protected string _sslServer; - protected bool _objectParameters; protected ServiceClientBuilder(Type callbackContract, IServiceProvider serviceProvider) { @@ -53,18 +52,6 @@ public TDerived Logger(ILogger logger) _logger = logger; return (TDerived)this; } - /// - /// By default, method parameters are serialized as json strings. Setting this allows serialization as json objects. - /// This should improve performance for large strings, but decrease it for many small objects. - /// Setting it breaks compatibility with older servers. - /// So a proxy with this setting will only be able to connect to servers that understand the new encoding. - /// - /// this - public TDerived SerializeParametersAsObjects() - { - _objectParameters = true; - return (TDerived)this; - } public TDerived Logger(IServiceProvider serviceProvider) => Logger(serviceProvider.GetRequiredService>()); diff --git a/src/UiPath.CoreIpc/Connection.cs b/src/UiPath.CoreIpc/Connection.cs index 2e2ac328..97849e57 100644 --- a/src/UiPath.CoreIpc/Connection.cs +++ b/src/UiPath.CoreIpc/Connection.cs @@ -80,7 +80,6 @@ internal async ValueTask RemoteCall(Request request, CancellationToken } internal ValueTask Send(Request request, CancellationToken token) { - Debug.Assert(request.Parameters == null || request.ObjectParameters == null); var uploadStream = request.UploadStream; var requestBytes = SerializeToStream(request); return uploadStream == null ? @@ -100,7 +99,6 @@ Task CancelServerCall(string requestId) => } internal ValueTask Send(Response response, CancellationToken cancellationToken) { - Debug.Assert(response.Data == null || response.ObjectData == null); var responseBytes = SerializeToStream(response); return response.DownloadStream == null ? SendMessage(MessageType.Response, responseBytes, cancellationToken) : diff --git a/src/UiPath.CoreIpc/Dtos.cs b/src/UiPath.CoreIpc/Dtos.cs index c3236c74..76eb38aa 100644 --- a/src/UiPath.CoreIpc/Dtos.cs +++ b/src/UiPath.CoreIpc/Dtos.cs @@ -4,14 +4,13 @@ namespace UiPath.CoreIpc; public class Message { - internal bool ObjectParameters { get; set; } internal Type CallbackContract { get; set; } [JsonIgnore] public IClient Client { get; set; } [JsonIgnore] public TimeSpan RequestTimeout { get; set; } public TCallbackInterface GetCallback() where TCallbackInterface : class => - Client.GetCallback(CallbackContract, ObjectParameters); + Client.GetCallback(CallbackContract); public void ImpersonateClient(Action action) => Client.Impersonate(action); } public class Message : Message @@ -19,28 +18,26 @@ public class Message : Message public Message(TPayload payload) => Payload = payload; public TPayload Payload { get; } } -record Request(string Endpoint, string Id, string MethodName, string[] Parameters, object[] ObjectParameters, double TimeoutInSeconds) +record Request(string Endpoint, string Id, string MethodName, string[] Parameters, double TimeoutInSeconds) { internal Stream UploadStream { get; set; } public override string ToString() => $"{Endpoint} {MethodName} {Id}."; - internal bool HasObjectParameters => ObjectParameters is not null; internal TimeSpan GetTimeout(TimeSpan defaultTimeout) => TimeoutInSeconds == 0 ? defaultTimeout : TimeSpan.FromSeconds(TimeoutInSeconds); } record CancellationRequest(string RequestId); -record Response(string RequestId, string Data = null, object ObjectData = null, Error Error = null) +record Response(string RequestId, string Data = null, Error Error = null) { internal Stream DownloadStream { get; set; } public static Response Fail(Request request, Exception ex) => new(request.Id, Error: ex.ToError()); public static Response Success(Request request, string data) => new(request.Id, data); public static Response Success(Request request, Stream downloadStream) => new(request.Id) { DownloadStream = downloadStream }; - public TResult Deserialize(ISerializer serializer, bool objectParameters) + public TResult Deserialize(ISerializer serializer) { if (Error != null) { throw new RemoteException(Error); } - return (TResult)(DownloadStream ?? (objectParameters ? - serializer.Deserialize(ObjectData, typeof(TResult)) : serializer.Deserialize(Data ?? "", typeof(TResult)))); + return (TResult)(DownloadStream ?? serializer.Deserialize(Data ?? "", typeof(TResult))); } } [Serializable] diff --git a/src/UiPath.CoreIpc/IpcJsonSerializer.cs b/src/UiPath.CoreIpc/IpcJsonSerializer.cs index 33a9faf5..2883fd81 100644 --- a/src/UiPath.CoreIpc/IpcJsonSerializer.cs +++ b/src/UiPath.CoreIpc/IpcJsonSerializer.cs @@ -8,15 +8,12 @@ namespace UiPath.CoreIpc; public interface ISerializer { ValueTask DeserializeAsync(Stream json); - object Deserialize(object json, Type type); void Serialize(object obj, Stream stream); string Serialize(object obj); object Deserialize(string json, Type type); } class IpcJsonSerializer : ISerializer, IArrayPool { - static readonly JsonSerializer ObjectArgsSerializer = new(){ DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, NullValueHandling = NullValueHandling.Ignore, - CheckAdditionalContent = true }; static readonly JsonSerializer StringArgsSerializer = new(){ CheckAdditionalContent = true }; #if !NET461 [AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))] @@ -27,15 +24,9 @@ public async ValueTask DeserializeAsync(Stream json) await json.CopyToAsync(stream); stream.Position = 0; using var reader = CreateReader(new StreamReader(stream)); - return ObjectArgsSerializer.Deserialize(reader); + return StringArgsSerializer.Deserialize(reader); } - public object Deserialize(object json, Type type) => json switch - { - JToken token => token.ToObject(type, ObjectArgsSerializer), - { } => type.IsAssignableFrom(json.GetType()) ? json : new JValue(json).ToObject(type), - null => null, - }; - public void Serialize(object obj, Stream stream) => Serialize(obj, new StreamWriter(stream), ObjectArgsSerializer); + public void Serialize(object obj, Stream stream) => Serialize(obj, new StreamWriter(stream), StringArgsSerializer); private void Serialize(object obj, TextWriter streamWriter, JsonSerializer serializer) { using var writer = new JsonTextWriter(streamWriter) { ArrayPool = this, CloseOutput = false }; diff --git a/src/UiPath.CoreIpc/NamedPipe/NamedPipeClient.cs b/src/UiPath.CoreIpc/NamedPipe/NamedPipeClient.cs index 61584f39..ebe014e4 100644 --- a/src/UiPath.CoreIpc/NamedPipe/NamedPipeClient.cs +++ b/src/UiPath.CoreIpc/NamedPipe/NamedPipeClient.cs @@ -15,8 +15,8 @@ interface INamedPipeKey : IConnectionKey class NamedPipeClient : ServiceClient, INamedPipeKey where TInterface : class { - public NamedPipeClient(string serverName, string pipeName, ISerializer serializer, TimeSpan requestTimeout, bool allowImpersonation, ILogger logger, ConnectionFactory connectionFactory, string sslServer, BeforeCallHandler beforeCall, bool objectParameters, EndpointSettings serviceEndpoint) - : base(serializer, requestTimeout, logger, connectionFactory, sslServer, beforeCall, objectParameters, serviceEndpoint) + public NamedPipeClient(string serverName, string pipeName, ISerializer serializer, TimeSpan requestTimeout, bool allowImpersonation, ILogger logger, ConnectionFactory connectionFactory, string sslServer, BeforeCallHandler beforeCall, EndpointSettings serviceEndpoint) + : base(serializer, requestTimeout, logger, connectionFactory, sslServer, beforeCall, serviceEndpoint) { ServerName = serverName; PipeName = pipeName; diff --git a/src/UiPath.CoreIpc/NamedPipe/NamedPipeClientBuilder.cs b/src/UiPath.CoreIpc/NamedPipe/NamedPipeClientBuilder.cs index 5e4b69d4..6285dc22 100644 --- a/src/UiPath.CoreIpc/NamedPipe/NamedPipeClientBuilder.cs +++ b/src/UiPath.CoreIpc/NamedPipe/NamedPipeClientBuilder.cs @@ -27,7 +27,7 @@ public TDerived AllowImpersonation() } protected override TInterface BuildCore(EndpointSettings serviceEndpoint) => - new NamedPipeClient(_serverName, _pipeName, _serializer, _requestTimeout, _allowImpersonation, _logger, _connectionFactory, _sslServer, _beforeCall, _objectParameters, serviceEndpoint).CreateProxy(); + new NamedPipeClient(_serverName, _pipeName, _serializer, _requestTimeout, _allowImpersonation, _logger, _connectionFactory, _sslServer, _beforeCall, serviceEndpoint).CreateProxy(); } public class NamedPipeClientBuilder : NamedPipeClientBuilderBase, TInterface> where TInterface : class diff --git a/src/UiPath.CoreIpc/Server/Server.cs b/src/UiPath.CoreIpc/Server/Server.cs index 5e6d5b4d..1d2e3fde 100644 --- a/src/UiPath.CoreIpc/Server/Server.cs +++ b/src/UiPath.CoreIpc/Server/Server.cs @@ -63,11 +63,6 @@ async ValueTask OnRequestReceived(Request request) return; } var method = GetMethod(endpoint.Contract, request.MethodName); - if (request.HasObjectParameters && !method.ReturnType.IsGenericType) - { - await HandleRequest(method, endpoint, request, default); - return; - } Response response = null; var requestCancellation = Rent(); _requests[request.Id] = requestCancellation; @@ -111,7 +106,6 @@ ValueTask OnError(Request request, Exception ex) #endif async ValueTask HandleRequest(Method method, EndpointSettings endpoint, Request request, CancellationToken cancellationToken) { - var objectParameters = request.HasObjectParameters; var contract = endpoint.Contract; var arguments = GetArguments(); var beforeCall = endpoint.BeforeCall; @@ -152,12 +146,12 @@ async ValueTask InvokeMethod() { return Response.Success(request, downloadStream); } - return objectParameters ? new Response(request.Id, ObjectData: returnValue) : Response.Success(request, Serializer.Serialize(returnValue)); + return Response.Success(request, Serializer.Serialize(returnValue)); } else { (defaultScheduler ? MethodCall() : RunOnScheduler().Unwrap()).LogException(Logger, method.MethodInfo); - return objectParameters ? null : Response.Success(request, ""); + return Response.Success(request, ""); } Task MethodCall() => method.Invoke(service, arguments, cancellationToken); Task RunOnScheduler() => Task.Factory.StartNew(MethodCall, cancellationToken, TaskCreationOptions.DenyChildAttach, scheduler); @@ -166,12 +160,12 @@ object[] GetArguments() { var parameters = method.Parameters; var allParametersLength = parameters.Length; - var requestParametersLength = objectParameters ? request.ObjectParameters.Length : request.Parameters.Length; + var requestParametersLength = request.Parameters.Length; if (requestParametersLength > allParametersLength) { throw new ArgumentException("Too many parameters for " + method.MethodInfo); } - var allArguments = objectParameters && requestParametersLength == allParametersLength ? request.ObjectParameters : new object[allParametersLength]; + var allArguments = new object[allParametersLength]; Deserialize(); SetOptionalArguments(); return allArguments; @@ -191,9 +185,7 @@ void Deserialize() } else { - argument = objectParameters ? - Serializer.Deserialize(request.ObjectParameters[index], parameterType) : - Serializer.Deserialize(request.Parameters[index], parameterType); + argument = Serializer.Deserialize(request.Parameters[index], parameterType); argument = CheckMessage(argument, parameterType); } allArguments[index] = argument; @@ -209,7 +201,6 @@ object CheckMessage(object argument, Type parameterType) { message.CallbackContract = endpoint.CallbackContract; message.Client = _client; - message.ObjectParameters = objectParameters; } return argument; } diff --git a/src/UiPath.CoreIpc/Server/ServerConnection.cs b/src/UiPath.CoreIpc/Server/ServerConnection.cs index 43f11a6a..1631d69f 100644 --- a/src/UiPath.CoreIpc/Server/ServerConnection.cs +++ b/src/UiPath.CoreIpc/Server/ServerConnection.cs @@ -3,7 +3,7 @@ namespace UiPath.CoreIpc; public interface IClient { - TCallbackInterface GetCallback(Type callbackContract, bool objectParameters) where TCallbackInterface : class; + TCallbackInterface GetCallback(Type callbackContract) where TCallbackInterface : class; void Impersonate(Action action); } abstract class ServerConnection : IClient, IDisposable @@ -18,7 +18,7 @@ abstract class ServerConnection : IClient, IDisposable public ListenerSettings Settings => _listener.Settings; public abstract Task AcceptClient(CancellationToken cancellationToken); public virtual void Impersonate(Action action) => action(); - TCallbackInterface IClient.GetCallback(Type callbackContract, bool objectParameters) where TCallbackInterface : class + TCallbackInterface IClient.GetCallback(Type callbackContract) where TCallbackInterface : class { if (callbackContract == null) { @@ -36,10 +36,7 @@ TCallbackInterface CreateCallback(Type callbackContract) _listener.Log($"Create callback {callbackContract} {_listener.Name}"); } _connectionAsTask ??= Task.FromResult(_connection); - var serviceClient = new ServiceClient(_connection.Serializer, Settings.RequestTimeout, Logger, (_, _) => _connectionAsTask) - { - ObjectParameters = objectParameters - }; + var serviceClient = new ServiceClient(_connection.Serializer, Settings.RequestTimeout, Logger, (_, _) => _connectionAsTask); return serviceClient.CreateProxy(); } } diff --git a/src/UiPath.CoreIpc/Tcp/TcpClient.cs b/src/UiPath.CoreIpc/Tcp/TcpClient.cs index 50386575..0aa69171 100644 --- a/src/UiPath.CoreIpc/Tcp/TcpClient.cs +++ b/src/UiPath.CoreIpc/Tcp/TcpClient.cs @@ -11,7 +11,7 @@ interface ITcpKey : IConnectionKey } class TcpClient : ServiceClient, ITcpKey where TInterface : class { - public TcpClient(IPEndPoint endPoint, ISerializer serializer, TimeSpan requestTimeout, ILogger logger, ConnectionFactory connectionFactory, string sslServer, BeforeCallHandler beforeCall, bool objectParameters, EndpointSettings serviceEndpoint) : base(serializer, requestTimeout, logger, connectionFactory, sslServer, beforeCall, objectParameters, serviceEndpoint) + public TcpClient(IPEndPoint endPoint, ISerializer serializer, TimeSpan requestTimeout, ILogger logger, ConnectionFactory connectionFactory, string sslServer, BeforeCallHandler beforeCall, EndpointSettings serviceEndpoint) : base(serializer, requestTimeout, logger, connectionFactory, sslServer, beforeCall, serviceEndpoint) { EndPoint = endPoint; HashCode = (EndPoint, sslServer).GetHashCode(); diff --git a/src/UiPath.CoreIpc/Tcp/TcpClientBuilder.cs b/src/UiPath.CoreIpc/Tcp/TcpClientBuilder.cs index a0a05b71..1672d2d0 100644 --- a/src/UiPath.CoreIpc/Tcp/TcpClientBuilder.cs +++ b/src/UiPath.CoreIpc/Tcp/TcpClientBuilder.cs @@ -10,7 +10,7 @@ protected TcpClientBuilderBase(IPEndPoint endPoint, Type callbackContract = null _endPoint = endPoint; protected override TInterface BuildCore(EndpointSettings serviceEndpoint) => - new TcpClient(_endPoint, _serializer, _requestTimeout, _logger, _connectionFactory, _sslServer, _beforeCall, _objectParameters, serviceEndpoint).CreateProxy(); + new TcpClient(_endPoint, _serializer, _requestTimeout, _logger, _connectionFactory, _sslServer, _beforeCall, serviceEndpoint).CreateProxy(); } public class TcpClientBuilder : TcpClientBuilderBase, TInterface> where TInterface : class diff --git a/src/UiPath.CoreIpc/WebSockets/WebSocketClient.cs b/src/UiPath.CoreIpc/WebSockets/WebSocketClient.cs index f0774988..04665a85 100644 --- a/src/UiPath.CoreIpc/WebSockets/WebSocketClient.cs +++ b/src/UiPath.CoreIpc/WebSockets/WebSocketClient.cs @@ -8,7 +8,7 @@ interface IWebSocketsKey : IConnectionKey } class WebSocketClient : ServiceClient, IWebSocketsKey where TInterface : class { - public WebSocketClient(Uri uri, ISerializer serializer, TimeSpan requestTimeout, ILogger logger, ConnectionFactory connectionFactory, string sslServer, BeforeCallHandler beforeCall, bool objectParameters, EndpointSettings serviceEndpoint) : base(serializer, requestTimeout, logger, connectionFactory, sslServer, beforeCall, objectParameters, serviceEndpoint) + public WebSocketClient(Uri uri, ISerializer serializer, TimeSpan requestTimeout, ILogger logger, ConnectionFactory connectionFactory, string sslServer, BeforeCallHandler beforeCall, EndpointSettings serviceEndpoint) : base(serializer, requestTimeout, logger, connectionFactory, sslServer, beforeCall, serviceEndpoint) { Uri = uri; HashCode = (uri, sslServer).GetHashCode(); diff --git a/src/UiPath.CoreIpc/WebSockets/WebSocketClientBuilder.cs b/src/UiPath.CoreIpc/WebSockets/WebSocketClientBuilder.cs index 893a8b7a..72c38d54 100644 --- a/src/UiPath.CoreIpc/WebSockets/WebSocketClientBuilder.cs +++ b/src/UiPath.CoreIpc/WebSockets/WebSocketClientBuilder.cs @@ -5,7 +5,7 @@ public abstract class WebSocketClientBuilderBase : Service protected WebSocketClientBuilderBase(Uri uri, Type callbackContract = null, IServiceProvider serviceProvider = null) : base(callbackContract, serviceProvider) => _uri = uri; protected override TInterface BuildCore(EndpointSettings serviceEndpoint) => - new WebSocketClient(_uri, _serializer, _requestTimeout, _logger, _connectionFactory, _sslServer, _beforeCall, _objectParameters, serviceEndpoint).CreateProxy(); + new WebSocketClient(_uri, _serializer, _requestTimeout, _logger, _connectionFactory, _sslServer, _beforeCall, serviceEndpoint).CreateProxy(); } public class WebSocketClientBuilder : WebSocketClientBuilderBase, TInterface> where TInterface : class {