Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/Nest/Resolvers/PropertyNameResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,12 @@ public static IElasticPropertyAttribute Property(MemberInfo info)
return null;
}

public static ElasticTypeAttribute Type<T>() 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());
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
<Compile Include="Reproduce\Reproduce860Tests.cs" />
<Compile Include="Reproduce\Reproduce806Tests.cs" />
<Compile Include="Reproduce\Reproduce876Tests.cs" />
<Compile Include="Reproduce\Reproduce926Tests.cs" />
<Compile Include="Search\Fields\FieldsTests.cs" />
<Compile Include="Search\Filter\Modes\ConditionlessFilterJson.cs" />
<Compile Include="Search\Filter\Modes\FilterModesTests.cs" />
Expand Down
39 changes: 39 additions & 0 deletions src/Tests/Nest.Tests.Unit/Reproduce/Reproduce926Tests.cs
Original file line number Diff line number Diff line change
@@ -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<long, SomeOtherClass>();
}

public long ID { get; set; }

[ElasticProperty(Type = FieldType.Object)]
public Dictionary<long, SomeOtherClass> 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<SomeClass>(m => m
.MapFromAttributes());
}
}
}