IGNITE-2398 .NET: Change default name mapper behavior to full name This closes #1787
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3e3b91a8 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3e3b91a8 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3e3b91a8 Branch: refs/heads/ignite-4985 Commit: 3e3b91a8a3e50ce8e255bb0ce2bfc4ae9ab858a2 Parents: 99842bf Author: Pavel Tupitsyn <[email protected]> Authored: Tue Apr 18 11:19:57 2017 +0300 Committer: Pavel Tupitsyn <[email protected]> Committed: Tue Apr 18 11:19:57 2017 +0300 ---------------------------------------------------------------------- .../ignite/binary/BinaryBasicNameMapper.java | 3 + .../PlatformDotNetConfigurationClosure.java | 66 +--- .../utils/PlatformConfigurationUtils.java | 8 + .../internal/processors/query/QueryUtils.java | 5 + .../Apache.Ignite.Core.Tests.csproj | 7 + .../Binary/BinaryBuilderSelfTest.cs | 90 +++-- .../Binary/BinaryBuilderSelfTestSimpleName.cs | 33 ++ .../Binary/BinaryCompactFooterInteropTest.cs | 3 + .../Binary/BinaryDynamicRegistrationTest.cs | 10 +- .../Binary/BinaryNameMapperTest.cs | 108 ++++++ .../Binary/BinarySelfTest.cs | 20 +- .../Binary/BinarySelfTestSimpleName.cs | 33 ++ .../Binary/Serializable/SqlDmlTest.cs | 3 + .../Binary/TypeNameParserTest.cs | 232 +++++++++++ .../Cache/Query/CacheDmlQueriesTest.cs | 11 + .../Query/CacheDmlQueriesTestSimpleName.cs | 35 ++ .../Cache/Query/CacheLinqTest.cs | 15 +- .../Cache/Query/CacheLinqTestSimpleName.cs | 35 ++ .../Query/CacheQueriesCodeConfigurationTest.cs | 10 +- .../Cache/Query/CacheQueriesTest.cs | 13 +- .../Cache/Query/CacheQueriesTestSimpleName.cs | 35 ++ .../Continuous/ContinuousQueryAbstractTest.cs | 36 +- .../Cache/Store/CacheStoreTest.cs | 4 +- .../Compute/ComputeApiTest.cs | 3 +- .../Config/Compute/compute-grid2.xml | 10 - .../Config/cache-binarizables.xml | 16 +- .../Config/cache-query-continuous.xml | 8 +- .../Config/cache-query.xml | 2 +- .../Services/ServicesTest.cs | 3 + .../Apache.Ignite.Core.csproj | 2 + .../Binary/BinaryBasicNameMapper.cs | 129 +++++++ .../Cache/Configuration/QueryEntity.cs | 4 +- .../Cache/Configuration/QueryField.cs | 2 +- .../Apache.Ignite.Core/IgniteConfiguration.cs | 11 + .../Apache.Ignite.Core/Impl/Binary/Binary.cs | 10 +- .../Binary/BinarySurrogateTypeDescriptor.cs | 15 +- .../Impl/Binary/BinaryUtils.cs | 117 +----- .../Impl/Binary/Marshaller.cs | 95 ++++- .../Impl/Binary/TypeNameParser.cs | 384 +++++++++++++++++++ .../Impl/Binary/TypeResolver.cs | 95 ++--- .../Impl/CacheFieldsQueryProvider.cs | 24 +- .../Impl/CacheQueryExpressionVisitor.cs | 4 +- 42 files changed, 1403 insertions(+), 346 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java index bc338b4..156716c 100644 --- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java @@ -111,6 +111,9 @@ public class BinaryBasicNameMapper implements BinaryNameMapper { } if (idx < 0) + idx = clsName.lastIndexOf('+'); // .NET inner class. + + if (idx < 0) idx = clsName.lastIndexOf('.'); return idx >= 0 ? clsName.substring(idx + 1) : clsName; http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java index 0ff78af..b0daf35 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java @@ -101,13 +101,33 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur igniteCfg.setPlatformConfiguration(dotNetCfg0); + // Set Ignite home so that marshaller context works. + String ggHome = igniteCfg.getIgniteHome(); + + if (ggHome != null) + U.setIgniteHome(ggHome); + + // 4. Callback to .Net. + prepare(igniteCfg, dotNetCfg0); + + // Make sure binary config is right. + setBinaryConfiguration(igniteCfg, dotNetCfg0); + } + + /** + * Sets binary config. + * + * @param igniteCfg Ignite config. + * @param dotNetCfg Dotnet config. + */ + private void setBinaryConfiguration(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx dotNetCfg) { // Check marshaller. Marshaller marsh = igniteCfg.getMarshaller(); if (marsh == null) { igniteCfg.setMarshaller(new BinaryMarshaller()); - dotNetCfg0.warnings(Collections.singleton("Marshaller is automatically set to " + + dotNetCfg.warnings(Collections.singleton("Marshaller is automatically set to " + BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type).")); } else if (!(marsh instanceof BinaryMarshaller)) @@ -115,50 +135,6 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur " can be used when running Apache Ignite.NET): " + marsh.getClass().getName()); BinaryConfiguration bCfg = igniteCfg.getBinaryConfiguration(); - - if (bCfg == null) { - bCfg = new BinaryConfiguration(); - - bCfg.setNameMapper(new BinaryBasicNameMapper(true)); - bCfg.setIdMapper(new BinaryBasicIdMapper(true)); - - igniteCfg.setBinaryConfiguration(bCfg); - - dotNetCfg0.warnings(Collections.singleton("Binary configuration is automatically initiated, " + - "note that binary name mapper is set to " + bCfg.getNameMapper() - + " and binary ID mapper is set to " + bCfg.getIdMapper() - + " (other nodes must have the same binary name and ID mapper types).")); - } - else { - BinaryNameMapper nameMapper = bCfg.getNameMapper(); - - if (nameMapper == null) { - bCfg.setNameMapper(new BinaryBasicNameMapper(true)); - - dotNetCfg0.warnings(Collections.singleton("Binary name mapper is automatically set to " + - bCfg.getNameMapper() - + " (other nodes must have the same binary name mapper type).")); - } - - BinaryIdMapper idMapper = bCfg.getIdMapper(); - - if (idMapper == null) { - bCfg.setIdMapper(new BinaryBasicIdMapper(true)); - - dotNetCfg0.warnings(Collections.singleton("Binary ID mapper is automatically set to " + - bCfg.getIdMapper() - + " (other nodes must have the same binary ID mapper type).")); - } - } - - // Set Ignite home so that marshaller context works. - String ggHome = igniteCfg.getIgniteHome(); - - if (ggHome != null) - U.setIgniteHome(ggHome); - - // 4. Callback to .Net. - prepare(igniteCfg, dotNetCfg0); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java index 6a15b85..98ce61d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java @@ -34,6 +34,7 @@ import java.util.Set; import javax.cache.configuration.Factory; import javax.cache.expiry.ExpiryPolicy; import org.apache.ignite.IgniteException; +import org.apache.ignite.binary.BinaryBasicNameMapper; import org.apache.ignite.binary.BinaryRawReader; import org.apache.ignite.binary.BinaryRawWriter; import org.apache.ignite.cache.CacheAtomicityMode; @@ -563,6 +564,11 @@ public class PlatformConfigurationUtils { if (in.readBoolean()) // compact footer is set cfg.getBinaryConfiguration().setCompactFooter(in.readBoolean()); + + if (in.readBoolean()) { + // Simple name mapper. + cfg.getBinaryConfiguration().setNameMapper(new BinaryBasicNameMapper(true)); + } } int attrCnt = in.readInt(); @@ -969,6 +975,8 @@ public class PlatformConfigurationUtils { w.writeBoolean(true); // binary config exists w.writeBoolean(true); // compact footer is set w.writeBoolean(bc.isCompactFooter()); + w.writeBoolean(bc.getNameMapper() instanceof BinaryBasicNameMapper && + ((BinaryBasicNameMapper)(bc.getNameMapper())).isSimpleName()); } else w.writeBoolean(false); http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java index 118f8b8..f00cbd6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java @@ -615,6 +615,11 @@ public class QueryUtils { if (parentEnd >= 0) clsName = clsName.substring(parentEnd + 1); + parentEnd = clsName.lastIndexOf('+'); // .NET parent + + if (parentEnd >= 0) + clsName = clsName.substring(parentEnd + 1); + return clsName; } http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj index 838a1e0..a13878a 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj @@ -68,9 +68,12 @@ <Reference Include="System.Xml.Linq" /> </ItemGroup> <ItemGroup> + <Compile Include="Binary\BinaryBuilderSelfTestSimpleName.cs" /> <Compile Include="Binary\BinaryEqualityComparerTest.cs" /> <Compile Include="Binary\BinaryBuilderSelfTestDynamicRegistration.cs" /> + <Compile Include="Binary\BinaryNameMapperTest.cs" /> <Compile Include="Binary\BinaryReaderWriterTest.cs" /> + <Compile Include="Binary\BinarySelfTestSimpleName.cs" /> <Compile Include="Binary\IO\BinaryStreamsTest.cs" /> <Compile Include="Binary\JavaBinaryInteropTest.cs" /> <Compile Include="Binary\JavaTypeMappingTest.cs" /> @@ -80,6 +83,7 @@ <Compile Include="Binary\Serializable\ObjectReferenceTests.cs" /> <Compile Include="Binary\Serializable\PrimitivesTest.cs" /> <Compile Include="Binary\Serializable\SqlDmlTest.cs" /> + <Compile Include="Binary\TypeNameParserTest.cs" /> <Compile Include="Binary\TypeResolverTest.cs" /> <Compile Include="Cache\Affinity\AffinityKeyTest.cs" /> <Compile Include="Cache\Affinity\AffinityTopologyVersionTest.cs" /> @@ -87,6 +91,9 @@ <Compile Include="Cache\CacheResultTest.cs" /> <Compile Include="Cache\Query\CacheDmlQueriesTest.cs" /> <Compile Include="Cache\CacheAbstractTransactionalTest.cs" /> + <Compile Include="Cache\Query\CacheDmlQueriesTestSimpleName.cs" /> + <Compile Include="Cache\Query\CacheLinqTestSimpleName.cs" /> + <Compile Include="Cache\Query\CacheQueriesTestSimpleName.cs" /> <Compile Include="Cache\Store\CacheStoreAdapterTest.cs" /> <Compile Include="Cache\Store\NamedNodeCacheStoreTest.cs" /> <Compile Include="Collections\MultiValueDictionaryTest.cs" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs index c104e15..e8d0049 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs @@ -58,8 +58,8 @@ namespace Apache.Ignite.Core.Tests.Binary { TypeConfigurations = GetTypeConfigurations(), IdMapper = new IdMapper(), - NameMapper = new NameMapper(), - CompactFooter = GetCompactFooter() + NameMapper = new NameMapper(GetNameMapper()), + CompactFooter = GetCompactFooter(), } }; @@ -114,6 +114,22 @@ namespace Apache.Ignite.Core.Tests.Binary } /// <summary> + /// Gets the name mapper. + /// </summary> + protected virtual IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.FullNameInstance; + } + + /// <summary> + /// Gets the name of the type. + /// </summary> + private string GetTypeName(Type type) + { + return GetNameMapper().GetTypeName(type.AssemblyQualifiedName); + } + + /// <summary> /// Tear down routine. /// </summary> [TestFixtureTearDown] @@ -249,7 +265,7 @@ namespace Apache.Ignite.Core.Tests.Binary // 4. Objects. IBinaryObject binObj = api.ToBinary<IBinaryObject>(new ToBinary(1)); - Assert.AreEqual(typeof(ToBinary).Name, binObj.GetBinaryType().TypeName); + Assert.AreEqual(GetTypeName(typeof(ToBinary)), binObj.GetBinaryType().TypeName); Assert.AreEqual(1, binObj.GetBinaryType().Fields.Count); Assert.AreEqual("Val", binObj.GetBinaryType().Fields.First()); Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj.GetBinaryType().GetFieldTypeName("Val")); @@ -280,7 +296,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(Remove).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(Remove)), meta.TypeName); Assert.AreEqual(0, meta.Fields.Count); // Populate it with field. @@ -301,7 +317,7 @@ namespace Apache.Ignite.Core.Tests.Binary meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(Remove).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(Remove)), meta.TypeName); Assert.AreEqual(1, meta.Fields.Count); Assert.AreEqual("val", meta.Fields.First()); Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("val")); @@ -358,7 +374,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType meta = outerbinObj.GetBinaryType(); - Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(BuilderInBuilderOuter)), meta.TypeName); Assert.AreEqual(1, meta.Fields.Count); Assert.AreEqual("inner", meta.Fields.First()); Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner")); @@ -367,7 +383,7 @@ namespace Apache.Ignite.Core.Tests.Binary meta = innerbinObj.GetBinaryType(); - Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(BuilderInBuilderInner)), meta.TypeName); Assert.AreEqual(1, meta.Fields.Count); Assert.AreEqual("outer", meta.Fields.First()); Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("outer")); @@ -386,7 +402,7 @@ namespace Apache.Ignite.Core.Tests.Binary meta = outerbinObj.GetBinaryType(); - Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(BuilderInBuilderOuter)), meta.TypeName); Assert.AreEqual(2, meta.Fields.Count); Assert.IsTrue(meta.Fields.Contains("inner")); Assert.IsTrue(meta.Fields.Contains("inner2")); @@ -423,7 +439,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(DecimalHolder)), meta.TypeName); Assert.AreEqual(2, meta.Fields.Count); Assert.IsTrue(meta.Fields.Contains("val")); Assert.IsTrue(meta.Fields.Contains("valArr")); @@ -456,7 +472,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType meta = binCol.GetBinaryType(); - Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(BuilderCollection)), meta.TypeName); Assert.AreEqual(1, meta.Fields.Count); Assert.AreEqual("col", meta.Fields.First()); Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col")); @@ -469,7 +485,7 @@ namespace Apache.Ignite.Core.Tests.Binary meta = binItem.GetBinaryType(); - Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(BuilderCollectionItem)), meta.TypeName); Assert.AreEqual(1, meta.Fields.Count); Assert.AreEqual("val", meta.Fields.First()); Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("val")); @@ -549,7 +565,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType meta = binObj.GetBinaryType(); Assert.IsNotNull(meta); - Assert.AreEqual(typeof(Empty).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(Empty)), meta.TypeName); Assert.AreEqual(0, meta.Fields.Count); Empty obj = binObj.Deserialize<Empty>(); @@ -690,11 +706,11 @@ namespace Apache.Ignite.Core.Tests.Binary /// <summary> /// Checks the primitive fields values. /// </summary> - private static void CheckPrimitiveFields1(IBinaryObject binObj) + private void CheckPrimitiveFields1(IBinaryObject binObj) { IBinaryType meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(Primitives).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(Primitives)), meta.TypeName); Assert.AreEqual(9, meta.Fields.Count); @@ -842,11 +858,11 @@ namespace Apache.Ignite.Core.Tests.Binary /// <summary> /// Checks the primitive array fields. /// </summary> - private static void CheckPrimitiveArrayFields1(IBinaryObject binObj) + private void CheckPrimitiveArrayFields1(IBinaryObject binObj) { IBinaryType meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(PrimitiveArrays)), meta.TypeName); Assert.AreEqual(9, meta.Fields.Count); @@ -1009,7 +1025,7 @@ namespace Apache.Ignite.Core.Tests.Binary { IBinaryType meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(StringDateGuidEnum)), meta.TypeName); Assert.AreEqual(10, meta.Fields.Count); @@ -1139,7 +1155,7 @@ namespace Apache.Ignite.Core.Tests.Binary var meta = binEnum.GetBinaryType(); Assert.IsTrue(meta.IsEnum); - Assert.AreEqual(typeof (TestEnumRegistered).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof (TestEnumRegistered)), meta.TypeName); Assert.AreEqual(0, meta.Fields.Count); } @@ -1157,7 +1173,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(CompositeArray)), meta.TypeName); Assert.AreEqual(1, meta.Fields.Count); Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr")); @@ -1254,7 +1270,7 @@ namespace Apache.Ignite.Core.Tests.Binary meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(CompositeArray)), meta.TypeName); Assert.AreEqual(2, meta.Fields.Count); Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr")); Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr")); @@ -1311,7 +1327,7 @@ namespace Apache.Ignite.Core.Tests.Binary // 1. Check meta. IBinaryType meta = binObj.GetBinaryType(); - Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(CompositeContainer)), meta.TypeName); Assert.AreEqual(2, meta.Fields.Count); Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col")); @@ -1378,7 +1394,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType meta = outerbinObj.GetBinaryType(); - Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName); + Assert.AreEqual(GetTypeName(typeof(NestedOuter)), meta.TypeName); Assert.AreEqual(1, meta.Fields.Count); Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1")); @@ -1386,7 +1402,7 @@ namespace Apache.Ignite.Core.Tests.Binary IBinaryType innerMeta = innerbinObj1.GetBinaryType(); - Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName); + Assert.AreEqual(GetTypeName(typeof(NestedInner)), innerMeta.TypeName); Assert.AreEqual(1, innerMeta.Fields.Count); Assert.AreEqual(BinaryTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val")); @@ -1605,10 +1621,12 @@ namespace Apache.Ignite.Core.Tests.Binary binary.ToBinary<IBinaryObject>(new DecimalHolder()); + var typeName = GetTypeName(typeof(DecimalHolder)); + // All meta var allMetas = binary.GetBinaryTypes(); - var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder"); + var decimalMeta = allMetas.Single(x => x.TypeName == typeName); Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields); @@ -1618,12 +1636,12 @@ namespace Apache.Ignite.Core.Tests.Binary Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields); // By type id - decimalMeta = binary.GetBinaryType(binary.GetTypeId("DecimalHolder")); + decimalMeta = binary.GetBinaryType(binary.GetTypeId(typeName)); Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields); // By type name - decimalMeta = binary.GetBinaryType("DecimalHolder"); + decimalMeta = binary.GetBinaryType(typeName); Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields); } @@ -1638,7 +1656,7 @@ namespace Apache.Ignite.Core.Tests.Binary var binEnums = new[] { binary.BuildEnum(typeof (TestEnumRegistered), val), - binary.BuildEnum(typeof (TestEnumRegistered).Name, val) + binary.BuildEnum(GetTypeName(typeof (TestEnumRegistered)), val) }; foreach (var binEnum in binEnums) @@ -2086,18 +2104,30 @@ namespace Apache.Ignite.Core.Tests.Binary public class NameMapper : IBinaryNameMapper { /** */ + private readonly IBinaryNameMapper _baseMapper; + + /** */ public const string TestTypeName = "NameMapperTestType"; /** */ public const string TestFieldName = "NameMapperTestField"; + /// <summary> + /// Initializes a new instance of the <see cref="NameMapper" /> class. + /// </summary> + /// <param name="baseMapper">The base mapper.</param> + public NameMapper(IBinaryNameMapper baseMapper) + { + _baseMapper = baseMapper; + } + /** <inheritdoc /> */ public string GetTypeName(string name) { - if (name == TestTypeName) - return name + "_"; + if (name == typeof(NameMapperTestType).AssemblyQualifiedName) + return TestTypeName + "_"; - return name; + return _baseMapper.GetTypeName(name); } /** <inheritdoc /> */ http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestSimpleName.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestSimpleName.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestSimpleName.cs new file mode 100644 index 0000000..918f82d --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestSimpleName.cs @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.Binary +{ + using Apache.Ignite.Core.Binary; + + /// <summary> + /// Builder test with simple names. + /// </summary> + public class BinaryBuilderSelfTestSimpleName : BinaryBuilderSelfTest + { + /** <inheritdoc /> */ + protected override IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.SimpleNameInstance; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs index 76ef999..bda3438 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs @@ -141,6 +141,9 @@ namespace Apache.Ignite.Core.Tests.Binary BinaryConfiguration = new BinaryConfiguration( typeof (PlatformComputeBinarizable), typeof (PlatformComputeNetBinarizable)) + { + NameMapper = BinaryBasicNameMapper.SimpleNameInstance + } }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs index 24f5e7c..687b1f5 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs @@ -293,7 +293,15 @@ namespace Apache.Ignite.Core.Tests.Binary [Test] public void TestJavaInterop() { - using (var ignite = Ignition.Start(TestUtils.GetTestConfiguration())) + var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + BinaryConfiguration = new BinaryConfiguration + { + NameMapper = BinaryBasicNameMapper.SimpleNameInstance + } + }; + + using (var ignite = Ignition.Start(cfg)) { var cacheCfg = new CacheConfiguration(null, new QueryEntity(typeof(PlatformComputeBinarizable)) { http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs new file mode 100644 index 0000000..b3ace97 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryNameMapperTest.cs @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.Binary +{ + using System.Collections.Generic; + using Apache.Ignite.Core.Binary; + using NUnit.Framework; + + /// <summary> + /// Tests binary name mapper. + /// </summary> + public class BinaryNameMapperTest + { + /// <summary> + /// Tests full name mode. + /// </summary> + [Test] + public void TestFullName() + { + var mapper = new BinaryBasicNameMapper(); + Assert.IsFalse(mapper.IsSimpleName); + + // Simple type. + Assert.AreEqual("System.Int32", mapper.GetTypeName(typeof(int).AssemblyQualifiedName)); + Assert.AreEqual("System.Int32", mapper.GetTypeName(typeof(int).FullName)); + + // Array. + Assert.AreEqual("System.String[]", mapper.GetTypeName(typeof(string[]).AssemblyQualifiedName)); + Assert.AreEqual("System.String[]", mapper.GetTypeName(typeof(string[]).FullName)); + + // Generics. + 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]]", + mapper.GetTypeName(typeof(Dictionary<int, string>).AssemblyQualifiedName)); + + Assert.AreEqual("Apache.Ignite.Core.Tests.Binary.BinaryNameMapperTest+Bar`1[[Apache.Ignite.Core." + + "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]][]", + mapper.GetTypeName(typeof(Bar<Foo>[]).AssemblyQualifiedName)); + + Assert.AreEqual("Apache.Ignite.Core.Tests.Binary.BinaryNameMapperTest+Bar`1[[Apache.Ignite.Core.Tests." + + "Binary.BinaryNameMapperTest+Foo[]]][]", + mapper.GetTypeName(typeof(Bar<Foo[]>[]).AssemblyQualifiedName)); + } + + /// <summary> + /// Tests simple name mode. + /// </summary> + [Test] + 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)); + + // Array. + Assert.AreEqual("String[]", mapper.GetTypeName(typeof(string[]).AssemblyQualifiedName)); + Assert.AreEqual("String[]", mapper.GetTypeName(typeof(string[]).FullName)); + + // Generics. + Assert.AreEqual("List`1[[String]]", mapper.GetTypeName(typeof(List<string>).AssemblyQualifiedName)); + 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)); + Assert.AreEqual("Bar`1[[Foo[]]][]", mapper.GetTypeName(typeof(Bar<Foo[]>[]).AssemblyQualifiedName)); + } + + /// <summary> + /// Nested class. + /// </summary> + private class Foo + { + // No-op. + } + + /// <summary> + /// Nested generic class. + /// </summary> + // ReSharper disable once UnusedTypeParameter + private class Bar<T> + { + // No-op. + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs index bde8166..bdc0d65 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs @@ -63,17 +63,28 @@ namespace Apache.Ignite.Core.Tests.Binary [TestFixtureSetUp] public void BeforeTest() { - _marsh = new Marshaller(new BinaryConfiguration{CompactFooter = GetCompactFooter()}); + _marsh = new Marshaller(new BinaryConfiguration + { + CompactFooter = GetCompactFooter(), + NameMapper = GetNameMapper() + }); } /// <summary> /// Gets the binary configuration. /// </summary> - /// <returns></returns> protected virtual bool GetCompactFooter() { return true; } + + /// <summary> + /// Gets the name mapper. + /// </summary> + protected virtual IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.FullNameInstance; + } /** * <summary>Check write of primitive boolean.</summary> @@ -1550,7 +1561,10 @@ namespace Apache.Ignite.Core.Tests.Binary [Test] public void TestBinaryConfigurationValidation() { - var cfg = new BinaryConfiguration(typeof (PropertyType)) {Types = new[] {"PropertyType"}}; + var cfg = new BinaryConfiguration(typeof (PropertyType)) + { + Types = new[] {typeof(PropertyType).AssemblyQualifiedName} + }; // ReSharper disable once ObjectCreationAsStatement Assert.Throws<BinaryObjectException>(() => new Marshaller(cfg)); http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTestSimpleName.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTestSimpleName.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTestSimpleName.cs new file mode 100644 index 0000000..96ccb0b --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTestSimpleName.cs @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.Binary +{ + using Apache.Ignite.Core.Binary; + + /// <summary> + /// Test with simple name mapper. + /// </summary> + public class BinarySelfTestSimpleName : BinarySelfTest + { + /** <inheritdoc /> */ + protected override IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.SimpleNameInstance; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs index b59247e..8495a30 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs @@ -54,6 +54,9 @@ namespace Apache.Ignite.Core.Tests.Binary.Serializable var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { BinaryConfiguration = new BinaryConfiguration(typeof(SimpleSerializable)) + { + NameMapper = BinaryBasicNameMapper.SimpleNameInstance + } }; _ignite = Ignition.Start(cfg); http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/TypeNameParserTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/TypeNameParserTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/TypeNameParserTest.cs new file mode 100644 index 0000000..f3394a3 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/TypeNameParserTest.cs @@ -0,0 +1,232 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ReSharper disable UnusedTypeParameter +namespace Apache.Ignite.Core.Tests.Binary +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using Apache.Ignite.Core.Common; + using Apache.Ignite.Core.Impl.Binary; + using NUnit.Framework; + + /// <summary> + /// Tests the type name parser. + /// </summary> + public class TypeNameParserTest + { + /// <summary> + /// Tests simple types. + /// </summary> + [Test] + public void TestSimpleTypes() + { + // One letter. + var res = TypeNameParser.Parse("x"); + Assert.AreEqual("x", res.GetFullName()); + Assert.AreEqual("x", res.GetName()); + Assert.AreEqual(0, res.NameStart); + Assert.AreEqual(0, res.NameEnd); + Assert.AreEqual(-1, res.AssemblyStart); + Assert.AreEqual(-1, res.AssemblyEnd); + Assert.IsNull(res.Generics); + + // Without assembly. + res = TypeNameParser.Parse("System.Int"); + + Assert.AreEqual(7, res.NameStart); + Assert.AreEqual(9, res.NameEnd); + Assert.IsNull(res.Generics); + Assert.AreEqual(-1, res.AssemblyStart); + + // With assembly. + res = TypeNameParser.Parse("System.Int, myasm, Ver=1"); + + Assert.AreEqual(7, res.NameStart); + Assert.AreEqual(9, res.NameEnd); + Assert.IsNull(res.Generics); + Assert.AreEqual(12, res.AssemblyStart); + + // Real types. + CheckType(GetType()); + CheckType(typeof(string)); + CheckType(typeof(IDictionary)); + + // Nested types. + CheckType(typeof(Nested)); + CheckType(typeof(Nested.Nested2)); + } + + /// <summary> + /// Tests generic types. + /// </summary> + [Test] + public void TestGenericTypes() + { + // Custom strings. + var res = TypeNameParser.Parse("List`1[[Int]]"); + Assert.AreEqual("List`1", res.GetName()); + Assert.AreEqual("List`1", res.GetFullName()); + Assert.AreEqual("Int", res.Generics.Single().GetName()); + Assert.AreEqual("Int", res.Generics.Single().GetFullName()); + + // One arg. + res = TypeNameParser.Parse(typeof(List<int>).AssemblyQualifiedName); + Assert.AreEqual("List`1", res.GetName()); + Assert.AreEqual("System.Collections.Generic.List`1", res.GetFullName()); + Assert.IsTrue(res.GetAssemblyName().StartsWith("mscorlib,")); + + Assert.AreEqual(1, res.Generics.Count); + var gen = res.Generics.Single(); + Assert.AreEqual("Int32", gen.GetName()); + Assert.AreEqual("System.Int32", gen.GetFullName()); + Assert.IsTrue(gen.GetAssemblyName().StartsWith("mscorlib,")); + + // Two args. + res = TypeNameParser.Parse(typeof(Dictionary<int, string>).AssemblyQualifiedName); + Assert.AreEqual("Dictionary`2", res.GetName()); + Assert.AreEqual("System.Collections.Generic.Dictionary`2", res.GetFullName()); + Assert.IsTrue(res.GetAssemblyName().StartsWith("mscorlib,")); + + Assert.AreEqual(2, res.Generics.Count); + + gen = res.Generics.First(); + Assert.AreEqual("Int32", gen.GetName()); + Assert.AreEqual("System.Int32", gen.GetFullName()); + Assert.IsTrue(gen.GetAssemblyName().StartsWith("mscorlib,")); + + gen = res.Generics.Last(); + Assert.AreEqual("String", gen.GetName()); + Assert.AreEqual("System.String", gen.GetFullName()); + Assert.IsTrue(gen.GetAssemblyName().StartsWith("mscorlib,")); + + // Nested args. + res = TypeNameParser.Parse(typeof(Dictionary<int, List<string>>).FullName); + + Assert.AreEqual("Dictionary`2", res.GetName()); + Assert.AreEqual("System.Collections.Generic.Dictionary`2", res.GetFullName()); + Assert.IsNull(res.GetAssemblyName()); + + Assert.AreEqual(2, res.Generics.Count); + + gen = res.Generics.Last(); + Assert.AreEqual("List`1", gen.GetName()); + Assert.AreEqual("System.Collections.Generic.List`1", gen.GetFullName()); + Assert.IsTrue(gen.GetAssemblyName().StartsWith("mscorlib,")); + Assert.AreEqual(1, gen.Generics.Count); + + gen = gen.Generics.Single(); + Assert.AreEqual("String", gen.GetName()); + Assert.AreEqual("System.String", gen.GetFullName()); + Assert.IsTrue(gen.GetAssemblyName().StartsWith("mscorlib,")); + + // Nested class. + res = TypeNameParser.Parse(typeof(NestedGeneric<int>).FullName); + + Assert.AreEqual("NestedGeneric`1", res.GetName()); + Assert.AreEqual("Apache.Ignite.Core.Tests.Binary.TypeNameParserTest+NestedGeneric`1", res.GetFullName()); + + gen = res.Generics.Single(); + Assert.AreEqual("Int32", gen.GetName()); + Assert.AreEqual("System.Int32", gen.GetFullName()); + + res = TypeNameParser.Parse(typeof(NestedGeneric<int>.NestedGeneric2<string>).AssemblyQualifiedName); + + Assert.AreEqual("NestedGeneric2`1", res.GetName()); + Assert.AreEqual("Apache.Ignite.Core.Tests.Binary.TypeNameParserTest+NestedGeneric`1+NestedGeneric2`1", + res.GetFullName()); + + Assert.AreEqual(2, res.Generics.Count); + Assert.AreEqual("Int32", res.Generics.First().GetName()); + Assert.AreEqual("String", res.Generics.Last().GetName()); + } + + /// <summary> + /// Tests arrays. + /// </summary> + [Test] + public void TestArrays() + { + CheckType(typeof(int[])); + CheckType(typeof(int[,])); + CheckType(typeof(int[][])); + + CheckType(typeof(List<int>[])); + CheckType(typeof(List<int>[,])); + CheckType(typeof(List<int>[][])); + } + + /// <summary> + /// Tests invalid type names. + /// </summary> + [Test] + public void TestInvalidTypes() + { + Assert.Throws<ArgumentException>(() => TypeNameParser.Parse(null)); + Assert.Throws<ArgumentException>(() => TypeNameParser.Parse("")); + + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x[")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x[[]")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x`[")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x`]")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x`[ ]")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x,")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x`x")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x`2[x")); + Assert.Throws<IgniteException>(() => TypeNameParser.Parse("x`2xx")); + } + + /// <summary> + /// Checks the type. + /// </summary> + private static void CheckType(Type type) + { + var name = type.AssemblyQualifiedName; + + Assert.IsNotNull(name); + + var res = TypeNameParser.Parse(name); + + Assert.AreEqual(type.Name, res.GetName() + res.GetArray()); + + if (res.Generics == null) + { + Assert.AreEqual(type.FullName, res.GetFullName() + res.GetArray()); + } + + Assert.AreEqual(type.FullName.Length + 2, res.AssemblyStart); + } + + private class Nested + { + public class Nested2 + { + // No-op. + } + } + + private class NestedGeneric<T> + { + public class NestedGeneric2<T2> + { + // No-op. + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs index 6afeff4..d79844e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs @@ -39,12 +39,23 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { BinaryConfiguration = new BinaryConfiguration(typeof(Foo), typeof(Key), typeof(Key2)) + { + NameMapper = GetNameMapper() + } }; Ignition.Start(cfg); } /// <summary> + /// Gets the name mapper. + /// </summary> + protected virtual IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.FullNameInstance; + } + + /// <summary> /// Tears down test fixture. /// </summary> [TestFixtureTearDown] http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTestSimpleName.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTestSimpleName.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTestSimpleName.cs new file mode 100644 index 0000000..467d78f --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTestSimpleName.cs @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.Cache.Query +{ + using Apache.Ignite.Core.Binary; + using NUnit.Framework; + + /// <summary> + /// Test with simple name mapper. + /// </summary> + [TestFixture] + public class CacheDmlQueriesTestSimpleName : CacheDmlQueriesTest + { + /** <inheritdoc /> */ + protected override IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.SimpleNameInstance; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs index 876b0be..b2213d8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs @@ -119,17 +119,28 @@ namespace Apache.Ignite.Core.Tests.Cache.Query /// <summary> /// Gets the configuration. /// </summary> - private static IgniteConfiguration GetConfig(string gridName = null) + private IgniteConfiguration GetConfig(string gridName = null) { return new IgniteConfiguration(TestUtils.GetTestConfiguration()) { BinaryConfiguration = new BinaryConfiguration(typeof(Person), - typeof(Organization), typeof(Address), typeof(Role), typeof(RoleKey), typeof(Numerics)), + typeof(Organization), typeof(Address), typeof(Role), typeof(RoleKey), typeof(Numerics)) + { + NameMapper = GetNameMapper() + }, IgniteInstanceName = gridName }; } /// <summary> + /// Gets the name mapper. + /// </summary> + protected virtual IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.FullNameInstance; + } + + /// <summary> /// Fixture tear down. /// </summary> [TestFixtureTearDown] http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTestSimpleName.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTestSimpleName.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTestSimpleName.cs new file mode 100644 index 0000000..9743e60 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTestSimpleName.cs @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.Cache.Query +{ + using Apache.Ignite.Core.Binary; + using NUnit.Framework; + + /// <summary> + /// LINQ test with simple name mapper. + /// </summary> + [TestFixture] + public class CacheLinqTestSimpleName : CacheLinqTest + { + /** <inheritdoc /> */ + protected override IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.SimpleNameInstance; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs index 8157a56..e25ddc0 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs @@ -40,10 +40,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query [Test] public void TestQueryEntityConfiguration() { - var cfg = new IgniteConfiguration + var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { - JvmOptions = TestUtils.TestJavaOptions(), - JvmClasspath = TestUtils.CreateTestClasspath(), BinaryConfiguration = new BinaryConfiguration(typeof (QueryPerson)), CacheConfiguration = new[] { @@ -132,12 +130,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query [Test] public void TestAttributeConfigurationQuery() { - var cfg = new IgniteConfiguration + var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { - JvmOptions = TestUtils.TestJavaOptions(), - JvmClasspath = TestUtils.CreateTestClasspath(), BinaryConfiguration = new BinaryConfiguration( - typeof (AttributeQueryPerson), typeof (AttributeQueryAddress)), + typeof (AttributeQueryPerson), typeof (AttributeQueryAddress)) }; using (var ignite = Ignition.Start(cfg)) http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs index d6705d4..5cbec0d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs @@ -35,7 +35,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query /// <summary> /// Queries tests. /// </summary> - public sealed class CacheQueriesTest + public class CacheQueriesTest { /** Grid count. */ private const int GridCnt = 2; @@ -66,7 +66,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query new BinaryTypeConfiguration(typeof (QueryPerson)), new BinaryTypeConfiguration(typeof (BinarizableScanQueryFilter<QueryPerson>)), new BinaryTypeConfiguration(typeof (BinarizableScanQueryFilter<BinaryObject>)) - } + }, + NameMapper = GetNameMapper() }, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), @@ -80,6 +81,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query Ignition.Start(cfg); } } + + /// <summary> + /// Gets the name mapper. + /// </summary> + protected virtual IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.FullNameInstance; + } /// <summary> /// http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTestSimpleName.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTestSimpleName.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTestSimpleName.cs new file mode 100644 index 0000000..c8924bb --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTestSimpleName.cs @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.Cache.Query +{ + using Apache.Ignite.Core.Binary; + using NUnit.Framework; + + /// <summary> + /// Test with simple name mapper. + /// </summary> + [TestFixture] + public class CacheQueriesTestSimpleName : CacheQueriesTest + { + /** <inheritdoc /> */ + protected override IBinaryNameMapper GetNameMapper() + { + return BinaryBasicNameMapper.SimpleNameInstance; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs index 57f3d00..a6b68bb 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs @@ -91,27 +91,21 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous [TestFixtureSetUp] public void SetUp() { - GC.Collect(); - TestUtils.JvmDebug = true; - - IgniteConfiguration cfg = new IgniteConfiguration(); - - BinaryConfiguration portCfg = new BinaryConfiguration(); - - ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>(); - - portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableEntry))); - portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFilter))); - portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(KeepBinaryFilter))); - - portCfg.TypeConfigurations = portTypeCfgs; - - cfg.BinaryConfiguration = portCfg; - cfg.JvmClasspath = TestUtils.CreateTestClasspath(); - cfg.JvmOptions = TestUtils.TestJavaOptions(); - cfg.SpringConfigUrl = "config\\cache-query-continuous.xml"; + var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + BinaryConfiguration = new BinaryConfiguration + { + TypeConfigurations = new List<BinaryTypeConfiguration> + { + new BinaryTypeConfiguration(typeof(BinarizableEntry)), + new BinaryTypeConfiguration(typeof(BinarizableFilter)), + new BinaryTypeConfiguration(typeof(KeepBinaryFilter)) + } + }, + SpringConfigUrl = "config\\cache-query-continuous.xml", + IgniteInstanceName = "grid-1" + }; - cfg.IgniteInstanceName = "grid-1"; grid1 = Ignition.Start(cfg); cache1 = grid1.GetCache<int, BinarizableEntry>(cacheName); @@ -1179,7 +1173,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous IBinaryType meta = val.GetBinaryType(); - Assert.AreEqual(typeof(BinarizableEntry).Name, meta.TypeName); + Assert.AreEqual(typeof(BinarizableEntry).FullName, meta.TypeName); } countDown.Signal(); http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs index b62a0ec..309c77e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs @@ -23,9 +23,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store using System.Linq; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Cache; - using Apache.Ignite.Core.Cache.Configuration; using Apache.Ignite.Core.Cache.Store; - using Apache.Ignite.Core.Common; using Apache.Ignite.Core.Impl; using NUnit.Framework; @@ -156,7 +154,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store Assert.NotNull(meta); - Assert.AreEqual("Value", meta.TypeName); + Assert.AreEqual("Apache.Ignite.Core.Tests.Cache.Store.Value", meta.TypeName); } /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs index b5b6c05..316e5d0 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs @@ -1315,7 +1315,8 @@ namespace Apache.Ignite.Core.Tests.Compute new BinaryTypeConfiguration(JavaBinaryCls), new BinaryTypeConfiguration(typeof(PlatformComputeEnum)), new BinaryTypeConfiguration(typeof(InteropComputeEnumFieldTest)) - } + }, + NameMapper = BinaryBasicNameMapper.SimpleNameInstance }, SpringConfigUrl = path }; http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml index d7f86f4..3774b51 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml @@ -62,16 +62,6 @@ </bean> </list> </property> - <property name="idMapper"> - <bean class="org.apache.ignite.binary.BinaryBasicIdMapper"> - <constructor-arg value="true"/> - </bean> - </property> - <property name="nameMapper"> - <bean class="org.apache.ignite.binary.BinaryBasicNameMapper"> - <constructor-arg value="true"/> - </bean> - </property> </bean> </property> http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml index 2804131..97ec97e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml @@ -35,14 +35,14 @@ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration"> <property name="types"> <list> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64]</value> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Type]</value> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64]]</value> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Collections.Generic.List[System.Tuple[System.Int64,System.String]]]</value> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String]</value> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,Apache.Ignite.Core.Tests.TestGenericBinarizable[System.String]]</value> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,System.Type]</value> - <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,System.Type]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`1[[System.Int64]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`1[[System.Type]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`1[[Apache.Ignite.Core.Tests.TestGenericBinarizable`1[[System.Int64]]]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`1[[System.Collections.Generic.List`1[[System.Tuple`2[[System.Int64],[System.String]]]]]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`2[[System.Int64],[System.String]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`2[[System.Int64],[Apache.Ignite.Core.Tests.TestGenericBinarizable`1[[System.String]]]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`3[[System.Int64],[System.String],[System.Type]]</value> + <value>Apache.Ignite.Core.Tests.TestGenericBinarizable`3[[System.Int64],[System.String],[Apache.Ignite.Core.Tests.TestGenericBinarizable`2[[System.Int64,System.String],[System.Type]]]]</value> </list> </property> </bean> http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml index 5fc973b..1bea206 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml @@ -42,7 +42,7 @@ <property name="queryEntities"> <list> <bean class="org.apache.ignite.cache.QueryEntity"> - <property name="valueType" value="BinarizableEntry"/> + <property name="valueType" value="Apache.Ignite.Core.Tests.Cache.Query.Continuous.ContinuousQueryAbstractTest+BinarizableEntry"/> <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> @@ -82,7 +82,7 @@ <property name="queryEntities"> <list> <bean class="org.apache.ignite.cache.QueryEntity"> - <property name="valueType" value="BinarizableEntry"/> + <property name="valueType" value="Apache.Ignite.Core.Tests.Cache.Query.Continuous.ContinuousQueryAbstractTest+BinarizableEntry"/> <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> @@ -121,7 +121,7 @@ <property name="queryEntities"> <list> <bean class="org.apache.ignite.cache.QueryEntity"> - <property name="valueType" value="BinarizableEntry"/> + <property name="valueType" value="Apache.Ignite.Core.Tests.Cache.Query.Continuous.ContinuousQueryAbstractTest+BinarizableEntry"/> <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> @@ -160,7 +160,7 @@ <property name="queryEntities"> <list> <bean class="org.apache.ignite.cache.QueryEntity"> - <property name="valueType" value="BinarizableEntry"/> + <property name="valueType" value="Apache.Ignite.Core.Tests.Cache.Query.Continuous.ContinuousQueryAbstractTest+BinarizableEntry"/> <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml index dd5d4d9..4f92c72 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml @@ -60,7 +60,7 @@ <property name="queryEntities"> <list> <bean class="org.apache.ignite.cache.QueryEntity"> - <property name="valueType" value="QueryPerson"/> + <property name="valueType" value="Apache.Ignite.Core.Tests.Cache.Query.QueryPerson"/> <property name="fields"> <util:map map-class="java.util.LinkedHashMap"> <entry key="age" value="int" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs index c4d4279..33c44a6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs @@ -677,6 +677,9 @@ namespace Apache.Ignite.Core.Tests.Services typeof (TestIgniteServiceBinarizableErr), typeof (PlatformComputeBinarizable), typeof (BinarizableObject)) + { + NameMapper = BinaryBasicNameMapper.SimpleNameInstance + } }; } http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj index 16e2552..a298f6f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj @@ -91,6 +91,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Binary\BinaryBasicNameMapper.cs" /> <Compile Include="Common\ExceptionFactory.cs" /> <Compile Include="Events\IEventStorageSpi.cs" /> <Compile Include="Events\MemoryEventStorageSpi.cs" /> @@ -191,6 +192,7 @@ <Compile Include="Impl\Binary\DeserializationCallbackProcessor.cs" /> <Compile Include="Impl\Binary\ReflectionUtils.cs" /> <Compile Include="Cache\Affinity\AffinityFunctionBase.cs" /> + <Compile Include="Impl\Binary\TypeNameParser.cs" /> <Compile Include="Impl\Cache\Store\CacheStore.cs" /> <Compile Include="Impl\Cache\Store\ICacheStoreInternal.cs" /> <Compile Include="Impl\Transactions\CacheTransactionManager.cs" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs new file mode 100644 index 0000000..0a6406b --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryBasicNameMapper.cs @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Binary +{ + using System; + using System.Text; + using Apache.Ignite.Core.Impl.Binary; + using Apache.Ignite.Core.Impl.Common; + + /// <summary> + /// Base binary name mapper implementation. + /// </summary> + public class BinaryBasicNameMapper : IBinaryNameMapper + { + /// <summary> + /// The simple name instance. + /// </summary> + internal static readonly BinaryBasicNameMapper SimpleNameInstance = new BinaryBasicNameMapper + { + IsSimpleName = true + }; + + /// <summary> + /// The full name instance. + /// </summary> + internal static readonly BinaryBasicNameMapper FullNameInstance = new BinaryBasicNameMapper(); + + /// <summary> + /// Gets or sets a value indicating whether this instance maps to simple type names. + /// </summary> + public bool IsSimpleName { get; set; } + + /// <summary> + /// Gets the type name. + /// </summary> + public string GetTypeName(string name) + { + IgniteArgumentCheck.NotNullOrEmpty(name, "typeName"); + + var parsedName = TypeNameParser.Parse(name); + + if (parsedName.Generics == null) + { + // Generics are rare, use simpler logic for the common case. + var res = IsSimpleName ? parsedName.GetName() : parsedName.GetFullName(); + + var arr = parsedName.GetArray(); + + if (arr != null) + { + res += arr; + } + + return res; + } + + var nameFunc = IsSimpleName + ? (Func<TypeNameParser, string>) (x => x.GetName()) + : (x => x.GetFullName()); + + return BuildTypeName(parsedName, new StringBuilder(), nameFunc).ToString(); + } + + /// <summary> + /// Gets the field name. + /// </summary> + public string GetFieldName(string name) + { + return name; + } + + /// <summary> + /// Builds the type name. + /// </summary> + private static StringBuilder BuildTypeName(TypeNameParser typeName, StringBuilder sb, + Func<TypeNameParser, string> typeNameFunc) + { + sb.Append(typeNameFunc(typeName)); + + var generics = typeName.Generics; + + if (generics != null) + { + sb.Append('['); + + var first = true; + + foreach (var genArg in generics) + { + if (first) + { + first = false; + } + else + { + sb.Append(','); + } + + sb.Append('['); + + BuildTypeName(genArg, sb, typeNameFunc); + + sb.Append(']'); + } + + sb.Append(']'); + } + + sb.Append(typeName.GetArray()); + + return sb; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs index b67f206..8aadf0e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs @@ -105,7 +105,7 @@ namespace Apache.Ignite.Core.Cache.Configuration KeyTypeName = value == null ? null - : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value)); + : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetSqlTypeName(value)); _keyType = value; } @@ -141,7 +141,7 @@ namespace Apache.Ignite.Core.Cache.Configuration ValueTypeName = value == null ? null - : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value)); + : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetSqlTypeName(value)); _valueType = value; } http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs index c33aa57..a1ebbd7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs @@ -89,7 +89,7 @@ namespace Apache.Ignite.Core.Cache.Configuration { FieldTypeName = value == null ? null - : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value)); + : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetSqlTypeName(value)); _type = value; } http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs index 24a4364..85c7548 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs @@ -272,6 +272,10 @@ namespace Apache.Ignite.Core { writer.WriteBoolean(false); } + + // Name mapper. + var mapper = BinaryConfiguration.NameMapper as BinaryBasicNameMapper; + writer.WriteBoolean(mapper != null && mapper.IsSimpleName); } else { @@ -430,7 +434,14 @@ namespace Apache.Ignite.Core BinaryConfiguration = BinaryConfiguration ?? new BinaryConfiguration(); if (r.ReadBoolean()) + { BinaryConfiguration.CompactFooter = r.ReadBoolean(); + } + + if (r.ReadBoolean()) + { + BinaryConfiguration.NameMapper = BinaryBasicNameMapper.SimpleNameInstance; + } } // User attributes http://git-wip-us.apache.org/repos/asf/ignite/blob/3e3b91a8/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs index fa7cf6c..4f3156c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs @@ -158,7 +158,7 @@ namespace Apache.Ignite.Core.Impl.Binary _marsh.PutBinaryType(desc); - return new BinaryEnum(GetTypeId(typeName), value, Marshaller); + return new BinaryEnum(desc.TypeId, value, Marshaller); } /** <inheritDoc /> */ @@ -166,8 +166,14 @@ namespace Apache.Ignite.Core.Impl.Binary { IgniteArgumentCheck.NotNull(type, "type"); IgniteArgumentCheck.Ensure(type.IsEnum, "type", "Type should be an Enum."); + + var desc = Marshaller.GetDescriptor(type); + + IgniteArgumentCheck.Ensure(desc.IsEnum, "typeName", "Type should be an Enum."); + + _marsh.PutBinaryType(desc); - return BuildEnum(type.Name, value); + return new BinaryEnum(desc.TypeId, value, Marshaller); } /// <summary>
