Skip to content

Commit 1e8f89f

Browse files
committed
Merge pull request #8 from yyjdelete/patch-1
Remove useless dependences
2 parents 17f7c9d + d19a440 commit 1e8f89f

File tree

4 files changed

+104
-131
lines changed

4 files changed

+104
-131
lines changed

src/System.Linq.Dynamic.Core/ExpressionParser.cs

+71-29
Original file line numberDiff line numberDiff line change
@@ -205,32 +205,29 @@ interface IEnumerableSignatures
205205
{ "bool", typeof(bool) },
206206
{ "float", typeof(float) },
207207
};
208-
static readonly HashSet<Type> _predefinedTypes = new HashSet<Type>() {
209-
typeof(object),
210-
typeof(bool),
211-
typeof(char),
212-
typeof(string),
213-
typeof(sbyte),
214-
typeof(byte),
215-
typeof(short),
216-
typeof(ushort),
217-
typeof(int),
218-
typeof(uint),
219-
typeof(long),
220-
typeof(ulong),
221-
typeof(float),
222-
typeof(double),
223-
typeof(decimal),
224-
typeof(DateTime),
225-
typeof(DateTimeOffset),
226-
typeof(TimeSpan),
227-
typeof(Guid),
228-
typeof(Math),
229-
typeof(Convert),
230-
typeof(Uri),
231-
#if !(NET35 || SILVERLIGHT || NETFX_CORE || DNXCORE50 || DOTNET5_4 || NETSTANDARD)
232-
typeof(Data.Objects.EntityFunctions)
233-
#endif
208+
static readonly Dictionary<Type, int> _predefinedTypes = new Dictionary<Type, int>() {
209+
{ typeof(object), 0 },
210+
{ typeof(bool), 0 },
211+
{ typeof(char), 0 },
212+
{ typeof(string), 0 },
213+
{ typeof(sbyte), 0 },
214+
{ typeof(byte), 0 },
215+
{ typeof(short), 0 },
216+
{ typeof(ushort), 0 },
217+
{ typeof(int), 0 },
218+
{ typeof(uint), 0 },
219+
{ typeof(long), 0 },
220+
{ typeof(ulong), 0 },
221+
{ typeof(float), 0 },
222+
{ typeof(double), 0 },
223+
{ typeof(decimal), 0 },
224+
{ typeof(DateTime), 0 },
225+
{ typeof(DateTimeOffset), 0 },
226+
{ typeof(TimeSpan), 0 },
227+
{ typeof(Guid), 0 },
228+
{ typeof(Math), 0 },
229+
{ typeof(Convert), 0 },
230+
{ typeof(Uri), 0 }
234231
};
235232

236233
// These aliases are supposed to simply the where clause and make it more human readable
@@ -279,6 +276,43 @@ interface IEnumerableSignatures
279276
char _ch;
280277
Token _token;
281278

279+
static ExpressionParser()
280+
{
281+
#if !(NET35 || SILVERLIGHT || NETFX_CORE || DNXCORE50 || DOTNET5_4 || NETSTANDARD)
282+
try
283+
{
284+
//System.Data.Entity is always here, so overwrite short name of it with EntityFramework if EntityFramework is found.
285+
Type efType;
286+
//EF5(or 4.x??), System.Data.Objects.DataClasses.EdmFunctionAttribute
287+
//There is also an System.Data.Entity, Version=3.5.0.0, but no Functions.
288+
efType = Type.GetType("System.Data.Objects.EntityFunctions, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
289+
if (efType != null)
290+
_predefinedTypes.Add(efType, 1);
291+
efType = Type.GetType("System.Data.Objects.SqlClient.SqlFunctions, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
292+
if (efType != null)
293+
_predefinedTypes.Add(efType, 1);
294+
efType = Type.GetType("System.Data.Objects.SqlClient.SqlSpatialFunctions, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
295+
if (efType != null)
296+
_predefinedTypes.Add(efType, 1);
297+
298+
//EF6,System.Data.Entity.DbFunctionAttribute
299+
efType = Type.GetType("System.Data.Entity.Core.Objects.EntityFunctions, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
300+
if (efType != null)
301+
_predefinedTypes.Add(efType, 2);
302+
efType = Type.GetType("System.Data.Entity.DbFunctions, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
303+
if (efType != null)
304+
_predefinedTypes.Add(efType, 2);
305+
efType = Type.GetType("System.Data.Entity.SqlServer.SqlFunctions, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
306+
if (efType != null)
307+
_predefinedTypes.Add(efType, 2);
308+
efType = Type.GetType("System.Data.Entity.SqlServer.SqlSpatialFunctions, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
309+
if (efType != null)
310+
_predefinedTypes.Add(efType, 2);
311+
}
312+
catch { }
313+
#endif
314+
}
315+
282316
public ExpressionParser(ParameterExpression[] parameters, string expression, object[] values)
283317
{
284318
if (_keywords == null) _keywords = CreateKeywords();
@@ -1326,7 +1360,7 @@ Expression ParseElementAccess(Expression expr)
13261360

13271361
static bool IsPredefinedType(Type type)
13281362
{
1329-
if (_predefinedTypes.Contains(type)) return true;
1363+
if (_predefinedTypes.ContainsKey(type)) return true;
13301364
if (GlobalConfig.CustomTypeProvider.GetCustomTypes().Contains(type)) return true;
13311365

13321366
return false;
@@ -2468,9 +2502,17 @@ static Dictionary<string, object> CreateKeywords()
24682502
d.Add(KEYWORD_IIF, KEYWORD_IIF);
24692503
d.Add(KEYWORD_NEW, KEYWORD_NEW);
24702504

2471-
foreach (Type type in _predefinedTypes) d.Add(type.Name, type);
2505+
foreach (Type type in _predefinedTypes.OrderBy(kvp => kvp.Value).Select(kvp => kvp.Key))
2506+
{
2507+
d[type.FullName] = type;
2508+
d[type.Name] = type;
2509+
}
24722510
foreach (KeyValuePair<string, Type> pair in _predefinedTypesShorthands) d.Add(pair.Key, pair.Value);
2473-
foreach (Type type in GlobalConfig.CustomTypeProvider.GetCustomTypes()) d.Add(type.Name, type);
2511+
foreach (Type type in GlobalConfig.CustomTypeProvider.GetCustomTypes())
2512+
{
2513+
d[type.FullName] = type;
2514+
d[type.Name] = type;
2515+
}
24742516

24752517
return d;
24762518
}

src/System.Linq.Dynamic.Core/GroupResult.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class GroupResult
3838
/// </summary>
3939
public override string ToString()
4040
{
41-
return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", Key, Count);
41+
return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", ((object)Key).ToString(), Count);
4242
}
4343
}
4444
}

src/System.Linq.Dynamic.Core/project.json

+19-88
Original file line numberDiff line numberDiff line change
@@ -13,145 +13,76 @@
1313
"compilationOptions": {
1414
},
1515

16+
"dependencies": {
17+
"JetBrains.Annotations": {
18+
"version": "10.1.4",
19+
"type": "build"
20+
}
21+
},
22+
1623
"frameworks": {
1724
"net35": {
1825
"frameworkAssemblies": {
1926
},
2027
"dependencies": {
21-
"JetBrains.Annotations": "10.1.4",
2228
"NetLegacySupport.ConcurrentDictionary": "1.1.0"
2329
}
2430
},
2531
"net40": {
26-
"dependencies": {
27-
"JetBrains.Annotations": "10.1.4"
28-
},
2932
"frameworkAssemblies": {
30-
"System.Data.Entity": ""
3133
}
3234
},
3335
"net45": {
34-
"dependencies": {
35-
"JetBrains.Annotations": "10.1.4"
36-
},
3736
"frameworkAssemblies": {
38-
"System.Data.Entity": ""
3937
}
4038
},
4139
"net451": {
42-
"dependencies": {
43-
"JetBrains.Annotations": "10.1.4"
44-
},
4540
"frameworkAssemblies": {
46-
"System.Data.Entity": ""
4741
}
4842
},
4943
"net452": {
50-
"dependencies": {
51-
"JetBrains.Annotations": "10.1.4"
52-
},
5344
"frameworkAssemblies": {
54-
"System.Data.Entity": ""
5545
}
5646
},
5747
"net461": {
58-
"dependencies": {
59-
"JetBrains.Annotations": "10.1.4"
60-
},
6148
"frameworkAssemblies": {
62-
"System.Data.Entity": ""
6349
}
6450
},
6551
"dnx451": {
66-
"dependencies": {
67-
"JetBrains.Annotations": "10.1.4"
68-
},
6952
"frameworkAssemblies": {
70-
"System.Data.Entity": ""
7153
}
7254
},
7355
"dnx452": {
74-
"dependencies": {
75-
"JetBrains.Annotations": "10.1.4"
76-
},
7756
"frameworkAssemblies": {
78-
"System.Data.Entity": ""
7957
}
8058
},
8159
"dnxcore5": {
8260
"dependencies": {
83-
"JetBrains.Annotations": "10.1.4",
84-
85-
"Microsoft.CSharp": "4.0.1-beta-*",
86-
87-
"System.Collections.Concurrent": "4.0.11-beta-*",
88-
8961
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final",
90-
91-
"System.Runtime.Extensions": "4.0.11-beta-*",
92-
"System.Runtime.InteropServices": "4.0.21-beta-*",
93-
"System.Runtime.Loader": "4.0.0-beta-*",
94-
95-
"System.Runtime.Serialization.Primitives": "4.1.0-beta-*",
96-
"System.Runtime.Serialization.Xml": "4.1.0-beta-*",
97-
98-
"System.Reflection.Primitives": "4.0.1-beta-*",
99-
"System.Reflection.TypeExtensions": "4.1.0-beta-*",
100-
"System.Reflection.Emit": "4.0.1-beta-*",
101-
102-
"System.Linq": "4.0.1-beta-*",
103-
"System.Linq.Expressions": "4.0.11-beta-*",
104-
"System.Linq.Queryable": "4.0.1-beta-*",
105-
106-
"System.Globalization": "4.0.11-beta-*",
107-
108-
"System.Diagnostics.Debug": "4.0.11-beta-*",
109-
"System.Diagnostics.Tools": "4.0.1-beta-*",
110-
"System.Diagnostics.Tracing": "4.0.21-beta-*",
111-
112-
"System.Threading": "4.0.11-beta-*"
62+
"System.Collections.Concurrent": "4.0.11-*",
63+
"System.Dynamic.Runtime": "4.0.11-*",
64+
"System.Reflection.Emit": "4.0.1-*",
65+
"System.Reflection.TypeExtensions": "4.1.0-*",
66+
"System.Linq.Expressions": "4.0.11-*",
67+
"System.Linq.Queryable": "4.0.1-*"
11368
}
11469
},
11570
"dotnet54": {
11671
"dependencies": {
117-
"JetBrains.Annotations": "10.1.4",
118-
119-
"Microsoft.CSharp": "4.0.1-beta-*",
120-
121-
"System.Collections.Concurrent": "4.0.11-beta-*",
122-
12372
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final",
124-
125-
"System.Runtime.Extensions": "4.0.11-beta-*",
126-
"System.Runtime.InteropServices": "4.0.21-beta-*",
127-
"System.Runtime.Loader": "4.0.0-beta-*",
128-
129-
"System.Runtime.Serialization.Primitives": "4.1.0-beta-*",
130-
"System.Runtime.Serialization.Xml": "4.1.0-beta-*",
131-
132-
"System.Reflection.Primitives": "4.0.1-beta-*",
133-
"System.Reflection.TypeExtensions": "4.1.0-beta-*",
134-
"System.Reflection.Emit": "4.0.1-beta-*",
135-
136-
"System.Linq": "4.0.1-beta-*",
137-
"System.Linq.Expressions": "4.0.11-beta-*",
138-
"System.Linq.Queryable": "4.0.1-beta-*",
139-
140-
"System.Globalization": "4.0.11-beta-*",
141-
142-
"System.Diagnostics.Debug": "4.0.11-beta-*",
143-
"System.Diagnostics.Tools": "4.0.1-beta-*",
144-
"System.Diagnostics.Tracing": "4.0.21-beta-*",
145-
146-
"System.Threading": "4.0.11-beta-*"
73+
"System.Collections.Concurrent": "4.0.11-*",
74+
"System.Dynamic.Runtime": "4.0.11-*",
75+
"System.Reflection.Emit": "4.0.1-*",
76+
"System.Reflection.TypeExtensions": "4.1.0-*",
77+
"System.Linq.Expressions": "4.0.11-*",
78+
"System.Linq.Queryable": "4.0.1-*"
14779
}
14880
},
14981
"sl5": {
15082
"compilationOptions": {
15183
"define": [ "SILVERLIGHT" ]
15284
},
15385
"dependencies": {
154-
"JetBrains.Annotations": "10.1.4",
15586
"Portable.ConcurrentDictionary": "1.0.1"
15687
},
15788
"frameworkAssemblies": {

web/DynamicLinqWebDocs/DynamicLinqWebDocs.csproj

+13-13
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@
4343
<ItemGroup>
4444
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
4545
<SpecificVersion>False</SpecificVersion>
46-
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
46+
<HintPath>..\..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
4747
</Reference>
4848
<Reference Include="MarkdownSharp">
49-
<HintPath>..\packages\MarkdownSharp.1.13.0.0\lib\35\MarkdownSharp.dll</HintPath>
49+
<HintPath>..\..\packages\MarkdownSharp.1.13.0.0\lib\35\MarkdownSharp.dll</HintPath>
5050
</Reference>
5151
<Reference Include="Microsoft.CSharp" />
5252
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
53-
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
53+
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
5454
<Private>True</Private>
5555
</Reference>
5656
<Reference Include="SimpleMvcSitemap, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL">
57-
<HintPath>..\packages\SimpleMvcSitemap.2.3.1\lib\net45\SimpleMvcSitemap.dll</HintPath>
57+
<HintPath>..\..\packages\SimpleMvcSitemap.2.3.1\lib\net45\SimpleMvcSitemap.dll</HintPath>
5858
<Private>True</Private>
5959
</Reference>
6060
<Reference Include="System" />
@@ -68,34 +68,34 @@
6868
<Reference Include="System.ComponentModel.DataAnnotations" />
6969
<Reference Include="System.Web.Extensions" />
7070
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
71-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
71+
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
7272
<Private>True</Private>
7373
</Reference>
7474
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
75-
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
75+
<HintPath>..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
7676
<Private>True</Private>
7777
</Reference>
7878
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7979
<SpecificVersion>False</SpecificVersion>
80-
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
80+
<HintPath>..\..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
8181
</Reference>
8282
<Reference Include="System.Web" />
8383
<Reference Include="System.Web.Abstractions" />
8484
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
85-
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
85+
<HintPath>..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
8686
<Private>True</Private>
8787
</Reference>
8888
<Reference Include="System.Web.Routing" />
8989
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
90-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
90+
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
9191
<Private>True</Private>
9292
</Reference>
9393
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
94-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
94+
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
9595
<Private>True</Private>
9696
</Reference>
9797
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
98-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
98+
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
9999
<Private>True</Private>
100100
</Reference>
101101
<Reference Include="System.Xml" />
@@ -104,7 +104,7 @@
104104
<Reference Include="System.EnterpriseServices" />
105105
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
106106
<Private>True</Private>
107-
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
107+
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
108108
</Reference>
109109
<Reference Include="System.Net.Http">
110110
</Reference>
@@ -113,7 +113,7 @@
113113
<Reference Include="System.Xml.Linq" />
114114
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115115
<SpecificVersion>False</SpecificVersion>
116-
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
116+
<HintPath>..\..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
117117
</Reference>
118118
</ItemGroup>
119119
<ItemGroup />

0 commit comments

Comments
 (0)