Skip to content

Commit b5ce48c

Browse files
fix: no beforecall for incomming callbacks
- write test - tweak debug names
1 parent e93e8ed commit b5ce48c

File tree

14 files changed

+50
-13
lines changed

14 files changed

+50
-13
lines changed

src/UiPath.CoreIpc/Client/ServiceClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private async Task<Network> Connect(CancellationToken ct)
277277
protected override ConnectionFactory? ConnectionFactory => _client.ConnectionFactory;
278278
protected override BeforeCallHandler? BeforeCall => _client.BeforeCall;
279279
protected override ILogger? Log => _client.Logger;
280-
protected override string DebugName => "Some ServiceClient"; // TODO: get the DebugName from the client
280+
protected override string DebugName => _client.ToString();
281281
protected override ISerializer? Serializer => _client.Serializer;
282282
}
283283

@@ -301,7 +301,7 @@ public ServiceClientForCallback(Connection connection, Listener listener, Type i
301301
protected override ConnectionFactory? ConnectionFactory => null;
302302
protected override BeforeCallHandler? BeforeCall => null;
303303
protected override ILogger? Log => null;
304-
protected override string DebugName => "Some Callback ServiceClient"; // TODO: get the DebugName from the listener or somewhere else
304+
protected override string DebugName => $"ReverseClient for {_listener}";
305305
protected override ISerializer? Serializer => null;
306306
}
307307

src/UiPath.CoreIpc/Extensibility/ClientBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal override RouterConfig CreateCallbackRouterConfig()
5050
Callbacks.OrDefault(),
5151
endpoint => endpoint with
5252
{
53-
BeforeCall = endpoint.BeforeCall ?? BeforeCall,
53+
BeforeCall = null, // callbacks don't support BeforeCall
5454
Scheduler = endpoint.Scheduler ?? Scheduler
5555
});
5656
}

src/UiPath.CoreIpc/Helpers/Router.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public static RouterConfig From(EndpointCollection endpoints, Func<EndpointSetti
88

99
foreach (var endpoint in endpoints)
1010
{
11-
var newValue = transform(endpoint);
11+
var newEndpoint = transform(endpoint);
1212
foreach (var iface in endpoint.Service.Type.GetInterfaces().Prepend(endpoint.Service.Type))
1313
{
14-
nameToEndpoint[iface.Name] = newValue;
14+
nameToEndpoint[iface.Name] = newEndpoint;
1515
}
1616
}
1717

@@ -32,7 +32,7 @@ public Router(RouterConfig config, IServiceProvider? serviceProvider)
3232

3333
public bool TryResolve(string endpoint, out Route route)
3434
{
35-
if (_config is not { } config) /// in case <see cref="Router"/> was allocated as default, bypassing the constructor
35+
if (_config is not { } config) /// in case <see cref="Router"/> was allocated as <c>default(Router)</c>, bypassing the constructor
3636
{
3737
throw new InvalidOperationException();
3838
}

src/UiPath.CoreIpc/Server/EndpointSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public record EndpointSettings
1111
public IServiceProvider? ServiceProvider => Service.MaybeGetServiceProvider();
1212
internal ServiceFactory Service { get; }
1313

14-
public EndpointSettings(Type contractType, object? serviceInstance) : this(
14+
public EndpointSettings(Type contractType, object? serviceInstance = null) : this(
1515
serviceInstance is not null
1616
? new ServiceFactory.Instance()
1717
{

src/UiPath.CoreIpc/Server/Listener.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,6 @@ private async Task AcceptConnection(CancellationToken ct)
178178
}
179179
}
180180
}
181+
182+
public override string ToString() => Config.ToString();
181183
}

src/UiPath.CoreIpc/Server/ServerConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public async Task Listen(Stream network, CancellationToken cancellationToken)
8181
{
8282
var stream = await AuthenticateAsServer(); // TODO: should we decommission this?
8383
var serializer = Listener.Server.ServiceProvider.GetService<ISerializer>();
84-
Connection = new Connection(stream, serializer, Listener.Logger, Listener.Config.DebugName, Listener.Config.MaxMessageSize);
84+
Connection = new Connection(stream, serializer, Listener.Logger, debugName: Listener.ToString(), maxMessageSize: Listener.Config.MaxMessageSize);
8585
Server = new Server(
8686
new Router(
8787
Listener.Config.CreateRouterConfig(Listener.Server),

src/UiPath.CoreIpc/Transport/NamedPipe/NamedPipeClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public sealed record NamedPipeClient : ClientBase, IClient<NamedPipeClientState,
88
public required string PipeName { get; init; }
99
public string ServerName { get; init; } = ".";
1010
public bool AllowImpersonation { get; init; } = false;
11+
12+
public override string ToString() => $"ClientPipe={PipeName}";
1113
}
1214

1315
internal sealed class NamedPipeClientState : IClientState<NamedPipeClient, NamedPipeClientState>

src/UiPath.CoreIpc/Transport/NamedPipe/NamedPipeListener.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ IEnumerable<string> INamedPipeListenerConfig.Validate()
5353
{
5454
if (PipeName is null or "") { yield return "PipeName is required"; }
5555
}
56+
57+
public override string ToString() => $"ServerPipe={PipeName}";
5658
}
5759

5860
internal sealed class NamedPipeServerConnectionState

src/UiPath.CoreIpc/Transport/Tcp/TcpClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ namespace UiPath.Ipc.Transport.Tcp;
55
public sealed record TcpClient : ClientBase, IClient<TcpClientState, TcpClient>
66
{
77
public required IPEndPoint EndPoint { get; init; }
8+
9+
public override string ToString() => $"TcpClient={EndPoint}";
810
}
911

1012
internal sealed class TcpClientState : IClientState<TcpClient, TcpClientState>

src/UiPath.CoreIpc/Transport/Tcp/TcpListener.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ IEnumerable<string> ITcpListenerConfig.Validate()
3939
yield return "EndPoint is required";
4040
}
4141
}
42+
43+
public override string ToString() => $"TcpServer={EndPoint}";
4244
}
4345

4446
internal sealed class TcpListenerState : IAsyncDisposable

0 commit comments

Comments
 (0)