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 2021/03/16 07:29:54 UTC
[ignite] branch IGNITE-14320-2 created (now f5d5ba0)
This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a change to branch IGNITE-14320-2
in repository https://gitbox.apache.org/repos/asf/ignite.git.
at f5d5ba0 IGNITE-14320 Fix invocation .Net -> .Net services with system types arguments.
This branch includes the following new commits:
new 0c64174 IGNITE-14320 Fix invocation .Net -> .Net services with system types arguments.
new f5d5ba0 IGNITE-14320 Fix invocation .Net -> .Net services with system types arguments.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[ignite] 01/02: IGNITE-14320 Fix invocation .Net -> .Net services
with system types arguments.
Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch IGNITE-14320-2
in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 0c6417473677ac6e569dedaffdf37c383e0c880c
Author: Nikolay Izhikov <ni...@apache.org>
AuthorDate: Tue Mar 16 10:26:44 2021 +0300
IGNITE-14320 Fix invocation .Net -> .Net services with system types arguments.
---
.../Services/ServicesTypeAutoResolveTest.cs | 25 +++++++---------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs
index 2d666ab..f3a7c7c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs
@@ -18,7 +18,6 @@
namespace Apache.Ignite.Core.Tests.Services
{
using System;
- using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -141,8 +140,6 @@ namespace Apache.Ignite.Core.Tests.Services
DoTestService(svc);
- DoTestDepartments(svc);
-
_grid1.GetServices().Cancel(javaSvcName);
}
@@ -160,32 +157,26 @@ namespace Apache.Ignite.Core.Tests.Services
DoTestService(svc);
- DoTestDepartments(svc);
-
_grid1.GetServices().Cancel(javaSvcName);
}
/// <summary>
- /// Tests departments call.
+ /// Tests java service instance.
/// </summary>
- private void DoTestDepartments(IJavaService svc)
+ private static void DoTestService(IJavaService svc)
{
Assert.IsNull(svc.testDepartments(null));
- var arr = new[] {"HR", "IT"}.Select(x => new Department() {Name = x}).ToArray();
-
- ICollection deps = svc.testDepartments(arr);
+ var deps = svc.testDepartments(new[]
+ {
+ new Department() {Name = "HR"},
+ new Department() {Name = "IT"}
+ }.ToList());
Assert.NotNull(deps);
Assert.AreEqual(1, deps.Count);
- Assert.AreEqual("Executive", deps.OfType<Department>().Select(d => d.Name).ToArray()[0]);
- }
+ Assert.AreEqual("Executive", deps.OfType<Department>().ToArray()[0].Name);
- /// <summary>
- /// Tests java service instance.
- /// </summary>
- private static void DoTestService(IJavaService svc)
- {
Assert.IsNull(svc.testAddress(null));
Address addr = svc.testAddress(new Address {Zip = "000", Addr = "Moscow"});
[ignite] 02/02: IGNITE-14320 Fix invocation .Net -> .Net services
with system types arguments.
Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch IGNITE-14320-2
in repository https://gitbox.apache.org/repos/asf/ignite.git
commit f5d5ba03d3053d8c3086871070ef200f4da726f1
Author: Nikolay Izhikov <ni...@apache.org>
AuthorDate: Tue Mar 16 09:49:59 2021 +0300
IGNITE-14320 Fix invocation .Net -> .Net services with system types arguments.
---
.../Binary/BinaryNameMapperTest.cs | 94 ++++++++++++++++++----
.../Services/ServicesTypeAutoResolveTest.cs | 36 +++++----
.../Binary/BinaryBasicNameMapper.cs | 5 +-
.../Impl/Binary/TypeNameParser.cs | 10 ++-
4 files changed, 109 insertions(+), 36 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs
index 1974caf..b3168a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs
@@ -45,22 +45,22 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual("System.String[]", mapper.GetTypeName(typeof(string[]).FullName));
// Generics.
- Assert.AreEqual("System.Collections.Generic.List`1[[System.String]]",
+ Assert.AreEqual("System.Collections.Generic.List`1[[System.String]]",
mapper.GetTypeName(typeof(List<string>).AssemblyQualifiedName));
-
- Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.Int32],[System.String]]",
+
+ Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.Int32],[System.String]]",
mapper.GetTypeName(typeof(Dictionary<int, string>).AssemblyQualifiedName));
-
+
Assert.AreEqual("Apache.Ignite.Core.Tests.Binary.BinaryNameMapperTest+Bar`1[[Apache.Ignite.Core." +
- "Tests.Binary.BinaryNameMapperTest+Foo]]",
+ "Tests.Binary.BinaryNameMapperTest+Foo]]",
mapper.GetTypeName(typeof(Bar<Foo>).AssemblyQualifiedName));
Assert.AreEqual("Apache.Ignite.Core.Tests.Binary.BinaryNameMapperTest+Bar`1[[Apache.Ignite.Core.Tests" +
- ".Binary.BinaryNameMapperTest+Foo]][]",
+ ".Binary.BinaryNameMapperTest+Foo]][]",
mapper.GetTypeName(typeof(Bar<Foo>[]).AssemblyQualifiedName));
-
+
Assert.AreEqual("Apache.Ignite.Core.Tests.Binary.BinaryNameMapperTest+Bar`1[[Apache.Ignite.Core.Tests." +
- "Binary.BinaryNameMapperTest+Foo[]]][]",
+ "Binary.BinaryNameMapperTest+Foo[]]][]",
mapper.GetTypeName(typeof(Bar<Foo[]>[]).AssemblyQualifiedName));
// Open generics.
@@ -78,7 +78,7 @@ namespace Apache.Ignite.Core.Tests.Binary
public void TestSimpleName()
{
var mapper = new BinaryBasicNameMapper {IsSimpleName = true};
-
+
// Simple type.
Assert.AreEqual("Int32", mapper.GetTypeName(typeof(int).AssemblyQualifiedName));
Assert.AreEqual("Int32", mapper.GetTypeName(typeof(int).FullName));
@@ -89,7 +89,7 @@ namespace Apache.Ignite.Core.Tests.Binary
// Generics.
Assert.AreEqual("List`1[[String]]", mapper.GetTypeName(typeof(List<string>).AssemblyQualifiedName));
- Assert.AreEqual("Dictionary`2[[Int32],[String]]",
+ Assert.AreEqual("Dictionary`2[[Int32],[String]]",
mapper.GetTypeName(typeof(Dictionary<int, string>).AssemblyQualifiedName));
Assert.AreEqual("Bar`1[[Foo]]", mapper.GetTypeName(typeof(Bar<Foo>).AssemblyQualifiedName));
Assert.AreEqual("Bar`1[[Foo]][]", mapper.GetTypeName(typeof(Bar<Foo>[]).AssemblyQualifiedName));
@@ -110,11 +110,23 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual("org.company.MyClass", mapper.GetTypeName("Org.Company.MyClass"));
Assert.AreEqual("org.company.URL", mapper.GetTypeName("Org.Company.URL"));
- Assert.AreEqual("apache.ignite.platform.model.Address",
+ Assert.AreEqual("apache.ignite.platform.model.Address",
mapper.GetTypeName(typeof(Address).FullName));
- Assert.AreEqual("apache.ignite.platform.model.Address[]",
+ Assert.AreEqual("apache.ignite.platform.model.Address[]",
mapper.GetTypeName(typeof(Address[]).FullName));
+
+ Assert.AreEqual("System.Collections.Generic.List`1",
+ mapper.GetTypeName(typeof(List<>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.List`1[[apache.ignite.platform.model.Address]]",
+ mapper.GetTypeName(typeof(List<Address>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.Dictionary`2",
+ mapper.GetTypeName(typeof(Dictionary<,>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.Int32],[apache.ignite.platform.model.Address]]",
+ mapper.GetTypeName(typeof(Dictionary<int,Address>).AssemblyQualifiedName));
}
/// <summary>
@@ -131,6 +143,18 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual("MyClass", mapper.GetTypeName("Org.Company.MyClass"));
Assert.AreEqual("URL", mapper.GetTypeName("Org.Company.URL"));
+ Assert.AreEqual("List`1",
+ mapper.GetTypeName(typeof(List<>).AssemblyQualifiedName));
+
+ Assert.AreEqual("List`1[[Address]]",
+ mapper.GetTypeName(typeof(List<Address>).AssemblyQualifiedName));
+
+ Assert.AreEqual("Dictionary`2",
+ mapper.GetTypeName(typeof(Dictionary<,>).AssemblyQualifiedName));
+
+ Assert.AreEqual("Dictionary`2[[Int32],[Address]]",
+ mapper.GetTypeName(typeof(Dictionary<int,Address>).AssemblyQualifiedName));
+
mapper = new BinaryBasicNameMapper {IsSimpleName = true, NamespacePrefix = "org."};
Assert.IsTrue(mapper.IsSimpleName);
@@ -138,6 +162,18 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual("Class", mapper.GetTypeName("Org.MyCompany.Class"));
Assert.AreEqual("MyClass", mapper.GetTypeName("Org.Company.MyClass"));
Assert.AreEqual("URL", mapper.GetTypeName("Org.Company.URL"));
+
+ Assert.AreEqual("List`1",
+ mapper.GetTypeName(typeof(List<>).AssemblyQualifiedName));
+
+ Assert.AreEqual("List`1[[Address]]",
+ mapper.GetTypeName(typeof(List<Address>).AssemblyQualifiedName));
+
+ Assert.AreEqual("Dictionary`2",
+ mapper.GetTypeName(typeof(Dictionary<,>).AssemblyQualifiedName));
+
+ Assert.AreEqual("Dictionary`2[[Int32],[Address]]",
+ mapper.GetTypeName(typeof(Dictionary<int, Address>).AssemblyQualifiedName));
}
/// <summary>
@@ -154,12 +190,24 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual("org.company.MyClass", mapper.GetTypeName("Company.MyClass"));
Assert.AreEqual("org.company.URL", mapper.GetTypeName("Company.URL"));
- Assert.AreEqual("org.apache.ignite.platform.model.Address",
+ Assert.AreEqual("org.apache.ignite.platform.model.Address",
mapper.GetTypeName(typeof(Address).FullName));
- Assert.AreEqual("org.apache.ignite.platform.model.Address[]",
+ Assert.AreEqual("org.apache.ignite.platform.model.Address[]",
mapper.GetTypeName(typeof(Address[]).FullName));
-
+
+ Assert.AreEqual("System.Collections.Generic.List`1[[org.apache.ignite.platform.model.Address]]",
+ mapper.GetTypeName(typeof(List<Address>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.List`1",
+ mapper.GetTypeName(typeof(List<>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.Dictionary`2",
+ mapper.GetTypeName(typeof(Dictionary<,>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.Int32],[org.apache.ignite.platform.model.Address]]",
+ mapper.GetTypeName(typeof(Dictionary<int, Address>).AssemblyQualifiedName));
+
mapper = new BinaryBasicNameMapper {NamespacePrefix = "Org.", NamespaceToLower = false};
Assert.IsFalse(mapper.IsSimpleName);
@@ -168,11 +216,23 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual("Org.Company.MyClass", mapper.GetTypeName("Company.MyClass"));
Assert.AreEqual("Org.Company.URL", mapper.GetTypeName("Company.URL"));
- Assert.AreEqual("Org.Apache.Ignite.Platform.Model.Address",
+ Assert.AreEqual("Org.Apache.Ignite.Platform.Model.Address",
mapper.GetTypeName(typeof(Address).FullName));
- Assert.AreEqual("Org.Apache.Ignite.Platform.Model.Address[]",
+ Assert.AreEqual("Org.Apache.Ignite.Platform.Model.Address[]",
mapper.GetTypeName(typeof(Address[]).FullName));
+
+ Assert.AreEqual("System.Collections.Generic.List`1[[Org.Apache.Ignite.Platform.Model.Address]]",
+ mapper.GetTypeName(typeof(List<Address>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.List`1",
+ mapper.GetTypeName(typeof(List<>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.Dictionary`2",
+ mapper.GetTypeName(typeof(Dictionary<,>).AssemblyQualifiedName));
+
+ Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.Int32],[Org.Apache.Ignite.Platform.Model.Address]]",
+ mapper.GetTypeName(typeof(Dictionary<int, Address>).AssemblyQualifiedName));
}
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs
index f3a7c7c..3de31ab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs
@@ -23,6 +23,8 @@ namespace Apache.Ignite.Core.Tests.Services
using System.Linq;
using System.Reflection;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Services;
using NUnit.Framework;
using Apache.Ignite.Platform.Model;
@@ -169,14 +171,27 @@ namespace Apache.Ignite.Core.Tests.Services
var deps = svc.testDepartments(new[]
{
- new Department() {Name = "HR"},
- new Department() {Name = "IT"}
+ new Department {Name = "HR"},
+ new Department {Name = "IT"}
}.ToList());
Assert.NotNull(deps);
Assert.AreEqual(1, deps.Count);
Assert.AreEqual("Executive", deps.OfType<Department>().ToArray()[0].Name);
+ Assert.IsNull(svc.testMap(null));
+
+ var map = new Dictionary<Key, Value>();
+
+ map.Add(new Key() {Id = 1}, new Value() {Val = "value1"});
+ map.Add(new Key() {Id = 2}, new Value() {Val = "value2"});
+
+ var res = svc.testMap(map);
+
+ Assert.NotNull(res);
+ Assert.AreEqual(1, res.Count);
+ Assert.AreEqual("value3", ((Value)res[new Key() {Id = 3}]).Val);
+
Assert.IsNull(svc.testAddress(null));
Address addr = svc.testAddress(new Address {Zip = "000", Addr = "Moscow"});
@@ -199,19 +214,6 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.AreEqual("Kyle Reese", emps[0].Fio);
Assert.AreEqual(3, emps[0].Salary);
- Assert.IsNull(svc.testMap(null));
-
- var map = new Dictionary<Key, Value>();
-
- map.Add(new Key() {Id = 1}, new Value() {Val = "value1"});
- map.Add(new Key() {Id = 2}, new Value() {Val = "value2"});
-
- var res = svc.testMap(map);
-
- 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);
@@ -226,10 +228,10 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.NotNull(users);
Assert.AreEqual(2, users.Length);
Assert.AreEqual(1, users[0].Id);
- Assert.AreEqual(ACL.Allow, users[0].Acl);
+ 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(ACL.DENY, users[1].Acl);
Assert.AreEqual("user", users[1].Role.Name);
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs
index 4385f2c..47c7bd8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs
@@ -140,10 +140,13 @@ namespace Apache.Ignite.Core.Binary
if (IsSimpleName)
return name.GetName();
- var fullName = NamespaceToLower && name.HasNamespace()
+ var fullName = NamespaceToLower && name.HasNamespace() && !name.IsSystem()
? name.GetNamespace().ToLower(CultureInfo.InvariantCulture) + name.GetName()
: name.GetNameWithNamespace();
+ if (name.IsSystem())
+ return fullName;
+
return NamespacePrefix + fullName;
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeNameParser.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeNameParser.cs
index f3ea08f..5ac7b63 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeNameParser.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeNameParser.cs
@@ -168,11 +168,19 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
+ /// Get a value indicating that type is a System type. E.g List, Dictionary.
+ /// </summary>
+ public bool IsSystem()
+ {
+ return GetFullName().StartsWith("System");
+ }
+
+ /// <summary>
/// Gets namespace name part.
/// </summary>
public string GetNamespace()
{
- return NameStart == 0 ? null : _typeName.Substring(_start, NameStart);
+ return NameStart == 0 ? null : _typeName.Substring(_start, NameStart - _start);
}
/// <summary>