From 7006cd03685f45c5b6d0e32499466b66e1c6c5ab Mon Sep 17 00:00:00 2001 From: Alexander Ulitin Date: Thu, 3 Apr 2025 15:45:51 +0200 Subject: [PATCH] rd-reflection: all null values for all reactive primitives and make calls async --- rd-net/RdFramework.Reflection/BindableChildrenUtil.cs | 8 ++++++++ .../RdFramework.Reflection/ReflectionRdActivator.cs | 11 ----------- rd-net/RdFramework/Base/IRdReactive.cs | 1 + rd-net/RdFramework/Impl/InternRoot.cs | 6 ++++++ rd-net/RdFramework/Tasks/Interfaces.cs | 6 +++++- rd-net/RdFramework/Tasks/RdCall.cs | 2 +- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/rd-net/RdFramework.Reflection/BindableChildrenUtil.cs b/rd-net/RdFramework.Reflection/BindableChildrenUtil.cs index a665b4703..c758e524f 100644 --- a/rd-net/RdFramework.Reflection/BindableChildrenUtil.cs +++ b/rd-net/RdFramework.Reflection/BindableChildrenUtil.cs @@ -4,6 +4,7 @@ using System.Reflection; using JetBrains.Diagnostics; using JetBrains.Rd.Base; +using JetBrains.Rd.Tasks; using JetBrains.Rd.Util; using JetBrains.Util; @@ -85,6 +86,13 @@ internal static void FillBindableFields(IReflectionBindable instance) // value can be null for fields primitive types in RdModels. They are used in serializations, but send their value on bind if (value != null) obj.BindableChildren.Add(new KeyValuePair(bindableMembers[i].Name, value)); + + if (value is IRdReactive reactive) + { + reactive.ValueCanBeNull = true; + if (value is IRdCall) + reactive.Async = true; + } } }; lock (ourFillBindableChildren) diff --git a/rd-net/RdFramework.Reflection/ReflectionRdActivator.cs b/rd-net/RdFramework.Reflection/ReflectionRdActivator.cs index f2d588496..f5cd61256 100644 --- a/rd-net/RdFramework.Reflection/ReflectionRdActivator.cs +++ b/rd-net/RdFramework.Reflection/ReflectionRdActivator.cs @@ -334,20 +334,9 @@ public static void SetHandler(RdCall endpoint, Func throw new NotSupportedException("Intern Roots are always async"); } + public bool ValueCanBeNull + { + get => false; + set => throw new NotSupportedException("Intern Roots are always non-nullable"); + } + public void OnWireReceived(UnsafeReader reader, IRdWireableDispatchHelper dispatchHelper) { if (!TryGetSerializationContext(out var serializationCtx)) diff --git a/rd-net/RdFramework/Tasks/Interfaces.cs b/rd-net/RdFramework/Tasks/Interfaces.cs index b972ee60e..f60f90673 100644 --- a/rd-net/RdFramework/Tasks/Interfaces.cs +++ b/rd-net/RdFramework/Tasks/Interfaces.cs @@ -20,7 +20,11 @@ public interface IRdEndpoint void SetRdTask(Func> handler, IScheduler? cancellationScheduler = null, IScheduler? handlerScheduler = null); } - public interface IRdCall + public interface IRdCall + { + } + + public interface IRdCall : IRdCall { TRes Sync(TReq request, RpcTimeouts? timeouts = null); diff --git a/rd-net/RdFramework/Tasks/RdCall.cs b/rd-net/RdFramework/Tasks/RdCall.cs index 84ad4178a..a7d707187 100644 --- a/rd-net/RdFramework/Tasks/RdCall.cs +++ b/rd-net/RdFramework/Tasks/RdCall.cs @@ -10,7 +10,7 @@ namespace JetBrains.Rd.Tasks { - public class RdCall : RdReactiveBase, IRdCall, IRdEndpoint + public class RdCall : RdReactiveBase, IRdCall, IRdEndpoint, IRdCall { [PublicAPI] public CtxReadDelegate ReadRequestDelegate { get; }