Skip to content

Commit be30f9c

Browse files
taking shape
1 parent a491e3a commit be30f9c

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

src/UiPath.CoreIpc.BackCompat/ServiceClientBuilder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace UiPath.Ipc.BackCompat;
66

7-
8-
97
public abstract class ServiceClientBuilder<TDerived, TInterface>
108
: ServiceClientBuilder<TInterface>
119
where TInterface : class

src/UiPath.CoreIpc/Client/ServiceClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public override async ValueTask CloseConnection()
208208
return (LatestConnection, newlyConnected: true);
209209
}
210210
}
211+
211212
private async Task<Network> Connect(CancellationToken ct)
212213
{
213214
if (ConnectionFactory is not null

src/UiPath.CoreIpc/Extensibility/ClientBase.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public abstract record ClientBase : EndpointConfig
1515

1616
public virtual void Validate() { }
1717

18+
public TProxy GetProxy<TProxy>() where TProxy : class
19+
=> new ServiceClientProper<TClient, TClientState>(_client, typeof(TProxy))
20+
.CreateProxy<TProxy>();
21+
22+
1823
internal void ValidateInternal()
1924
{
2025
var haveDeferredInjectedCallbacks = Callbacks?.Any(x => !x.Service.HasServiceProvider() && x.Service.MaybeGetInstance() is null) ?? false;
@@ -55,9 +60,7 @@ internal override RouterConfig CreateCallbackRouterConfig()
5560

5661
public interface IClient<TState, TSelf>
5762
where TSelf : ClientBase, IClient<TState, TSelf>
58-
where TState : class, IClientState<TSelf, TState>, new()
59-
{
60-
}
63+
where TState : class, IClientState<TSelf, TState>, new() { }
6164

6265
public static class ClientExtensions
6366
{

src/UiPath.CoreIpc/IpcJsonSerializer.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Microsoft.Extensions.Logging.Abstractions;
2-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
32
using System.Buffers;
43
using System.Globalization;
54
using System.Text;
@@ -22,30 +21,39 @@ internal class IpcJsonSerializer : ISerializer, IArrayPool<char>
2221
#if !NET461
2322
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
2423
#endif
25-
public async ValueTask<T> DeserializeAsync<T>(Stream json)
24+
public async ValueTask<T?> DeserializeAsync<T>(Stream json)
2625
{
2726
using var stream = IOHelpers.GetStream((int)json.Length);
2827
await json.CopyToAsync(stream);
2928
stream.Position = 0;
3029
using var reader = CreateReader(new StreamReader(stream));
3130
return StringArgsSerializer.Deserialize<T>(reader);
3231
}
33-
public void Serialize(object obj, Stream stream) => Serialize(obj, new StreamWriter(stream), StringArgsSerializer);
32+
public void Serialize(object? obj, Stream stream) => Serialize(obj, new StreamWriter(stream), StringArgsSerializer);
3433
private void Serialize(object obj, TextWriter streamWriter, JsonSerializer serializer)
3534
{
3635
using var writer = new JsonTextWriter(streamWriter) { ArrayPool = this, CloseOutput = false };
3736
serializer.Serialize(writer, obj);
3837
writer.Flush();
3938
}
4039
public char[] Rent(int minimumLength) => ArrayPool<char>.Shared.Rent(minimumLength);
41-
public void Return(char[] array) => ArrayPool<char>.Shared.Return(array);
42-
public string Serialize(object obj)
40+
public void Return(char[]? array)
41+
{
42+
if (array is null)
43+
{
44+
return;
45+
}
46+
47+
ArrayPool<char>.Shared.Return(array);
48+
}
49+
50+
public string Serialize(object? obj)
4351
{
4452
var stringWriter = new StringWriter(new StringBuilder(capacity: 256), CultureInfo.InvariantCulture);
4553
Serialize(obj, stringWriter, StringArgsSerializer);
4654
return stringWriter.ToString();
4755
}
48-
public object Deserialize(string json, Type type)
56+
public object? Deserialize(string json, Type type)
4957
{
5058
using var reader = CreateReader(new StringReader(json));
5159
return StringArgsSerializer.Deserialize(reader, type);

0 commit comments

Comments
 (0)