You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2020/12/25 19:52:31 UTC

[ignite] branch master updated: IGNITE-13734 .NET: Register service return type on method invocation (#8602)

This is an automated email from the ASF dual-hosted git repository.

nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 6d02e32  IGNITE-13734 .NET: Register service return type on method invocation (#8602)
6d02e32 is described below

commit 6d02e32e7f049e4f78f7abd37f4ff91d77f738c2
Author: Nikolay <ni...@apache.org>
AuthorDate: Fri Dec 25 22:52:13 2020 +0300

    IGNITE-13734 .NET: Register service return type on method invocation (#8602)
---
 .../platform/binary/PlatformBinaryProcessor.java   |  3 +-
 .../ignite/platform/PlatformDeployServiceTask.java | 25 +++++++++
 .../platform/{Department.java => model/ACL.java}   | 19 ++-----
 .../platform/{Key.java => model/Account.java}      | 40 ++++++++++----
 .../ignite/platform/{ => model}/Address.java       |  2 +-
 .../ignite/platform/{ => model}/Department.java    |  2 +-
 .../ignite/platform/{ => model}/Employee.java      |  2 +-
 .../apache/ignite/platform/{ => model}/Key.java    |  2 +-
 .../platform/{Department.java => model/Role.java}  | 11 ++--
 .../platform/{Address.java => model/User.java}     | 44 +++++++++++-----
 .../apache/ignite/platform/{ => model}/Value.java  |  2 +-
 .../Services/IJavaService.cs                       |  8 ++-
 .../Services/JavaServiceDynamicProxy.cs            | 12 ++++-
 .../Apache.Ignite.Core.Tests/Services/Model.cs     | 61 +++++++++++++++++++++-
 .../Services/ServiceProxyTest.cs                   | 41 +++++++++------
 .../Services/ServiceTypeAutoResolveTest.cs         | 26 +++++++--
 .../Impl/Binary/BinaryProcessor.cs                 | 39 +++++++++++++-
 .../Impl/Binary/BinaryProcessorClient.cs           | 12 ++---
 .../Apache.Ignite.Core/Impl/Binary/Marshaller.cs   |  2 +-
 .../Impl/Services/ServiceProxySerializer.cs        | 49 +++++++----------
 .../Apache.Ignite.Core/Impl/Services/Services.cs   | 18 +++++--
 21 files changed, 308 insertions(+), 112 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java
index 4c5c122..425c299 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java
@@ -134,10 +134,11 @@ public class PlatformBinaryProcessor extends PlatformAbstractTarget {
 
             case OP_GET_TYPE: {
                 int typeId = reader.readInt();
+                byte platformId = reader.readByte();
 
                 try {
                     String typeName = platformContext().kernalContext().marshallerContext()
-                        .getClassName(MarshallerPlatformIds.DOTNET_ID, typeId);
+                        .getClassName(platformId, typeId);
 
                     writer.writeString(typeName);
                 }
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
index 688b3b1..c604f8e 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
@@ -41,6 +41,15 @@ import org.apache.ignite.compute.ComputeJobResult;
 import org.apache.ignite.compute.ComputeTaskAdapter;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.platform.model.ACL;
+import org.apache.ignite.platform.model.Account;
+import org.apache.ignite.platform.model.Address;
+import org.apache.ignite.platform.model.Department;
+import org.apache.ignite.platform.model.Employee;
+import org.apache.ignite.platform.model.Key;
+import org.apache.ignite.platform.model.Role;
+import org.apache.ignite.platform.model.User;
+import org.apache.ignite.platform.model.Value;
 import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.services.Service;
 import org.apache.ignite.services.ServiceContext;
@@ -504,6 +513,22 @@ public class PlatformDeployServiceTask extends ComputeTaskAdapter<String, Object
         }
 
         /** */
+        public Account[] testAccounts() {
+            return new Account[] {
+                new Account("123", 42),
+                new Account("321", 0)
+            };
+        }
+
+        /** */
+        public User[] testUsers() {
+            return new User[] {
+                new User(1, ACL.ALLOW, new Role("admin")),
+                new User(2, ACL.DENY, new Role("user"))
+            };
+        }
+
+        /** */
         public void testDateArray(Timestamp[] dates) {
             assertNotNull(dates);
             assertEquals(2, dates.length);
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Department.java b/modules/core/src/test/java/org/apache/ignite/platform/model/ACL.java
similarity index 74%
copy from modules/core/src/test/java/org/apache/ignite/platform/Department.java
copy to modules/core/src/test/java/org/apache/ignite/platform/model/ACL.java
index a1aa9b7..6f75846 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Department.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/ACL.java
@@ -15,20 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
-/** Test value object. */
-public class Department {
-    /** */
-    private String name;
-
-    /** */
-    public String getName() {
-        return name;
-    }
-
-    /** */
-    public void setName(String name) {
-        this.name = name;
-    }
+/** Test enum. */
+public enum ACL {
+    ALLOW, DENY
 }
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Key.java b/modules/core/src/test/java/org/apache/ignite/platform/model/Account.java
similarity index 67%
copy from modules/core/src/test/java/org/apache/ignite/platform/Key.java
copy to modules/core/src/test/java/org/apache/ignite/platform/model/Account.java
index 26c5787..d192ce7 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Key.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/Account.java
@@ -15,36 +15,56 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 import java.util.Objects;
 
-/** Test key object. */
-public class Key {
+/** */
+public class Account {
     /** */
-    private long id;
+    private String id;
 
     /** */
-    public Key(long id) {
+    private int amount;
+
+    /** */
+    public Account() {
+    }
+
+    public Account(String id, int amount) {
         this.id = id;
+        this.amount = amount;
     }
 
     /** */
-    public long getId() {
+    public String getId() {
         return id;
     }
 
-    /** {@inheritDoc} */
+    /** */
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /** */
+    public int getAmount() {
+        return amount;
+    }
+
+    /** */
+    public void setAmount(int amount) {
+        this.amount = amount;
+    }
+
     @Override public boolean equals(Object o) {
         if (this == o)
             return true;
         if (o == null || getClass() != o.getClass())
             return false;
-        Key key = (Key)o;
-        return id == key.id;
+        Account account = (Account)o;
+        return Objects.equals(id, account.id);
     }
 
-    /** {@inheritDoc} */
     @Override public int hashCode() {
         return Objects.hash(id);
     }
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Address.java b/modules/core/src/test/java/org/apache/ignite/platform/model/Address.java
similarity index 96%
copy from modules/core/src/test/java/org/apache/ignite/platform/Address.java
copy to modules/core/src/test/java/org/apache/ignite/platform/model/Address.java
index 39390e8..42442cf 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Address.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/Address.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 /** Test value object. */
 public class Address {
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Department.java b/modules/core/src/test/java/org/apache/ignite/platform/model/Department.java
similarity index 96%
copy from modules/core/src/test/java/org/apache/ignite/platform/Department.java
copy to modules/core/src/test/java/org/apache/ignite/platform/model/Department.java
index a1aa9b7..b1f74f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Department.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/Department.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 /** Test value object. */
 public class Department {
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Employee.java b/modules/core/src/test/java/org/apache/ignite/platform/model/Employee.java
similarity index 96%
rename from modules/core/src/test/java/org/apache/ignite/platform/Employee.java
rename to modules/core/src/test/java/org/apache/ignite/platform/model/Employee.java
index 03d99a6..6c63c29 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Employee.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/Employee.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 /** Test value object. */
 public class Employee {
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Key.java b/modules/core/src/test/java/org/apache/ignite/platform/model/Key.java
similarity index 97%
rename from modules/core/src/test/java/org/apache/ignite/platform/Key.java
rename to modules/core/src/test/java/org/apache/ignite/platform/model/Key.java
index 26c5787..218d9c0 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Key.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/Key.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 import java.util.Objects;
 
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Department.java b/modules/core/src/test/java/org/apache/ignite/platform/model/Role.java
similarity index 86%
rename from modules/core/src/test/java/org/apache/ignite/platform/Department.java
rename to modules/core/src/test/java/org/apache/ignite/platform/model/Role.java
index a1aa9b7..f47eddb 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Department.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/Role.java
@@ -15,12 +15,17 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 /** Test value object. */
-public class Department {
+public class Role {
     /** */
-    private String name;
+    String name;
+
+    /** */
+    public Role(String name) {
+        this.name = name;
+    }
 
     /** */
     public String getName() {
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Address.java b/modules/core/src/test/java/org/apache/ignite/platform/model/User.java
similarity index 59%
rename from modules/core/src/test/java/org/apache/ignite/platform/Address.java
rename to modules/core/src/test/java/org/apache/ignite/platform/model/User.java
index 39390e8..88849d1 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Address.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/User.java
@@ -15,33 +15,53 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 /** Test value object. */
-public class Address {
+public class User {
     /** */
-    private String zip;
+    private int id;
 
     /** */
-    private String addr;
+    private ACL acl;
 
     /** */
-    public String getZip() {
-        return zip;
+    private Role role;
+
+    /** */
+    public User(int id, ACL acl, Role role) {
+        this.id = id;
+        this.acl = acl;
+        this.role = role;
+    }
+
+    /** */
+    public int getId() {
+        return id;
+    }
+
+    /** */
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    /** */
+    public ACL getAcl() {
+        return acl;
     }
 
     /** */
-    public void setZip(String zip) {
-        this.zip = zip;
+    public void setAcl(ACL acl) {
+        this.acl = acl;
     }
 
     /** */
-    public String getAddr() {
-        return addr;
+    public Role getRole() {
+        return role;
     }
 
     /** */
-    public void setAddr(String addr) {
-        this.addr = addr;
+    public void setRole(Role role) {
+        this.role = role;
     }
 }
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/Value.java b/modules/core/src/test/java/org/apache/ignite/platform/model/Value.java
similarity index 97%
rename from modules/core/src/test/java/org/apache/ignite/platform/Value.java
rename to modules/core/src/test/java/org/apache/ignite/platform/model/Value.java
index 0950291..7143bff 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/Value.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/model/Value.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.platform;
+package org.apache.ignite.platform.model;
 
 import java.util.Objects;
 
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs
index 07db779b..42b1cfe 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs
@@ -22,7 +22,7 @@ namespace Apache.Ignite.Core.Tests.Services
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
     using Apache.Ignite.Core.Binary;
-    using org.apache.ignite.platform;
+    using org.apache.ignite.platform.model;
 
     /// <summary>
     /// Java service proxy interface.
@@ -170,6 +170,12 @@ namespace Apache.Ignite.Core.Tests.Services
 
         /** */
         Employee[] testEmployees(Employee[] emps);
+        
+        /** */
+        Account[] testAccounts();
+
+        /** */
+        User[] testUsers();
 
         /** */
         ICollection testDepartments(ICollection deps);
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs
index 4156602..723e67c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs
@@ -21,7 +21,7 @@ namespace Apache.Ignite.Core.Tests.Services
     using System.Collections;
     using System.Collections.Generic;
     using Apache.Ignite.Core.Binary;
-    using org.apache.ignite.platform;
+    using org.apache.ignite.platform.model;
 
     /// <summary>
     /// Explicit service proxy over dynamic variable.
@@ -319,6 +319,16 @@ namespace Apache.Ignite.Core.Tests.Services
             return _svc.testEmployees(emps);
         }
 
+        public Account[] testAccounts()
+        {
+            return _svc.testAccounts();
+        }
+
+        public User[] testUsers()
+        {
+            return _svc.testUsers();
+        }
+
         /** <inheritDoc /> */
         public ICollection testDepartments(ICollection deps)
         {
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs
index 0793e87..275dc7d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs
@@ -16,8 +16,10 @@
  */
 
 // ReSharper disable once CheckNamespace
-namespace org.apache.ignite.platform
+namespace org.apache.ignite.platform.model
 {
+    using System;
+
     /// <summary>
     /// A class is a clone of Java class Address with the same namespace.
     /// </summary>
@@ -85,4 +87,61 @@ namespace org.apache.ignite.platform
     {
         public string Val { get; set; }
     }
+
+    /// <summary>
+    /// A class is a clone of Java class Account with the same namespace.
+    /// </summary>
+    public class Account
+    {
+        public String Id { get; set; }
+        
+        public int Amount { get; set; }
+
+        protected bool Equals(Account other)
+        {
+            return Id == other.Id;
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj)) return false;
+            if (ReferenceEquals(this, obj)) return true;
+            if (obj.GetType() != this.GetType()) return false;
+            return Equals((Account) obj);
+        }
+
+        public override int GetHashCode()
+        {
+            // ReSharper disable once NonReadonlyMemberInGetHashCode
+            return Id.GetHashCode();
+        }
+    }
+
+    /// <summary>
+    /// A enum is a clone of Java class User with the same namespace.
+    /// </summary>
+    public enum ACL
+    {
+        Allow, Deny
+    }
+
+    /// <summary>
+    /// A class is a clone of Java class Role with the same namespace.
+    /// </summary>
+    public class Role
+    {
+        public String Name { get; set; }
+    }
+
+    /// <summary>
+    /// A class is a clone of Java class User with the same namespace.
+    /// </summary>
+    public class User
+    {
+        public int Id { get; set; }
+        
+        public ACL Acl { get; set; }
+        
+        public Role Role { get; set; }
+    }    
 }
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
index 53bfbbc..82e0993 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
@@ -283,32 +283,41 @@ namespace Apache.Ignite.Core.Tests.Services
                 // 1) Write to a stream
                 inStream.WriteBool(SrvKeepBinary);  // WriteProxyMethod does not do this, but Java does
 
-                ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method.Name, 
-                    method, args, PlatformType.DotNet);
+                Marshaller.RegisterSameJavaType.Value = true;
 
-                inStream.SynchronizeOutput();
+                try
+                {
+                    ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method.Name,
+                        method, args, PlatformType.DotNet);
 
-                inStream.Seek(0, SeekOrigin.Begin);
+                    inStream.SynchronizeOutput();
 
-                // 2) call InvokeServiceMethod
-                string mthdName;
-                object[] mthdArgs;
+                    inStream.Seek(0, SeekOrigin.Begin);
 
-                ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs);
+                    // 2) call InvokeServiceMethod
+                    string mthdName;
+                    object[] mthdArgs;
 
-                var result = ServiceProxyInvoker.InvokeServiceMethod(_svc, mthdName, mthdArgs);
+                    ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs);
 
-                ServiceProxySerializer.WriteInvocationResult(outStream, _marsh, result.Key, result.Value);
+                    var result = ServiceProxyInvoker.InvokeServiceMethod(_svc, mthdName, mthdArgs);
 
-                var writer = _marsh.StartMarshal(outStream);
-                writer.WriteString("unused");  // fake Java exception details
-                writer.WriteString("unused");  // fake Java exception details
+                    ServiceProxySerializer.WriteInvocationResult(outStream, _marsh, result.Key, result.Value);
 
-                outStream.SynchronizeOutput();
+                    var writer = _marsh.StartMarshal(outStream);
+                    writer.WriteString("unused"); // fake Java exception details
+                    writer.WriteString("unused"); // fake Java exception details
 
-                outStream.Seek(0, SeekOrigin.Begin);
+                    outStream.SynchronizeOutput();
 
-                return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepBinary);
+                    outStream.Seek(0, SeekOrigin.Begin);
+
+                    return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepBinary);
+                }
+                finally 
+                {
+                    Marshaller.RegisterSameJavaType.Value = true;
+                }
             }
         }
 
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceTypeAutoResolveTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceTypeAutoResolveTest.cs
index c99a198..f88cb9e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceTypeAutoResolveTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceTypeAutoResolveTest.cs
@@ -23,7 +23,7 @@ namespace Apache.Ignite.Core.Tests.Services
     using System.IO;
     using System.Linq;
     using NUnit.Framework;
-    using org.apache.ignite.platform;
+    using org.apache.ignite.platform.model;
 
     /// <summary>
     /// Tests checks ability to execute service method without explicit registration of parameter type.
@@ -97,11 +97,11 @@ namespace Apache.Ignite.Core.Tests.Services
         {
             // Deploy Java service
             var javaSvcName = TestUtils.DeployJavaService(_grid1);
-            
+
             var svc = _grid1.GetServices().GetServiceProxy<IJavaService>(javaSvcName, false);
 
             doTestService(svc);
-            
+
             Assert.IsNull(svc.testDepartments(null));
 
             var arr  = new[] {"HR", "IT"}.Select(x => new Department() {Name = x}).ToArray();
@@ -153,6 +153,26 @@ namespace Apache.Ignite.Core.Tests.Services
             Assert.NotNull(res);
             Assert.AreEqual(1, res.Count);
             Assert.AreEqual("value3", ((Value)res[new Key() {Id = 3}]).Val);
+
+            var accs = svc.testAccounts();
+
+            Assert.NotNull(accs);
+            Assert.AreEqual(2, accs.Length);
+            Assert.AreEqual("123", accs[0].Id);
+            Assert.AreEqual("321", accs[1].Id);
+            Assert.AreEqual(42, accs[0].Amount);
+            Assert.AreEqual(0, accs[1].Amount);
+
+            var users = svc.testUsers();
+
+            Assert.NotNull(users);
+            Assert.AreEqual(2, users.Length);
+            Assert.AreEqual(1, users[0].Id);
+            Assert.AreEqual(ACL.Allow, users[0].Acl);
+            Assert.AreEqual("admin", users[0].Role.Name);
+            Assert.AreEqual(2, users[1].Id);
+            Assert.AreEqual(ACL.Deny, users[1].Acl);
+            Assert.AreEqual("user", users[1].Role.Name);
         }
 
         /// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
index 66380d6..05deb5b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
@@ -27,6 +27,12 @@ namespace Apache.Ignite.Core.Impl.Binary
     /// </summary>
     internal class BinaryProcessor : PlatformTargetAdapter, IBinaryProcessor
     {
+        /** Java platform id. See org.apache.ignite.internal.MarshallerPlatformIds in Java. */
+        public const byte JavaPlatformId = 0;
+
+        /** Type registry platform id. See org.apache.ignite.internal.MarshallerPlatformIds in Java. */
+        public const byte DotNetPlatformId = 1;
+
         /// <summary>
         /// Op codes.
         /// </summary>
@@ -162,7 +168,38 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <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 GetTypeName(id, DotNetPlatformId);
+            }
+            catch (BinaryObjectException)
+            {
+                if (!Marshaller.RegisterSameJavaType.Value)
+                    throw;
+            }
+
+            // Try to get java type name and register corresponding DotNet type.
+            var javaTypeName = GetTypeName(id, JavaPlatformId);
+            var netTypeName = Marshaller.GetTypeName(javaTypeName);
+
+            RegisterType(id, netTypeName, false);
+
+            return netTypeName;
+        }
+
+        /// <summary>
+        /// Gets the type name by id for specific platform.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="platformId">Platform identifier.</param>
+        /// <returns>Type or null.</returns>
+        private string GetTypeName(int id, byte platformId)
+        {
+            return DoOutInOp((int) Op.GetType, w =>
+            {
+                w.WriteInt(id);
+                w.WriteByte(platformId);
+            }, r => Marshaller.StartUnmarshal(r).ReadString());
         }
 
         /// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
index a45f95f..4f67c08 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
@@ -28,12 +28,6 @@ namespace Apache.Ignite.Core.Impl.Binary
     /// </summary>
     internal class BinaryProcessorClient : IBinaryProcessor
     {
-        /** Java platform id. See org.apache.ignite.internal.MarshallerPlatformIds in Java. */
-        private const byte JavaPlatformId = 0;
-
-        /** Type registry platform id. See org.apache.ignite.internal.MarshallerPlatformIds in Java. */
-        private const byte DotNetPlatformId = 1;
-
         /** Socket. */
         private readonly ClientFailoverSocket _socket;
 
@@ -80,7 +74,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             var res = _socket.DoOutInOp(ClientOp.BinaryTypeNamePut, ctx =>
             {
-                ctx.Stream.WriteByte(DotNetPlatformId);
+                ctx.Stream.WriteByte(BinaryProcessor.DotNetPlatformId);
                 ctx.Stream.WriteInt(id);
                 ctx.Writer.WriteString(typeName);
             }, ctx => ctx.Stream.ReadBool());
@@ -89,7 +83,7 @@ namespace Apache.Ignite.Core.Impl.Binary
             {
                 res = _socket.DoOutInOp(ClientOp.BinaryTypeNamePut, ctx =>
                 {
-                    ctx.Stream.WriteByte(JavaPlatformId);
+                    ctx.Stream.WriteByte(BinaryProcessor.JavaPlatformId);
                     ctx.Stream.WriteInt(id);
                     ctx.Writer.WriteString(typeName);
                 }, ctx => ctx.Stream.ReadBool());
@@ -109,7 +103,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             return _socket.DoOutInOp(ClientOp.BinaryTypeNameGet, ctx =>
                 {
-                    ctx.Stream.WriteByte(DotNetPlatformId);
+                    ctx.Stream.WriteByte(BinaryProcessor.DotNetPlatformId);
                     ctx.Stream.WriteInt(id);
                 },
                 ctx => ctx.Reader.ReadString());
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 76b9cbc..d160c08 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -915,7 +915,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <summary>
         /// Gets the name of the type.
         /// </summary>
-        private string GetTypeName(string fullTypeName, IBinaryNameMapper mapper = null)
+        public string GetTypeName(string fullTypeName, IBinaryNameMapper mapper = null)
         {
             mapper = mapper ?? _cfg.NameMapper ?? GetDefaultNameMapper();
 
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
index 16e3c47..e28f4d7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
@@ -46,45 +46,36 @@ namespace Apache.Ignite.Core.Impl.Services
         {
             Debug.Assert(writer != null);
 
-            Marshaller.RegisterSameJavaType.Value = true;
+            writer.WriteString(methodName);
 
-            try
+            if (arguments != null)
             {
-                writer.WriteString(methodName);
+                writer.WriteBoolean(true);
+                writer.WriteInt(arguments.Length);
 
-                if (arguments != null)
+                if (platformType == PlatformType.DotNet)
                 {
-                    writer.WriteBoolean(true);
-                    writer.WriteInt(arguments.Length);
-
-                    if (platformType == PlatformType.DotNet)
+                    // Write as is for .NET.
+                    foreach (var arg in arguments)
                     {
-                        // Write as is for .NET.
-                        foreach (var arg in arguments)
-                        {
-                            writer.WriteObjectDetached(arg);
-                        }
+                        writer.WriteObjectDetached(arg);
                     }
-                    else
+                }
+                else
+                {
+                    // Other platforms do not support Serializable, need to convert arrays and collections
+                    var mParams = method != null ? method.GetParameters() : null;
+                    Debug.Assert(mParams == null || mParams.Length == arguments.Length);
+
+                    for (var i = 0; i < arguments.Length; i++)
                     {
-                        // Other platforms do not support Serializable, need to convert arrays and collections
-                        var mParams = method != null ? method.GetParameters() : null;
-                        Debug.Assert(mParams == null || mParams.Length == arguments.Length);
-
-                        for (var i = 0; i < arguments.Length; i++)
-                        {
-                            WriteArgForPlatforms(writer, mParams != null ? mParams[i].ParameterType : null,
-                                arguments[i]);
-                        }
+                        WriteArgForPlatforms(writer, mParams != null ? mParams[i].ParameterType : null,
+                            arguments[i]);
                     }
                 }
-                else
-                    writer.WriteBoolean(false);
-            }
-            finally
-            {
-                Marshaller.RegisterSameJavaType.Value = false;
             }
+            else
+                writer.WriteBoolean(false);
         }
 
         /// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
index 204d3ae..3afe34b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -434,10 +434,20 @@ namespace Apache.Ignite.Core.Impl.Services
         private object InvokeProxyMethod(IPlatformTargetInternal proxy, string methodName,
             MethodBase method, object[] args, PlatformType platformType)
         {
-            return DoOutInOp(OpInvokeMethod,
-                writer => ServiceProxySerializer.WriteProxyMethod(writer, methodName, method, args, platformType),
-                (stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary), 
-                proxy);
+            Marshaller.RegisterSameJavaType.Value = true;
+
+            try
+            {
+                return DoOutInOp(OpInvokeMethod,
+                    writer => ServiceProxySerializer.WriteProxyMethod(writer, methodName, method, args, platformType),
+                    (stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary),
+                    proxy);
+            }
+            finally
+            {
+                Marshaller.RegisterSameJavaType.Value = false;
+            }
+
         }
 
         /// <summary>