You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/12/25 15:30:09 UTC

[GitHub] [ignite] ptupitsyn commented on a change in pull request #8602: IGNITE-13734 .Net: Register service return type on method invocation

ptupitsyn commented on a change in pull request #8602:
URL: https://github.com/apache/ignite/pull/8602#discussion_r548884247



##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
##########
@@ -162,7 +168,34 @@ public BinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string,
         /// <returns>Type or null.</returns>
         public string GetTypeName(int id)
         {
-            return DoOutInOp((int) Op.GetType, w => w.WriteInt(id), r => Marshaller.StartUnmarshal(r).ReadString());
+            try
+            {
+                return DoOutInOp((int) Op.GetType, w =>

Review comment:
       Let's extract a method `string GetTypeName(int id, bool java)`.

##########
File path: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
##########
@@ -18,6 +18,7 @@
 namespace Apache.Ignite.Core.Tests.Services
 {
     using System;
+    using System.CodeDom;

Review comment:
       Unused import

##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
##########
@@ -162,7 +168,34 @@ public BinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string,
         /// <returns>Type or null.</returns>
         public string GetTypeName(int id)
         {
-            return DoOutInOp((int) Op.GetType, w => w.WriteInt(id), r => Marshaller.StartUnmarshal(r).ReadString());
+            try
+            {
+                return DoOutInOp((int) Op.GetType, w =>
+                {
+                    w.WriteInt(id);
+                    w.WriteByte(DotNetPlatformId);
+                }, r => Marshaller.StartUnmarshal(r).ReadString());
+            }
+            catch (BinaryObjectException)
+            {
+                if (!Marshaller.RegisterSameJavaType.Value)
+                    throw;
+            }
+
+            // Try to get java type name and register corresponding DotNet type.
+            var javaTypeName = DoOutInOp((int) Op.GetType, w =>
+            {
+                w.WriteInt(id);
+                w.WriteByte(JavaPlatformId);
+            }, r => Marshaller.StartUnmarshal(r).ReadString());
+
+            RegisterType(id, Marshaller.GetTypeName(javaTypeName), false);
+
+            return DoOutInOp((int) Op.GetType, w =>

Review comment:
       I think we can return the name of the registered type from above, no need to call into Java again.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org