Skip to content

Commit 8325fb9

Browse files
authored
Merge pull request #18 from agileobjects/Net35Support
Net35 support
2 parents 5671c8b + bab0f2d commit 8325fb9

File tree

84 files changed

+2632
-1069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2632
-1069
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{9EB2525F-48E7-4057-98E5-7FE325ECCD32}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AgileObjects.ReadableExpressions.UnitTests.Net35</RootNamespace>
11+
<AssemblyName>AgileObjects.ReadableExpressions.UnitTests.Net35</AssemblyName>
12+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>TRACE;DEBUG;NET35</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE;NET35</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="AgileObjects.NetStandardPolyfills, Version=1.4.0.0, Culture=neutral, PublicKeyToken=06131ac1c008ad4e, processorArchitecture=MSIL">
34+
<HintPath>..\packages\AgileObjects.NetStandardPolyfills.1.4.0\lib\net35\AgileObjects.NetStandardPolyfills.dll</HintPath>
35+
</Reference>
36+
<Reference Include="Microsoft.Dynamic, Version=1.1.2.22, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
37+
<HintPath>..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Dynamic.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Microsoft.Scripting, Version=1.1.2.22, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
40+
<HintPath>..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Microsoft.Scripting.AspNet, Version=1.1.1.21, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
43+
<HintPath>..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.AspNet.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Microsoft.Scripting.Core, Version=1.1.2.22, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
46+
<HintPath>..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.Core.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Microsoft.Scripting.Metadata, Version=1.1.2.22, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
49+
<HintPath>..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.Metadata.dll</HintPath>
50+
</Reference>
51+
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
52+
<HintPath>..\packages\NUnit.3.6.1\lib\net35\nunit.framework.dll</HintPath>
53+
</Reference>
54+
<Reference Include="System" />
55+
<Reference Include="System.Core" />
56+
<Reference Include="System.Xml.Linq" />
57+
<Reference Include="System.Data.DataSetExtensions" />
58+
<Reference Include="System.Data" />
59+
<Reference Include="System.Xml" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="..\CommonAssemblyInfo.cs">
63+
<Link>Properties\CommonAssemblyInfo.cs</Link>
64+
</Compile>
65+
</ItemGroup>
66+
<ItemGroup>
67+
<Compile Include="..\ReadableExpressions.UnitTests\Extensions\WhenGettingAParentExpressionNode.cs">
68+
<Link>Extensions\WhenGettingAParentExpressionNode.cs</Link>
69+
</Compile>
70+
<Compile Include="..\ReadableExpressions.UnitTests\Extensions\WhenGettingFriendlyNames.cs">
71+
<Link>Extensions\WhenGettingFriendlyNames.cs</Link>
72+
</Compile>
73+
<Compile Include="..\ReadableExpressions.UnitTests\Properties\AssemblyInfo.cs">
74+
<Link>Properties\AssemblyInfo.cs</Link>
75+
</Compile>
76+
<Compile Include="..\ReadableExpressions.UnitTests\ShouldExtensions.cs">
77+
<Link>ShouldExtensions.cs</Link>
78+
</Compile>
79+
<Compile Include="..\ReadableExpressions.UnitTests\TestClassBase.cs">
80+
<Link>TestClassBase.cs</Link>
81+
</Compile>
82+
<Compile Include="..\ReadableExpressions.UnitTests\WhenFormattingCode.cs">
83+
<Link>WhenFormattingCode.cs</Link>
84+
</Compile>
85+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingAssignments.cs">
86+
<Link>WhenTranslatingAssignments.cs</Link>
87+
</Compile>
88+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingBlocks.cs">
89+
<Link>WhenTranslatingBlocks.cs</Link>
90+
</Compile>
91+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingComments.cs">
92+
<Link>WhenTranslatingComments.cs</Link>
93+
</Compile>
94+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingComparisons.cs">
95+
<Link>WhenTranslatingComparisons.cs</Link>
96+
</Compile>
97+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingConditionals.cs">
98+
<Link>WhenTranslatingConditionals.cs</Link>
99+
</Compile>
100+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingConstants.cs">
101+
<Link>WhenTranslatingConstants.cs</Link>
102+
</Compile>
103+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingConversions.cs">
104+
<Link>WhenTranslatingConversions.cs</Link>
105+
</Compile>
106+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingDebugInfo.cs">
107+
<Link>WhenTranslatingDebugInfo.cs</Link>
108+
</Compile>
109+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingDynamicOperations.cs">
110+
<Link>WhenTranslatingDynamicOperations.cs</Link>
111+
</Compile>
112+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingGotos.cs">
113+
<Link>WhenTranslatingGotos.cs</Link>
114+
</Compile>
115+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingLambdas.cs">
116+
<Link>WhenTranslatingLambdas.cs</Link>
117+
</Compile>
118+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingLanguageKeywords.cs">
119+
<Link>WhenTranslatingLanguageKeywords.cs</Link>
120+
</Compile>
121+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingLogicalOperations.cs">
122+
<Link>WhenTranslatingLogicalOperations.cs</Link>
123+
</Compile>
124+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingLoops.cs">
125+
<Link>WhenTranslatingLoops.cs</Link>
126+
</Compile>
127+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingMathsOperations.cs">
128+
<Link>WhenTranslatingMathsOperations.cs</Link>
129+
</Compile>
130+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingMemberAccesses.cs">
131+
<Link>WhenTranslatingMemberAccesses.cs</Link>
132+
</Compile>
133+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingObjectCreations.cs">
134+
<Link>WhenTranslatingObjectCreations.cs</Link>
135+
</Compile>
136+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingStringConcatenation.cs">
137+
<Link>WhenTranslatingStringConcatenation.cs</Link>
138+
</Compile>
139+
<Compile Include="..\ReadableExpressions.UnitTests\WhenTranslatingTryCatchFinallys.cs">
140+
<Link>WhenTranslatingTryCatchFinallys.cs</Link>
141+
</Compile>
142+
<Compile Include="..\ReadableExpressions.UnitTests\WhenUsingPartialTrust.cs">
143+
<Link>WhenUsingPartialTrust.cs</Link>
144+
</Compile>
145+
</ItemGroup>
146+
<ItemGroup>
147+
<None Include="packages.config" />
148+
</ItemGroup>
149+
<ItemGroup>
150+
<ProjectReference Include="..\ReadableExpressions\ReadableExpressions.csproj">
151+
<Project>{147ddcce-cdd3-4dd0-8ba3-d3f2f239e161}</Project>
152+
<Name>ReadableExpressions</Name>
153+
</ProjectReference>
154+
</ItemGroup>
155+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
156+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="AgileObjects.NetStandardPolyfills" version="1.4.0" targetFramework="net35" />
4+
<package id="DynamicLanguageRuntime" version="1.1.2" targetFramework="net35" />
5+
<package id="NUnit" version="3.6.1" targetFramework="net35" />
6+
</packages>

ReadableExpressions.UnitTests/Extensions/WhenGettingAParentExpressionNode.cs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,62 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Linq;
6-
using System.Linq.Expressions;
76
using ReadableExpressions.Extensions;
7+
#if !NET35
8+
using System.Linq.Expressions;
89
using Xunit;
10+
#else
11+
using Expression = Microsoft.Scripting.Ast.Expression;
12+
using MemberExpression = Microsoft.Scripting.Ast.MemberExpression;
13+
using ParameterExpression = Microsoft.Scripting.Ast.ParameterExpression;
14+
using Fact = NUnit.Framework.TestAttribute;
915

10-
public class WhenGettingAParentExpressionNode
16+
[NUnit.Framework.TestFixture]
17+
#endif
18+
public class WhenGettingAParentExpressionNode : TestClassBase
1119
{
1220
[Fact]
1321
public void ShouldReturnAMemberAccessParent()
1422
{
15-
Expression<Func<Type, string>> personViewModelName = t => t.Name;
23+
var personViewModelName = CreateLambda((Type t) => t.Name);
1624

1725
var namePropertyParent = personViewModelName.Body.GetParentOrNull() as ParameterExpression;
1826

19-
Assert.NotNull(namePropertyParent);
20-
Assert.Equal("t", namePropertyParent.Name);
27+
namePropertyParent.ShouldNotBeNull();
28+
namePropertyParent.Name.ShouldBe("t");
2129
}
2230

2331
[Fact]
2432
public void ShouldReturnANestedMemberAccessParent()
2533
{
26-
Expression<Func<Type, string>> typeAssemblyImageVersion = t => t.Assembly.ImageRuntimeVersion;
34+
var typeAssemblyImageVersion = CreateLambda((Type t) => t.Assembly.ImageRuntimeVersion);
2735

2836
var typeAssemblyImageVersionParent = typeAssemblyImageVersion.Body.GetParentOrNull() as MemberExpression;
2937

30-
Assert.NotNull(typeAssemblyImageVersionParent);
31-
Assert.Equal("Assembly", typeAssemblyImageVersionParent.Member.Name);
38+
typeAssemblyImageVersionParent.ShouldNotBeNull();
39+
typeAssemblyImageVersionParent.Member.Name.ShouldBe("Assembly");
3240
}
3341

3442
[Fact]
3543
public void ShouldReturnAMemberMethodCallParent()
3644
{
37-
Expression<Func<Type, string>> typeAssemblyToString = p => p.Assembly.ToString();
45+
var typeAssemblyToString = CreateLambda((Type t) => t.Assembly.ToString());
3846

3947
var assemblyToStringPropertyParent = typeAssemblyToString.Body.GetParentOrNull() as MemberExpression;
4048

41-
Assert.NotNull(assemblyToStringPropertyParent);
42-
Assert.Equal("Assembly", assemblyToStringPropertyParent.Member.Name);
49+
assemblyToStringPropertyParent.ShouldNotBeNull();
50+
assemblyToStringPropertyParent.Member.Name.ShouldBe("Assembly");
4351
}
4452

4553
[Fact]
4654
public void ShouldReturnAnExtensionMethodCallParent()
4755
{
48-
Expression<Func<IEnumerable<Type>, Type[]>> typesToArray = ts => ts.ToArray();
56+
var typesToArray = CreateLambda((IEnumerable<Type> ts) => ts.ToArray());
4957

5058
var typesToArrayPropertyParent = typesToArray.Body.GetParentOrNull() as ParameterExpression;
5159

52-
Assert.NotNull(typesToArrayPropertyParent);
53-
Assert.Equal("ts", typesToArrayPropertyParent.Name);
60+
typesToArrayPropertyParent.ShouldNotBeNull();
61+
typesToArrayPropertyParent.Name.ShouldBe("ts");
5462
}
5563
}
5664
}

ReadableExpressions.UnitTests/Extensions/WhenGettingFriendlyNames.cs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
{
33
using System;
44
using System.Collections.Generic;
5-
using System.Linq.Expressions;
65
using ReadableExpressions.Extensions;
6+
#if !NET35
7+
using System.Linq.Expressions;
78
using Xunit;
9+
#else
10+
using Expression = Microsoft.Scripting.Ast.Expression;
11+
using Fact = NUnit.Framework.TestAttribute;
812

9-
public class WhenGettingFriendlyNames
13+
[NUnit.Framework.TestFixture]
14+
#endif
15+
public class WhenGettingFriendlyNames : TestClassBase
1016
{
1117
[Fact]
1218
public void ShouldUseFriendlyNamesForArrays()
@@ -15,19 +21,19 @@ public void ShouldUseFriendlyNamesForArrays()
1521
var assignNull = Expression.Assign(intArrayVariable, Expression.Default(intArrayVariable.Type));
1622
var assignNullBlock = Expression.Block(new[] { intArrayVariable }, assignNull);
1723

18-
var translated = assignNullBlock.ToReadableString();
24+
var translated = ToReadableString(assignNullBlock);
1925

20-
Assert.Equal("var ints = default(int[]);", translated);
26+
translated.ShouldBe("var ints = default(int[]);");
2127
}
2228

2329
[Fact]
2430
public void ShouldUseFriendlyNamesForCharacters()
2531
{
26-
Expression<Func<char, double>> characterToNumeric = c => char.GetNumericValue(c);
32+
var characterToNumeric = CreateLambda((char c) => char.GetNumericValue(c));
2733

28-
var translated = characterToNumeric.ToReadableString();
34+
var translated = ToReadableString(characterToNumeric);
2935

30-
Assert.Equal("c => char.GetNumericValue(c)", translated);
36+
translated.ShouldBe("c => char.GetNumericValue(c)");
3137
}
3238

3339
[Fact]
@@ -37,7 +43,7 @@ public void ShouldUseFriendlyNamesForAnonymousTypes()
3743

3844
var friendlyName = anon.GetType().GetFriendlyName();
3945

40-
Assert.Equal("AnonymousType<int, string>", friendlyName);
46+
friendlyName.ShouldBe("AnonymousType<int, string>");
4147
}
4248

4349
// See https://github.com/agileobjects/ReadableExpressions/issues/6
@@ -46,39 +52,39 @@ public void ShouldUseFriendlyNamesForMultiplyNestedTypes()
4652
{
4753
var nestedType = Expression.Constant(typeof(OuterClass.InnerClass.Nested), typeof(Type));
4854

49-
var translated = nestedType.ToReadableString();
55+
var translated = ToReadableString(nestedType);
5056

51-
Assert.Equal("typeof(OuterClass.InnerClass.Nested)", translated);
57+
translated.ShouldBe("typeof(OuterClass.InnerClass.Nested)");
5258
}
5359

5460
[Fact]
5561
public void ShouldUseFriendlyNamesForListsOfNestedTypes()
5662
{
5763
var newNestedTypeList = Expression.New(typeof(List<>).MakeGenericType(typeof(OuterClass.InnerClass)));
5864

59-
var translated = newNestedTypeList.ToReadableString();
65+
var translated = ToReadableString(newNestedTypeList);
6066

61-
Assert.Equal("new List<OuterClass.InnerClass>()", translated);
67+
translated.ShouldBe("new List<OuterClass.InnerClass>()");
6268
}
6369

6470
[Fact]
6571
public void ShouldUseFriendlyNamesForGenericNestedTypes()
6672
{
6773
var genericListEnumeratorType = Expression.Constant(typeof(List<string>.Enumerator), typeof(Type));
6874

69-
var translated = genericListEnumeratorType.ToReadableString();
75+
var translated = ToReadableString(genericListEnumeratorType);
7076

71-
Assert.Equal("typeof(List<string>.Enumerator)", translated);
77+
translated.ShouldBe("typeof(List<string>.Enumerator)");
7278
}
7379

7480
[Fact]
7581
public void ShouldUseFriendlyNamesForNestedGenericTypes()
7682
{
7783
var genericListEnumeratorType = Expression.Constant(typeof(GenericTestHelper<int>), typeof(Type));
7884

79-
var translated = genericListEnumeratorType.ToReadableString();
85+
var translated = ToReadableString(genericListEnumeratorType);
8086

81-
Assert.Equal("typeof(WhenGettingFriendlyNames.GenericTestHelper<int>)", translated);
87+
translated.ShouldBe("typeof(WhenGettingFriendlyNames.GenericTestHelper<int>)");
8288
}
8389

8490
[Fact]
@@ -88,9 +94,9 @@ public void ShouldUseFriendlyNamesForGenericMultiplyNestedTypes()
8894
typeof(OuterGeneric<int>.InnerGeneric<long>.Nested),
8995
typeof(Type));
9096

91-
var translated = nestedGenericType.ToReadableString();
97+
var translated = ToReadableString(nestedGenericType);
9298

93-
Assert.Equal("typeof(OuterGeneric<int>.InnerGeneric<long>.Nested)", translated);
99+
translated.ShouldBe("typeof(OuterGeneric<int>.InnerGeneric<long>.Nested)");
94100
}
95101

96102
#region Helper Classes

0 commit comments

Comments
 (0)