diff --git a/src/Nest/Resolvers/PropertyNameResolver.cs b/src/Nest/Resolvers/PropertyNameResolver.cs index 99a695cca53..08c246c1256 100644 --- a/src/Nest/Resolvers/PropertyNameResolver.cs +++ b/src/Nest/Resolvers/PropertyNameResolver.cs @@ -32,25 +32,12 @@ public static IElasticPropertyAttribute Property(MemberInfo info) return null; } - public static ElasticTypeAttribute Type() where T : class - { - return _Type(typeof(T)); - } - public static ElasticTypeAttribute Type(Type type) - { - return _Type(type); - } - - private static ElasticTypeAttribute _Type(Type type) { ElasticTypeAttribute attr = null; if (CachedTypeLookups.TryGetValue(type, out attr)) return attr; - if (!type.IsClass && !type.IsInterface) - throw new ArgumentException("Type is not a class or interface", "type"); - var attributes = type.GetCustomAttributes(typeof(ElasticTypeAttribute), true); if (attributes.HasAny()) attr = ((ElasticTypeAttribute)attributes.First()); diff --git a/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj b/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj index 4f278821972..64bc68a8699 100644 --- a/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj +++ b/src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj @@ -377,6 +377,7 @@ + diff --git a/src/Tests/Nest.Tests.Unit/Reproduce/Reproduce926Tests.cs b/src/Tests/Nest.Tests.Unit/Reproduce/Reproduce926Tests.cs new file mode 100644 index 00000000000..4f569bc35a8 --- /dev/null +++ b/src/Tests/Nest.Tests.Unit/Reproduce/Reproduce926Tests.cs @@ -0,0 +1,39 @@ +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Nest.Tests.Unit.Reproduce +{ + class SomeClass + { + public SomeClass() + { + this.Data = new Dictionary(); + } + + public long ID { get; set; } + + [ElasticProperty(Type = FieldType.Object)] + public Dictionary Data { get; set; } + } + + class SomeOtherClass + { + public string Value1 { get; set; } + public string Value2 { get; set; } + } + + [TestFixture] + public class Reproduce926Tests : BaseJsonTests + { + [Test] + public void ObjectMappingOnDictionaryCausesArgumentException() + { + var mapResult = this._client.Map(m => m + .MapFromAttributes()); + } + } +}