Skip to content

Refactor/expressionvisitor #1765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from 4 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
114 changes: 99 additions & 15 deletions src/Benchmarking/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@
"frameworkAssemblies": [
"System.Diagnostics.Tools",
"System.IO.Compression.FileSystem",
"System.Linq",
"System.Reflection",
"System.Runtime",
"System.Threading.Tasks"
Expand Down Expand Up @@ -1032,6 +1033,7 @@
"System.Diagnostics.Tools": "4.0.1-beta-23225",
"System.Dynamic.Runtime": "4.0.11-beta-23516",
"System.Linq": "4.0.0-beta-23109",
"System.Linq.Expressions": "4.0.11-beta-23516",
"System.Linq.Queryable": "4.0.0-beta-23109",
"System.Runtime": "4.0.21-beta-23225",
"System.Threading": "4.0.11-beta-23225",
Expand Down Expand Up @@ -2716,6 +2718,7 @@
"frameworkAssemblies": [
"System.Diagnostics.Tools",
"System.IO.Compression.FileSystem",
"System.Linq",
"System.Reflection",
"System.Runtime",
"System.Threading.Tasks"
Expand Down Expand Up @@ -3337,6 +3340,7 @@
"frameworkAssemblies": [
"System.Diagnostics.Tools",
"System.IO.Compression.FileSystem",
"System.Linq",
"System.Reflection",
"System.Runtime",
"System.Threading.Tasks"
Expand Down Expand Up @@ -3879,6 +3883,7 @@
"System.Diagnostics.Tools": "4.0.1-beta-23225",
"System.Dynamic.Runtime": "4.0.11-beta-23516",
"System.Linq": "4.0.0-beta-23109",
"System.Linq.Expressions": "4.0.11-beta-23516",
"System.Linq.Queryable": "4.0.0-beta-23109",
"System.Runtime": "4.0.21-beta-23225",
"System.Threading": "4.0.11-beta-23225",
Expand All @@ -3894,6 +3899,34 @@
"lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll": {}
}
},
"runtime.any.System.Linq.Expressions/4.0.11-beta-23516": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Globalization": "4.0.10",
"System.IO": "4.0.10",
"System.Linq": "4.0.0",
"System.ObjectModel": "4.0.10",
"System.Reflection": "4.0.10",
"System.Reflection.Emit": "4.0.0",
"System.Reflection.Emit.ILGeneration": "4.0.0",
"System.Reflection.Emit.Lightweight": "4.0.0",
"System.Reflection.Extensions": "4.0.0",
"System.Reflection.Primitives": "4.0.0",
"System.Reflection.TypeExtensions": "4.0.0",
"System.Resources.ResourceManager": "4.0.0",
"System.Runtime": "4.0.20",
"System.Runtime.Extensions": "4.0.10",
"System.Threading": "4.0.10"
},
"compile": {
"ref/dotnet/_._": {}
},
"runtime": {
"lib/DNXCore50/System.Linq.Expressions.dll": {}
}
},
"runtime.win7.System.Console/4.0.0-beta-23516": {
"type": "package",
"dependencies": {
Expand Down Expand Up @@ -4699,13 +4732,13 @@
"lib/DNXCore50/System.Reflection.Emit.ILGeneration.dll": {}
}
},
"System.Reflection.Emit.Lightweight/4.0.0-beta-23109": {
"System.Reflection.Emit.Lightweight/4.0.0": {
"type": "package",
"dependencies": {
"System.Reflection": "4.0.0-beta-23109",
"System.Reflection.Emit.ILGeneration": "4.0.0-beta-23109",
"System.Reflection.Primitives": "4.0.0-beta-23109",
"System.Runtime": "4.0.0-beta-23109"
"System.Reflection": "4.0.0",
"System.Reflection.Emit.ILGeneration": "4.0.0",
"System.Reflection.Primitives": "4.0.0",
"System.Runtime": "4.0.0"
},
"compile": {
"ref/dotnet/System.Reflection.Emit.Lightweight.dll": {}
Expand Down Expand Up @@ -5752,6 +5785,7 @@
"System.Diagnostics.Tools": "4.0.1-beta-23225",
"System.Dynamic.Runtime": "4.0.11-beta-23516",
"System.Linq": "4.0.0-beta-23109",
"System.Linq.Expressions": "4.0.11-beta-23516",
"System.Linq.Queryable": "4.0.0-beta-23109",
"System.Runtime": "4.0.21-beta-23225",
"System.Threading": "4.0.11-beta-23225",
Expand All @@ -5767,6 +5801,34 @@
"lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll": {}
}
},
"runtime.any.System.Linq.Expressions/4.0.11-beta-23516": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Globalization": "4.0.10",
"System.IO": "4.0.10",
"System.Linq": "4.0.0",
"System.ObjectModel": "4.0.10",
"System.Reflection": "4.0.10",
"System.Reflection.Emit": "4.0.0",
"System.Reflection.Emit.ILGeneration": "4.0.0",
"System.Reflection.Emit.Lightweight": "4.0.0",
"System.Reflection.Extensions": "4.0.0",
"System.Reflection.Primitives": "4.0.0",
"System.Reflection.TypeExtensions": "4.0.0",
"System.Resources.ResourceManager": "4.0.0",
"System.Runtime": "4.0.20",
"System.Runtime.Extensions": "4.0.10",
"System.Threading": "4.0.10"
},
"compile": {
"ref/dotnet/_._": {}
},
"runtime": {
"lib/DNXCore50/System.Linq.Expressions.dll": {}
}
},
"runtime.win7.System.Console/4.0.0-beta-23516": {
"type": "package",
"dependencies": {
Expand Down Expand Up @@ -6572,13 +6634,13 @@
"lib/DNXCore50/System.Reflection.Emit.ILGeneration.dll": {}
}
},
"System.Reflection.Emit.Lightweight/4.0.0-beta-23109": {
"System.Reflection.Emit.Lightweight/4.0.0": {
"type": "package",
"dependencies": {
"System.Reflection": "4.0.0-beta-23109",
"System.Reflection.Emit.ILGeneration": "4.0.0-beta-23109",
"System.Reflection.Primitives": "4.0.0-beta-23109",
"System.Runtime": "4.0.0-beta-23109"
"System.Reflection": "4.0.0",
"System.Reflection.Emit.ILGeneration": "4.0.0",
"System.Reflection.Primitives": "4.0.0",
"System.Runtime": "4.0.0"
},
"compile": {
"ref/dotnet/System.Reflection.Emit.Lightweight.dll": {}
Expand Down Expand Up @@ -7633,6 +7695,28 @@
"tools/install.ps1"
]
},
"runtime.any.System.Linq.Expressions/4.0.11-beta-23516": {
"type": "package",
"serviceable": true,
"sha512": "4sPxQCjllMJ1uZNlwz/EataPyHSH+AqSDlOIPPqcy/88R2B+abfhPPC78rd7gvHp8KmMX4qbJF6lcCeDIQpmVg==",
"files": [
"lib/DNXCore50/System.Linq.Expressions.dll",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net45/_._",
"lib/netcore50/System.Linq.Expressions.dll",
"lib/win8/_._",
"lib/wp80/_._",
"lib/wpa81/_._",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"ref/dotnet/_._",
"runtime.any.System.Linq.Expressions.4.0.11-beta-23516.nupkg",
"runtime.any.System.Linq.Expressions.4.0.11-beta-23516.nupkg.sha512",
"runtime.any.System.Linq.Expressions.nuspec",
"runtimes/aot/lib/netcore50/_._"
]
},
"runtime.win7.System.Console/4.0.0-beta-23516": {
"type": "package",
"serviceable": true,
Expand Down Expand Up @@ -7727,7 +7811,7 @@
"runtime.win7.System.Net.Requests/4.0.11-beta-23516": {
"type": "package",
"serviceable": true,
"sha512": "mqWBQUhXhzkiwb+zVUuKg+wswJUsnQtZkFtz6eISw8vWNXA9i2jkzYjU3pjjIVmtdopnhle9YaS4a/w4OuWGLw==",
"sha512": "HI99nCEekL4SNvkLmpqkOE0PuEF5B6xyDcnJesdjo06BrGYH3QCvqJt2VmzBVe6hDSo6FnGOlhMvLdCUpDXiXA==",
"files": [
"ref/dotnet/_._",
"runtime.win7.System.Net.Requests.4.0.11-beta-23516.nupkg",
Expand Down Expand Up @@ -9523,9 +9607,9 @@
"System.Reflection.Emit.ILGeneration.nuspec"
]
},
"System.Reflection.Emit.Lightweight/4.0.0-beta-23109": {
"System.Reflection.Emit.Lightweight/4.0.0": {
"type": "package",
"sha512": "Kbg03ijw7jZUswutleX/zmGgz6VYszTuyy4DciBn1PHFYAqAgZFZdK3cpYCsAU+cPliQ35UcOX828OsAG9NU4w==",
"sha512": "DJZhHiOdkN08xJgsJfDjkuOreLLmMcU8qkEEqEHqyhkPUZMMQs0lE8R+6+68BAFWgcdzxtNu0YmIOtEug8j00w==",
"files": [
"lib/DNXCore50/System.Reflection.Emit.Lightweight.dll",
"lib/net45/_._",
Expand All @@ -9544,8 +9628,8 @@
"ref/dotnet/zh-hant/System.Reflection.Emit.Lightweight.xml",
"ref/net45/_._",
"ref/wp80/_._",
"System.Reflection.Emit.Lightweight.4.0.0-beta-23109.nupkg",
"System.Reflection.Emit.Lightweight.4.0.0-beta-23109.nupkg.sha512",
"System.Reflection.Emit.Lightweight.4.0.0.nupkg",
"System.Reflection.Emit.Lightweight.4.0.0.nupkg.sha512",
"System.Reflection.Emit.Lightweight.nuspec"
]
},
Expand Down
6 changes: 3 additions & 3 deletions src/Elasticsearch.Net/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@
"runtime.win7.System.Net.Requests/4.0.11-beta-23516": {
"type": "package",
"serviceable": true,
"sha512": "mqWBQUhXhzkiwb+zVUuKg+wswJUsnQtZkFtz6eISw8vWNXA9i2jkzYjU3pjjIVmtdopnhle9YaS4a/w4OuWGLw==",
"sha512": "HI99nCEekL4SNvkLmpqkOE0PuEF5B6xyDcnJesdjo06BrGYH3QCvqJt2VmzBVe6hDSo6FnGOlhMvLdCUpDXiXA==",
"files": [
"ref/dotnet/_._",
"runtime.win7.System.Net.Requests.4.0.11-beta-23516.nupkg",
Expand Down Expand Up @@ -3109,9 +3109,9 @@
"projectFileDependencyGroups": {
"": [],
".NETFramework,Version=v4.5": [
"fx/System ",
"fx/System.Runtime ",
"fx/System.Runtime.Serialization ",
"fx/System "
"fx/System.Runtime.Serialization "
],
".NETPlatform,Version=v5.1": [
"Microsoft.CSharp >= 4.0.1-beta-23225",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public TConnectionSettings MapIdPropertyFor<TDocument>(Expression<Func<TDocument
{
objectPath.ThrowIfNull(nameof(objectPath));

var memberInfo = new MemberInfoResolver(this, objectPath);
var memberInfo = new MemberInfoResolver(objectPath);
var fieldName = memberInfo.Members.Single().Name;

if (this._idProperties.ContainsKey(typeof(TDocument)))
Expand Down Expand Up @@ -190,7 +190,7 @@ private void ApplyPropertyMappings<TDocument>(IList<IClrTypePropertyMapping<TDoc
foreach (var mapping in mappings)
{
var e = mapping.Property;
var memberInfoResolver = new MemberInfoResolver(this, e);
var memberInfoResolver = new MemberInfoResolver(e);
if (memberInfoResolver.Members.Count > 1)
throw new ArgumentException("MapFieldNameFor can only map direct properties");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ namespace Nest
/// <summary>
/// Resolves member infos in an expression, instance may NOT be shared.
/// </summary>
public class MemberInfoResolver : FieldResolver
public class MemberInfoResolver : ExpressionVisitor
{
private readonly IList<MemberInfo> _members = new List<MemberInfo>();
public IList<MemberInfo> Members { get { return _members; } }

public MemberInfoResolver(IConnectionSettingsValues settings, Expression expression) : base(settings)
public MemberInfoResolver(Expression expression)
{
var stack = new Stack<string>();
var properties = new Stack<ElasticsearchPropertyAttribute>();
base.Visit(expression, stack, properties);
base.Visit(expression);
}

protected override Expression VisitMemberAccess(MemberExpression expression, Stack<string> stack, Stack<ElasticsearchPropertyAttribute> properties)
protected override Expression VisitMember(MemberExpression expression)
{
this._members.Add(expression.Member);
return base.VisitMemberAccess(expression, stack, properties);
return base.VisitMember(expression);
}
}
}
Loading