diff --git a/AgileMapper.PerformanceTester/AgileMapper.PerformanceTester.csproj b/AgileMapper.PerformanceTester/AgileMapper.PerformanceTester.csproj index 774508132..66fda6e37 100644 --- a/AgileMapper.PerformanceTester/AgileMapper.PerformanceTester.csproj +++ b/AgileMapper.PerformanceTester/AgileMapper.PerformanceTester.csproj @@ -34,11 +34,11 @@ 4 - - ..\packages\AgileObjects.NetStandardPolyfills.1.3.0\lib\net40\AgileObjects.NetStandardPolyfills.dll + + ..\packages\AgileObjects.NetStandardPolyfills.1.4.0\lib\net40\AgileObjects.NetStandardPolyfills.dll - - ..\packages\AgileObjects.ReadableExpressions.1.11.0\lib\net40\AgileObjects.ReadableExpressions.dll + + ..\packages\AgileObjects.ReadableExpressions.1.12.1\lib\net40\AgileObjects.ReadableExpressions.dll ..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll diff --git a/AgileMapper.PerformanceTester/App.config b/AgileMapper.PerformanceTester/App.config index 291327982..b176983b3 100644 --- a/AgileMapper.PerformanceTester/App.config +++ b/AgileMapper.PerformanceTester/App.config @@ -7,7 +7,7 @@ - + diff --git a/AgileMapper.PerformanceTester/packages.config b/AgileMapper.PerformanceTester/packages.config index 73ff2151f..6bb5b1c0a 100644 --- a/AgileMapper.PerformanceTester/packages.config +++ b/AgileMapper.PerformanceTester/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/AgileMapper.UnitTests.MoreTestClasses/AgileMapper.UnitTests.MoreTestClasses.csproj b/AgileMapper.UnitTests.MoreTestClasses/AgileMapper.UnitTests.MoreTestClasses.csproj index a4b214a7a..ef63b0656 100644 --- a/AgileMapper.UnitTests.MoreTestClasses/AgileMapper.UnitTests.MoreTestClasses.csproj +++ b/AgileMapper.UnitTests.MoreTestClasses/AgileMapper.UnitTests.MoreTestClasses.csproj @@ -1,8 +1,8 @@ - + - netstandard1.0 + net35;netstandard1.0 AgileObjects.AgileMapper.UnitTests.MoreTestClasses AgileObjects.AgileMapper.UnitTests.MoreTestClasses diff --git a/AgileMapper.UnitTests.Net35/AgileMapper.UnitTests.Net35.csproj b/AgileMapper.UnitTests.Net35/AgileMapper.UnitTests.Net35.csproj new file mode 100644 index 000000000..c7c51c967 --- /dev/null +++ b/AgileMapper.UnitTests.Net35/AgileMapper.UnitTests.Net35.csproj @@ -0,0 +1,89 @@ + + + + + + Debug + AnyCPU + {E0706509-4A4B-4C0D-A3B2-4A713FFC6ED4} + Library + Properties + AgileObjects.AgileMapper.UnitTests.Net35 + AgileObjects.AgileMapper.UnitTests.Net35 + v3.5 + 512 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;NET35 + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE;NET35 + prompt + 4 + + + + ..\packages\AgileObjects.NetStandardPolyfills.1.4.0\lib\net35\AgileObjects.NetStandardPolyfills.dll + + + ..\packages\AgileObjects.ReadableExpressions.1.12.1\lib\net35\AgileObjects.ReadableExpressions.dll + + + ..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Dynamic.dll + + + ..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.dll + + + ..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.AspNet.dll + + + ..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.Core.dll + + + ..\packages\DynamicLanguageRuntime.1.1.2\lib\Net35\Microsoft.Scripting.Metadata.dll + + + ..\packages\NUnit.3.6.1\lib\net35\nunit.framework.dll + + + + + + + + + + + %(RecursiveDir)%(Filename)%(Extension) + + + + + Properties\CommonAssemblyInfo.cs + + + + + + + + {0d045f11-1cbb-4be1-b854-d7e5d348c2fe} + AgileMapper.UnitTests.MoreTestClasses + + + {147ddcce-cdd3-4dd0-8ba3-d3f2f239e161} + AgileMapper + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.Net35/packages.config b/AgileMapper.UnitTests.Net35/packages.config new file mode 100644 index 000000000..b089d5d31 --- /dev/null +++ b/AgileMapper.UnitTests.Net35/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.NetCore/AgileMapper.UnitTests.NetCore.csproj b/AgileMapper.UnitTests.NetCore/AgileMapper.UnitTests.NetCore.csproj index a2c6ab49b..eda1e9913 100644 --- a/AgileMapper.UnitTests.NetCore/AgileMapper.UnitTests.NetCore.csproj +++ b/AgileMapper.UnitTests.NetCore/AgileMapper.UnitTests.NetCore.csproj @@ -29,7 +29,7 @@ - + diff --git a/AgileMapper.UnitTests.NetCore2.1/AgileMapper.UnitTests.NetCore2.1.csproj b/AgileMapper.UnitTests.NetCore2.1/AgileMapper.UnitTests.NetCore2.1.csproj index e43559c85..7285bfa32 100644 --- a/AgileMapper.UnitTests.NetCore2.1/AgileMapper.UnitTests.NetCore2.1.csproj +++ b/AgileMapper.UnitTests.NetCore2.1/AgileMapper.UnitTests.NetCore2.1.csproj @@ -29,7 +29,7 @@ - + diff --git a/AgileMapper.UnitTests.NetCore2/AgileMapper.UnitTests.NetCore2.csproj b/AgileMapper.UnitTests.NetCore2/AgileMapper.UnitTests.NetCore2.csproj index 31d66bef0..1e90ad6d2 100644 --- a/AgileMapper.UnitTests.NetCore2/AgileMapper.UnitTests.NetCore2.csproj +++ b/AgileMapper.UnitTests.NetCore2/AgileMapper.UnitTests.NetCore2.csproj @@ -29,7 +29,7 @@ - + diff --git a/AgileMapper.UnitTests.NonParallel/app.config b/AgileMapper.UnitTests.NonParallel/app.config index b4c3aaacc..b1d125491 100644 --- a/AgileMapper.UnitTests.NonParallel/app.config +++ b/AgileMapper.UnitTests.NonParallel/app.config @@ -4,7 +4,7 @@ - + diff --git a/AgileMapper.UnitTests.Orms.EFCore2.NetCore2/AgileMapper.UnitTests.Orms.EfCore2.NetCore2.csproj b/AgileMapper.UnitTests.Orms.EFCore2.NetCore2/AgileMapper.UnitTests.Orms.EfCore2.NetCore2.csproj index 233aa58e2..2b3440bf8 100644 --- a/AgileMapper.UnitTests.Orms.EFCore2.NetCore2/AgileMapper.UnitTests.Orms.EfCore2.NetCore2.csproj +++ b/AgileMapper.UnitTests.Orms.EFCore2.NetCore2/AgileMapper.UnitTests.Orms.EfCore2.NetCore2.csproj @@ -31,7 +31,7 @@ - + diff --git a/AgileMapper.UnitTests.Orms.Ef5.LocalDb/AgileMapper.UnitTests.Orms.Ef5.LocalDb.csproj b/AgileMapper.UnitTests.Orms.Ef5.LocalDb/AgileMapper.UnitTests.Orms.Ef5.LocalDb.csproj index 6e6799b8a..415d552ff 100644 --- a/AgileMapper.UnitTests.Orms.Ef5.LocalDb/AgileMapper.UnitTests.Orms.Ef5.LocalDb.csproj +++ b/AgileMapper.UnitTests.Orms.Ef5.LocalDb/AgileMapper.UnitTests.Orms.Ef5.LocalDb.csproj @@ -45,8 +45,8 @@ ..\AgileMapper.snk - - ..\packages\AgileObjects.NetStandardPolyfills.1.3.0\lib\net40\AgileObjects.NetStandardPolyfills.dll + + ..\packages\AgileObjects.NetStandardPolyfills.1.4.0\lib\net40\AgileObjects.NetStandardPolyfills.dll ..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll diff --git a/AgileMapper.UnitTests.Orms.Ef5.LocalDb/App.config b/AgileMapper.UnitTests.Orms.Ef5.LocalDb/App.config index da5fa9f0e..c279b5844 100644 --- a/AgileMapper.UnitTests.Orms.Ef5.LocalDb/App.config +++ b/AgileMapper.UnitTests.Orms.Ef5.LocalDb/App.config @@ -17,6 +17,10 @@ + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.Orms.Ef5.LocalDb/packages.config b/AgileMapper.UnitTests.Orms.Ef5.LocalDb/packages.config index 5364bcad1..feb0ee3df 100644 --- a/AgileMapper.UnitTests.Orms.Ef5.LocalDb/packages.config +++ b/AgileMapper.UnitTests.Orms.Ef5.LocalDb/packages.config @@ -1,6 +1,6 @@  - + diff --git a/AgileMapper.UnitTests.Orms.Ef5/AgileMapper.UnitTests.Orms.Ef5.csproj b/AgileMapper.UnitTests.Orms.Ef5/AgileMapper.UnitTests.Orms.Ef5.csproj index 64c300e0f..ba9b553b2 100644 --- a/AgileMapper.UnitTests.Orms.Ef5/AgileMapper.UnitTests.Orms.Ef5.csproj +++ b/AgileMapper.UnitTests.Orms.Ef5/AgileMapper.UnitTests.Orms.Ef5.csproj @@ -47,7 +47,7 @@ - ..\packages\Effort.1.3.4\lib\net45\Effort.dll + ..\packages\Effort.1.3.5\lib\net45\Effort.dll ..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll diff --git a/AgileMapper.UnitTests.Orms.Ef5/App.config b/AgileMapper.UnitTests.Orms.Ef5/App.config index 3d5ee2c10..72aa76b53 100644 --- a/AgileMapper.UnitTests.Orms.Ef5/App.config +++ b/AgileMapper.UnitTests.Orms.Ef5/App.config @@ -20,6 +20,10 @@ + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.Orms.Ef5/packages.config b/AgileMapper.UnitTests.Orms.Ef5/packages.config index 64593b956..f5ba35773 100644 --- a/AgileMapper.UnitTests.Orms.Ef5/packages.config +++ b/AgileMapper.UnitTests.Orms.Ef5/packages.config @@ -1,6 +1,6 @@  - + diff --git a/AgileMapper.UnitTests.Orms.Ef6.LocalDb/AgileMapper.UnitTests.Orms.Ef6.LocalDb.csproj b/AgileMapper.UnitTests.Orms.Ef6.LocalDb/AgileMapper.UnitTests.Orms.Ef6.LocalDb.csproj index 95ab6af79..67cd6b325 100644 --- a/AgileMapper.UnitTests.Orms.Ef6.LocalDb/AgileMapper.UnitTests.Orms.Ef6.LocalDb.csproj +++ b/AgileMapper.UnitTests.Orms.Ef6.LocalDb/AgileMapper.UnitTests.Orms.Ef6.LocalDb.csproj @@ -45,8 +45,8 @@ ..\AgileMapper.snk - - ..\packages\AgileObjects.NetStandardPolyfills.1.3.0\lib\net40\AgileObjects.NetStandardPolyfills.dll + + ..\packages\AgileObjects.NetStandardPolyfills.1.4.0\lib\net40\AgileObjects.NetStandardPolyfills.dll ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll @@ -100,7 +100,9 @@ - + + Designer + diff --git a/AgileMapper.UnitTests.Orms.Ef6.LocalDb/App.config b/AgileMapper.UnitTests.Orms.Ef6.LocalDb/App.config index a653955ca..560d9159f 100644 --- a/AgileMapper.UnitTests.Orms.Ef6.LocalDb/App.config +++ b/AgileMapper.UnitTests.Orms.Ef6.LocalDb/App.config @@ -14,4 +14,12 @@ + + + + + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.Orms.Ef6.LocalDb/packages.config b/AgileMapper.UnitTests.Orms.Ef6.LocalDb/packages.config index 54e6e4620..00bc851d6 100644 --- a/AgileMapper.UnitTests.Orms.Ef6.LocalDb/packages.config +++ b/AgileMapper.UnitTests.Orms.Ef6.LocalDb/packages.config @@ -1,6 +1,6 @@  - + diff --git a/AgileMapper.UnitTests.Orms.Ef6/App.config b/AgileMapper.UnitTests.Orms.Ef6/App.config index e6079b964..b8c386d9b 100644 --- a/AgileMapper.UnitTests.Orms.Ef6/App.config +++ b/AgileMapper.UnitTests.Orms.Ef6/App.config @@ -3,4 +3,12 @@ + + + + + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.Orms.EfCore1/app.config b/AgileMapper.UnitTests.Orms.EfCore1/app.config index d6e65bfe6..ad5ef9c84 100644 --- a/AgileMapper.UnitTests.Orms.EfCore1/app.config +++ b/AgileMapper.UnitTests.Orms.EfCore1/app.config @@ -50,6 +50,10 @@ + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.Orms.EfCore2/app.config b/AgileMapper.UnitTests.Orms.EfCore2/app.config index 02e56c21e..eafddf1b6 100644 --- a/AgileMapper.UnitTests.Orms.EfCore2/app.config +++ b/AgileMapper.UnitTests.Orms.EfCore2/app.config @@ -22,6 +22,10 @@ + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests.Orms/AgileMapper.UnitTests.Orms.csproj b/AgileMapper.UnitTests.Orms/AgileMapper.UnitTests.Orms.csproj index 9649fe6a2..30cd697fe 100644 --- a/AgileMapper.UnitTests.Orms/AgileMapper.UnitTests.Orms.csproj +++ b/AgileMapper.UnitTests.Orms/AgileMapper.UnitTests.Orms.csproj @@ -172,6 +172,7 @@ + diff --git a/AgileMapper.UnitTests.Orms/app.config b/AgileMapper.UnitTests.Orms/app.config new file mode 100644 index 000000000..b1d125491 --- /dev/null +++ b/AgileMapper.UnitTests.Orms/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj b/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj index 136330916..6d6032753 100644 --- a/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj +++ b/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj @@ -41,11 +41,11 @@ false - - ..\packages\AgileObjects.NetStandardPolyfills.1.3.0\lib\net40\AgileObjects.NetStandardPolyfills.dll + + ..\packages\AgileObjects.NetStandardPolyfills.1.4.0\lib\net40\AgileObjects.NetStandardPolyfills.dll - - ..\packages\AgileObjects.ReadableExpressions.1.11.0\lib\net40\AgileObjects.ReadableExpressions.dll + + ..\packages\AgileObjects.ReadableExpressions.1.12.1\lib\net40\AgileObjects.ReadableExpressions.dll ..\packages\Microsoft.Extensions.Primitives.2.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringCallbacksInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringCallbacksInline.cs index f9104f524..4002ab9ef 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringCallbacksInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringCallbacksInline.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using AgileMapper.Members; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringCallbacksInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringConstructorDataSourcesInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringConstructorDataSourcesInline.cs index 933db1c2f..07c38d95e 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringConstructorDataSourcesInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringConstructorDataSourcesInline.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringConstructorDataSourcesInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInline.cs index c2bdfaf12..b26c7d18a 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInline.cs @@ -5,8 +5,13 @@ using AgileMapper.Extensions; using AgileMapper.Members; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDataSourcesInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInlineIncorrectly.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInlineIncorrectly.cs index 7ee2cbc3d..afdd63e9d 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInlineIncorrectly.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDataSourcesInlineIncorrectly.cs @@ -3,8 +3,13 @@ using System; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDataSourcesInlineIncorrectly { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDerivedTypesInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDerivedTypesInline.cs index bca8518ef..6a9db359c 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDerivedTypesInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringDerivedTypesInline.cs @@ -4,8 +4,13 @@ using MoreTestClasses; using NetStandardPolyfills; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDerivedTypesInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringEnumMappingInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringEnumMappingInline.cs index 6a9be04ed..b7c3d628e 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringEnumMappingInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringEnumMappingInline.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration.Inline { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringEnumMappingInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringNameMatchingInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringNameMatchingInline.cs index 90ca6ecf5..cdb5b310f 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringNameMatchingInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringNameMatchingInline.cs @@ -2,8 +2,13 @@ { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringNameMatchingInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectCreationInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectCreationInline.cs index 1cb6b6a5d..f52e379f4 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectCreationInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectCreationInline.cs @@ -3,8 +3,13 @@ using System; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringObjectCreationInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectTrackingInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectTrackingInline.cs index 921f2c567..343b9ab02 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectTrackingInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringObjectTrackingInline.cs @@ -4,8 +4,13 @@ using System.Linq; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringObjectTrackingInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringStringFormattingInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringStringFormattingInline.cs index 05a741030..104b9fd48 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringStringFormattingInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringStringFormattingInline.cs @@ -2,8 +2,13 @@ { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringStringFormattingInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringTypeIdentifiersInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringTypeIdentifiersInline.cs index 16c0cbeab..5a8d34d9a 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringTypeIdentifiersInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenConfiguringTypeIdentifiersInline.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringTypeIdentifiersInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInline.cs index 462f2ca85..b7077da54 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInline.cs @@ -3,8 +3,13 @@ using System; using Api.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenIgnoringMembersInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInlineIncorrectly.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInlineIncorrectly.cs index 3b81ceb9a..2bdf89e2a 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInlineIncorrectly.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenIgnoringMembersInlineIncorrectly.cs @@ -2,8 +2,13 @@ { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenIgnoringMembersInlineIncorrectly { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenMappingToNullInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenMappingToNullInline.cs index 4374628fd..9277cae67 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenMappingToNullInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenMappingToNullInline.cs @@ -1,9 +1,15 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration.Inline { using AgileMapper.Configuration; + using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNullInline { [Fact] @@ -16,7 +22,7 @@ public void ShouldApplyAUserConfiguredConditionInline() .ToANew(cfg => cfg .WhenMapping .To
() - .If((o, a) => string.IsNullOrWhiteSpace(a.Line1)) + .If((o, a) => a.Line1.IsNullOrWhiteSpace()) .MapToNull()); result.Name.ShouldBe("Bob"); diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenValidatingMappingsInline.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenValidatingMappingsInline.cs index d508f6c30..203655b2a 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenValidatingMappingsInline.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenValidatingMappingsInline.cs @@ -3,8 +3,13 @@ using System; using TestClasses; using Validation; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenValidatingMappingsInline { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/Inline/WhenViewingMappingPlans.cs b/AgileMapper.UnitTests/Configuration/Inline/WhenViewingMappingPlans.cs index f1cd8bf0f..816158548 100644 --- a/AgileMapper.UnitTests/Configuration/Inline/WhenViewingMappingPlans.cs +++ b/AgileMapper.UnitTests/Configuration/Inline/WhenViewingMappingPlans.cs @@ -2,8 +2,13 @@ { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenViewingMappingPlans { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurations.cs b/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurations.cs index 57e96b13b..e83ca5d24 100644 --- a/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurations.cs +++ b/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurations.cs @@ -8,8 +8,13 @@ using MoreTestClasses; using NetStandardPolyfills; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenApplyingMapperConfigurations : AssemblyScanningTestClassBase { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurationsIncorrectly.cs b/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurationsIncorrectly.cs index 3405a0d2d..ccf2bec9a 100644 --- a/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurationsIncorrectly.cs +++ b/AgileMapper.UnitTests/Configuration/WhenApplyingMapperConfigurationsIncorrectly.cs @@ -4,8 +4,13 @@ using System.Reflection; using AgileMapper.Configuration; using MoreTestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenApplyingMapperConfigurationsIncorrectly : AssemblyScanningTestClassBase { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringConstructorDataSources.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringConstructorDataSources.cs index 6a994d2ba..ac2df77a4 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringConstructorDataSources.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringConstructorDataSources.cs @@ -2,8 +2,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringConstructorDataSources { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSources.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSources.cs index 5e253594c..6f10ceed0 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSources.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSources.cs @@ -8,8 +8,13 @@ using AgileMapper.Extensions; using AgileMapper.Members; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDataSources { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSourcesIncorrectly.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSourcesIncorrectly.cs index 5c205d004..1b1ea754d 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSourcesIncorrectly.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringDataSourcesIncorrectly.cs @@ -3,8 +3,13 @@ using System; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDataSourcesIncorrectly { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypes.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypes.cs index 7c42f0c79..1b7abe901 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypes.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypes.cs @@ -1,10 +1,16 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration { + using AgileMapper.Extensions.Internal; using MoreTestClasses; using NetStandardPolyfills; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDerivedTypes { [Fact] @@ -88,7 +94,7 @@ public void ShouldMapADerivedTypePairConditionally() .If(s => s.Source.Discount.HasValue) .MapTo() .And - .If(x => !string.IsNullOrWhiteSpace(x.Source.Report)) + .If(x => !x.Source.Report.IsNullOrWhiteSpace()) .MapTo(); var mysteryCustomerSource = new diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypesIncorrectly.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypesIncorrectly.cs index c261452fb..8644e5dd8 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypesIncorrectly.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringDerivedTypesIncorrectly.cs @@ -4,8 +4,13 @@ using System.Reflection; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDerivedTypesIncorrectly { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringEnumMapping.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringEnumMapping.cs index 32180e5e1..2a18fe326 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringEnumMapping.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringEnumMapping.cs @@ -3,8 +3,13 @@ using System; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringEnumMapping { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringExceptionHandling.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringExceptionHandling.cs index 4dccc5d12..c27a2cf0c 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringExceptionHandling.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringExceptionHandling.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringExceptionHandling { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringMappingCallbacks.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringMappingCallbacks.cs index 191fbe408..0fe0ed98e 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringMappingCallbacks.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringMappingCallbacks.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringMappingCallbacks { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs index 9670c77db..7857ee9af 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs @@ -5,8 +5,13 @@ using AgileMapper.Configuration; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringNameMatching { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreation.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreation.cs index a4e1bb017..8301d4019 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreation.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreation.cs @@ -7,8 +7,13 @@ using AgileMapper.Configuration; using AgileMapper.Members; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringObjectCreation { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreationCallbacks.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreationCallbacks.cs index bf243ab57..235439c06 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreationCallbacks.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreationCallbacks.cs @@ -8,8 +8,13 @@ using AgileMapper.Members; using ReadableExpressions.Extensions; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringObjectCreationCallbacks { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTracking.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTracking.cs index c011bf613..c998433f0 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTracking.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTracking.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringObjectTracking { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTrackingIncorrectly.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTrackingIncorrectly.cs index cdcdc0088..2182af8b1 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTrackingIncorrectly.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringObjectTrackingIncorrectly.cs @@ -2,8 +2,13 @@ { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringObjectTrackingIncorrectly { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringStringFormatting.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringStringFormatting.cs index bfed8a4d3..ea26a2b8f 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringStringFormatting.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringStringFormatting.cs @@ -3,8 +3,13 @@ using System; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringStringFormatting { // See https://github.com/agileobjects/AgileMapper/issues/23 diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringTypeIdentifiers.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringTypeIdentifiers.cs index 5585d35d4..afad44bca 100644 --- a/AgileMapper.UnitTests/Configuration/WhenConfiguringTypeIdentifiers.cs +++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringTypeIdentifiers.cs @@ -5,8 +5,13 @@ using System.Linq; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringTypeIdentifiers { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembers.cs b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembers.cs index 9fd349a91..08531d88d 100644 --- a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembers.cs +++ b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembers.cs @@ -6,8 +6,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration using AgileMapper.Configuration; using NetStandardPolyfills; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenIgnoringMembers { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs index bfc26ca55..5eddac21a 100644 --- a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs +++ b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs @@ -4,8 +4,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration using AgileMapper.Extensions.Internal; using NetStandardPolyfills; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenIgnoringMembersByFilter { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs index a279c7c9e..6da78fd5a 100644 --- a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs +++ b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs @@ -4,8 +4,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration using AgileMapper.Extensions.Internal; using NetStandardPolyfills; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenIgnoringMembersByGlobalFilter { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersIncorrectly.cs b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersIncorrectly.cs index 9f509b703..b8929cf11 100644 --- a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersIncorrectly.cs +++ b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersIncorrectly.cs @@ -2,8 +2,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Configuration { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenIgnoringMembersIncorrectly { [Fact] diff --git a/AgileMapper.UnitTests/Configuration/WhenMappingToNull.cs b/AgileMapper.UnitTests/Configuration/WhenMappingToNull.cs index 693f1cabc..96acd083e 100644 --- a/AgileMapper.UnitTests/Configuration/WhenMappingToNull.cs +++ b/AgileMapper.UnitTests/Configuration/WhenMappingToNull.cs @@ -4,9 +4,15 @@ using System.Collections.Generic; using System.Linq; using AgileMapper.Configuration; + using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNull { [Fact] @@ -16,7 +22,7 @@ public void ShouldApplyAUserConfiguredCondition() { mapper.WhenMapping .To
() - .If((o, a) => string.IsNullOrWhiteSpace(a.Line1)) + .If((o, a) => a.Line1.IsNullOrWhiteSpace()) .MapToNull(); var source = new CustomerViewModel { Name = "Bob" }; diff --git a/AgileMapper.UnitTests/Configuration/WhenViewingMappingPlans.cs b/AgileMapper.UnitTests/Configuration/WhenViewingMappingPlans.cs index b1078a460..aaa587678 100644 --- a/AgileMapper.UnitTests/Configuration/WhenViewingMappingPlans.cs +++ b/AgileMapper.UnitTests/Configuration/WhenViewingMappingPlans.cs @@ -2,8 +2,13 @@ { using System.Collections.ObjectModel; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenViewingMappingPlans { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs index 5342ee072..2c9a7d5ef 100644 --- a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs +++ b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringDictionaryMappingIncorrectly { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringNestedDictionaryMapping.cs b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringNestedDictionaryMapping.cs index d53764070..1793199a3 100644 --- a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringNestedDictionaryMapping.cs +++ b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringNestedDictionaryMapping.cs @@ -2,8 +2,13 @@ { using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringNestedDictionaryMapping { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs index 60963a985..5935075cd 100644 --- a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs +++ b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringSourceDictionaryMapping { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringTargetDictionaryMapping.cs b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringTargetDictionaryMapping.cs index 0c961e59e..f153edfed 100644 --- a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringTargetDictionaryMapping.cs +++ b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringTargetDictionaryMapping.cs @@ -5,8 +5,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringTargetDictionaryMapping { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenCreatingRootDictionaryMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenCreatingRootDictionaryMembers.cs index ef0b2976e..c4d414774 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenCreatingRootDictionaryMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenCreatingRootDictionaryMembers.cs @@ -5,8 +5,13 @@ using AgileMapper.Members.Dictionaries; using Members; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenCreatingRootDictionaryMembers : MemberTestsBase { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToComplexTypes.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToComplexTypes.cs index 7a2c2e7bf..557772625 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToComplexTypes.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToComplexTypes.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesOnToComplexTypes { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToEnumerableMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToEnumerableMembers.cs index d9b7e6ed8..c5ff3d42c 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToEnumerableMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOnToEnumerableMembers.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesOnToEnumerableMembers { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOverComplexTypes.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOverComplexTypes.cs index 73408fd97..52414958a 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOverComplexTypes.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesOverComplexTypes.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesOverComplexTypes { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypeMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypeMembers.cs index 796b7a881..c66333ee9 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypeMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypeMembers.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesToNewComplexTypeMembers { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypes.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypes.cs index 11772cc10..011f97da1 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypes.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewComplexTypes.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesToNewComplexTypes { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerableMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerableMembers.cs index dc4837b90..79f63efbe 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerableMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerableMembers.cs @@ -4,12 +4,17 @@ namespace AgileObjects.AgileMapper.UnitTests.Dictionaries using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_0 && !NET35 using Microsoft.Extensions.Primitives; #endif using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesToNewEnumerableMembers { [Fact] @@ -115,7 +120,7 @@ public void ShouldMapToAComplexTypeArrayFromUntypedDottedEntries() result.Value.Second().HowMega.ShouldBe(0.99); } -#if !NETCOREAPP1_0 +#if !NETCOREAPP1_0 && !NET35 // See https://github.com/agileobjects/AgileMapper/issues/50 // See https://github.com/agileobjects/AgileMapper/issues/51 [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerables.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerables.cs index e4127899a..fbac6a239 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerables.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionariesToNewEnumerables.cs @@ -4,8 +4,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Dictionaries using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesToNewEnumerables { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionaryMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionaryMembers.cs index 0576cef02..c1772f1c3 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionaryMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingFromDictionaryMembers.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionaryMembers { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaries.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaries.cs index ddb2282b9..b90ffebd1 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaries.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaries.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToDictionaries { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaryMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaryMembers.cs index b34db32f6..69e60a5b1 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaryMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingOnToDictionaryMembers.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToDictionaryMembers { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaries.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaries.cs index 4f9923337..0c26dad4a 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaries.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaries.cs @@ -5,8 +5,13 @@ using System.Collections.ObjectModel; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverDictionaries { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaryMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaryMembers.cs index 3c412e523..0028aba40 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaryMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingOverDictionaryMembers.cs @@ -2,8 +2,13 @@ { using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverDictionaryMembers { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaries.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaries.cs index fedd4b07c..f902c9bff 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaries.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaries.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewDictionaries { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaryMembers.cs b/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaryMembers.cs index 97c9e8804..6a178516c 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaryMembers.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenMappingToNewDictionaryMembers.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewDictionaryMembers { [Fact] diff --git a/AgileMapper.UnitTests/Dictionaries/WhenViewingDictionaryMappingPlans.cs b/AgileMapper.UnitTests/Dictionaries/WhenViewingDictionaryMappingPlans.cs index e3f4cc231..211d28865 100644 --- a/AgileMapper.UnitTests/Dictionaries/WhenViewingDictionaryMappingPlans.cs +++ b/AgileMapper.UnitTests/Dictionaries/WhenViewingDictionaryMappingPlans.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenViewingDictionaryMappingPlans { [Fact] @@ -18,7 +23,11 @@ public void ShouldShowATargetObjectMappingPlan() plan.ShouldContain("idKey = sourceDictionary_String_String.Keys.FirstOrDefault(key => key.MatchesKey(\"Id\""); plan.ShouldContain("id = sourceDictionary_String_String[idKey]"); plan.ShouldContain("customerViewModel.Id ="); +#if NET35 + plan.ShouldContain("id.ToGuid()"); +#else plan.ShouldContain("Guid.TryParse(id"); +#endif } [Fact] diff --git a/AgileMapper.UnitTests/Extensions/Internal/WhenEquatingExpressions.cs b/AgileMapper.UnitTests/Extensions/Internal/WhenEquatingExpressions.cs index 183bd65b8..c3a490978 100644 --- a/AgileMapper.UnitTests/Extensions/Internal/WhenEquatingExpressions.cs +++ b/AgileMapper.UnitTests/Extensions/Internal/WhenEquatingExpressions.cs @@ -5,8 +5,14 @@ using System.Linq.Expressions; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Dlr = Microsoft.Scripting.Ast; + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenEquatingExpressions { [Fact] @@ -15,7 +21,7 @@ public void ShouldEquateCheckedAdditions() Expression> bindingsOne = (x, y) => checked(x + y); Expression> bindingsTwo = (x, y) => checked(x + y); - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -24,7 +30,7 @@ public void ShouldEquateCheckedSubtractions() Expression> bindingsOne = (x, y) => checked(x - y); Expression> bindingsTwo = (x, y) => checked(x - y); - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -33,7 +39,7 @@ public void ShouldEquateCheckedMultiplications() Expression> bindingsOne = (x, y) => checked(x * y); Expression> bindingsTwo = (x, y) => checked(x * y); - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] public void ShouldEquateAModuloOperation() @@ -41,7 +47,7 @@ public void ShouldEquateAModuloOperation() Expression> bindingsOne = (x, y) => x % y == 0; Expression> bindingsTwo = (x, y) => x % y == 0; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -50,7 +56,7 @@ public void ShouldEquateNegatedDefaultComparisons() Expression> bindingsOne = x => !(x > default(int)); Expression> bindingsTwo = x => !(x > default(int)); - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -59,7 +65,7 @@ public void ShouldEquateTypeIsComparisons() Expression> bindingsOne = x => x is Person; Expression> bindingsTwo = x => x is Person; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -68,7 +74,7 @@ public void ShouldEquateTypeAsComparisons() Expression> bindingsOne = x => x as Person; Expression> bindingsTwo = x => x as Person; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -77,7 +83,7 @@ public void ShouldEquateAndComparisons() Expression> bindingsOne = x => x > 0 && x < 100; Expression> bindingsTwo = x => x > 0 && x < 100; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -86,7 +92,7 @@ public void ShouldEquateBitwiseAndComparisons() Expression> bindingsOne = x => x > 0 & x < 100; Expression> bindingsTwo = x => x > 0 & x < 100; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -95,7 +101,7 @@ public void ShouldEquateOrComparisons() Expression> bindingsOne = x => x > 0 || x < 100; Expression> bindingsTwo = x => x > 0 || x < 100; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -104,7 +110,7 @@ public void ShouldEquateBitwiseOrComparisons() Expression> bindingsOne = x => x > 0 | x < 100; Expression> bindingsTwo = x => x > 0 | x < 100; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -113,7 +119,7 @@ public void ShouldEquateExclusiveOrComparisons() Expression> bindingsOne = x => x > 0 ^ x < 100; Expression> bindingsTwo = x => x > 0 ^ x < 100; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -122,7 +128,7 @@ public void ShouldEquateMemberAccesses() Expression> accessOne = m => m.Expression.NodeType; Expression> accessTwo = m => m.Expression.NodeType; - ExpressionEvaluation.AreEqual(accessOne, accessTwo).ShouldBeTrue(); + VerifyEqual(accessOne, accessTwo); } [Fact] @@ -131,7 +137,7 @@ public void ShouldEquivalateMemberAccesses() Expression> accessOne = m => m.Expression.NodeType; Expression> accessTwo = e => e.NodeType; - ExpressionEvaluation.AreEquivalent(accessOne, accessTwo).ShouldBeTrue(); + VerifyEquivalent(accessOne, accessTwo); } [Fact] @@ -140,7 +146,7 @@ public void ShouldEquateListInitialisations() Expression>> bindingsOne = () => new List { 1, 2, 3 }; Expression>> bindingsTwo = () => new List { 1, 2, 3 }; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -149,7 +155,7 @@ public void ShouldEquateBitwiseLeftShiftOperations() Expression> bindingsOne = (x, y) => x << y; Expression> bindingsTwo = (x, y) => x << y; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -158,7 +164,7 @@ public void ShouldEquateBitwiseRightShiftOperations() Expression> bindingsOne = (x, y) => x >> y; Expression> bindingsTwo = (x, y) => x >> y; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -167,7 +173,7 @@ public void ShouldEquateCoalesceOperations() Expression> bindingsOne = (x, y) => x ?? y; Expression> bindingsTwo = (x, y) => x ?? y; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -176,7 +182,7 @@ public void ShouldEquateNegationOperations() Expression> bindingsOne = x => -x; Expression> bindingsTwo = x => -x; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -185,7 +191,7 @@ public void ShouldEquateCheckedNegationOperations() Expression> bindingsOne = x => checked(-x); Expression> bindingsTwo = x => checked(-x); - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -194,7 +200,7 @@ public void ShouldEquateANewBoundedArrayCreation() Expression> bindingsOne = x => new int[x]; Expression> bindingsTwo = x => new int[x]; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -203,7 +209,7 @@ public void ShouldEquateArrayIndexAccesses() Expression> bindingsOne = x => x[0]; Expression> bindingsTwo = x => x[0]; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -212,7 +218,7 @@ public void ShouldEquateArrayLengthAccesses() Expression> bindingsOne = x => x.Length == 1; Expression> bindingsTwo = x => x.Length == 1; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -221,7 +227,7 @@ public void ShouldEquateListBindings() Expression>>> bindingsOne = () => new PublicField> { Value = { 1 } }; Expression>>> bindingsTwo = () => new PublicField> { Value = { 1 } }; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeTrue(); + VerifyEqual(bindingsOne, bindingsTwo); } [Fact] @@ -230,7 +236,7 @@ public void ShouldDifferentiateListInitialisationsByInitialisationCount() Expression>> bindingsOne = () => new List { 1, 2, 3 }; Expression>> bindingsTwo = () => new List { 1, 2 }; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeFalse(); + VerifyNotEqual(bindingsOne, bindingsTwo); } [Fact] @@ -239,7 +245,7 @@ public void ShouldDifferentiateExpressionsByListBindingInitialiserCount() Expression>>> bindingsOne = () => new PublicField> { Value = { 1 } }; Expression>>> bindingsTwo = () => new PublicField> { Value = { 1, 2 } }; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeFalse(); + VerifyNotEqual(bindingsOne, bindingsTwo); } [Fact] @@ -248,7 +254,7 @@ public void ShouldDifferentiateExpressionsByBindingCount() Expression> oneBinding = () => new Address { Line1 = "One!" }; Expression> twoBindings = () => new Address { Line1 = "One!", Line2 = "Two!" }; - ExpressionEvaluation.AreEqual(oneBinding, twoBindings).ShouldBeFalse(); + VerifyNotEqual(oneBinding, twoBindings); } [Fact] @@ -266,7 +272,7 @@ public void ShouldDifferentiateExpressionsByBindingType() Value1 = "One!" }; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeFalse(); + VerifyNotEqual(bindingsOne, bindingsTwo); } [Fact] @@ -275,7 +281,29 @@ public void ShouldDifferentiateExpressionsBySubBindings() Expression> bindingsOne = () => new Person { Address = { Line1 = "One!" } }; Expression> bindingsTwo = () => new Person { Address = { Line1 = "One!", Line2 = "Two!" } }; - ExpressionEvaluation.AreEqual(bindingsOne, bindingsTwo).ShouldBeFalse(); + VerifyNotEqual(bindingsOne, bindingsTwo); + } + + private static void VerifyEqual(Expression one, Expression two) => Verify(one, two).ShouldBeTrue(); + + private static void VerifyNotEqual(Expression one, Expression two) => Verify(one, two).ShouldBeFalse(); + + private static bool Verify(Expression one, Expression two) + { +#if NET35 + return ExpressionEvaluation.AreEqual(one.ToDlrExpression(), two.ToDlrExpression()); +#else + return ExpressionEvaluation.AreEqual(one, two); +#endif + } + + private static void VerifyEquivalent(Expression one, Expression two) + { +#if NET35 + ExpressionEvaluation.AreEquivalent(one.ToDlrExpression(), two.ToDlrExpression()).ShouldBeTrue(); +#else + ExpressionEvaluation.AreEquivalent(one, two).ShouldBeTrue(); +#endif } } } diff --git a/AgileMapper.UnitTests/Extensions/Internal/WhenGeneratingVariableNames.cs b/AgileMapper.UnitTests/Extensions/Internal/WhenGeneratingVariableNames.cs index 719f84292..4d9d397b7 100644 --- a/AgileMapper.UnitTests/Extensions/Internal/WhenGeneratingVariableNames.cs +++ b/AgileMapper.UnitTests/Extensions/Internal/WhenGeneratingVariableNames.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenGeneratingVariableNames { [Fact] diff --git a/AgileMapper.UnitTests/Extensions/WhenFlatteningToQueryStringViaExtensionMethods.cs b/AgileMapper.UnitTests/Extensions/WhenFlatteningToQueryStringViaExtensionMethods.cs index 4127088d3..92a52af05 100644 --- a/AgileMapper.UnitTests/Extensions/WhenFlatteningToQueryStringViaExtensionMethods.cs +++ b/AgileMapper.UnitTests/Extensions/WhenFlatteningToQueryStringViaExtensionMethods.cs @@ -4,8 +4,13 @@ using System.Linq; using AgileMapper.Extensions; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenFlatteningToQueryStringViaExtensionMethods { [Fact] diff --git a/AgileMapper.UnitTests/Extensions/WhenFlatteningViaExtensionMethods.cs b/AgileMapper.UnitTests/Extensions/WhenFlatteningViaExtensionMethods.cs index ffa326d25..4959abf84 100644 --- a/AgileMapper.UnitTests/Extensions/WhenFlatteningViaExtensionMethods.cs +++ b/AgileMapper.UnitTests/Extensions/WhenFlatteningViaExtensionMethods.cs @@ -2,10 +2,16 @@ { using AgileMapper.Extensions; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenFlatteningViaExtensionMethods { +#if !NET35 [Fact] public void ShouldFlattenToDynamic() { @@ -105,7 +111,7 @@ public void ShouldFlattenToDynamicWithInlineConfigurationAndASpecifiedMapper() ((string)result._2_Line2).ShouldBe("3_2"); } } - +#endif [Fact] public void ShouldFlattenToDictionary() { diff --git a/AgileMapper.UnitTests/Extensions/WhenMappingViaExtensionMethods.cs b/AgileMapper.UnitTests/Extensions/WhenMappingViaExtensionMethods.cs index cb0fac831..95dcbc445 100644 --- a/AgileMapper.UnitTests/Extensions/WhenMappingViaExtensionMethods.cs +++ b/AgileMapper.UnitTests/Extensions/WhenMappingViaExtensionMethods.cs @@ -4,8 +4,13 @@ using System.Globalization; using AgileMapper.Extensions; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingViaExtensionMethods { [Fact] diff --git a/AgileMapper.UnitTests/MapperCloning/WhenCloningConstructorDataSources.cs b/AgileMapper.UnitTests/MapperCloning/WhenCloningConstructorDataSources.cs index 05d965123..375e43264 100644 --- a/AgileMapper.UnitTests/MapperCloning/WhenCloningConstructorDataSources.cs +++ b/AgileMapper.UnitTests/MapperCloning/WhenCloningConstructorDataSources.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenCloningConstructorDataSources { [Fact] diff --git a/AgileMapper.UnitTests/MapperCloning/WhenCloningDataSources.cs b/AgileMapper.UnitTests/MapperCloning/WhenCloningDataSources.cs index ee981e8bf..9f898ffd9 100644 --- a/AgileMapper.UnitTests/MapperCloning/WhenCloningDataSources.cs +++ b/AgileMapper.UnitTests/MapperCloning/WhenCloningDataSources.cs @@ -2,8 +2,13 @@ { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenCloningDataSources { [Fact] diff --git a/AgileMapper.UnitTests/MapperCloning/WhenCloningMemberIgnores.cs b/AgileMapper.UnitTests/MapperCloning/WhenCloningMemberIgnores.cs index e661b0d36..47c0c78dc 100644 --- a/AgileMapper.UnitTests/MapperCloning/WhenCloningMemberIgnores.cs +++ b/AgileMapper.UnitTests/MapperCloning/WhenCloningMemberIgnores.cs @@ -2,8 +2,13 @@ { using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenCloningMemberIgnores { [Fact] diff --git a/AgileMapper.UnitTests/MapperCloning/WhenCloningObjectFactories.cs b/AgileMapper.UnitTests/MapperCloning/WhenCloningObjectFactories.cs index 6249f7285..8730fbf77 100644 --- a/AgileMapper.UnitTests/MapperCloning/WhenCloningObjectFactories.cs +++ b/AgileMapper.UnitTests/MapperCloning/WhenCloningObjectFactories.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using AgileMapper.Configuration; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenCloningObjectFactories { [Fact] diff --git a/AgileMapper.UnitTests/MapperCloning/WhenCloningStringFormatting.cs b/AgileMapper.UnitTests/MapperCloning/WhenCloningStringFormatting.cs index a8a7838c2..cb289830e 100644 --- a/AgileMapper.UnitTests/MapperCloning/WhenCloningStringFormatting.cs +++ b/AgileMapper.UnitTests/MapperCloning/WhenCloningStringFormatting.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.MapperCloning { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenCloningStringFormatting { [Fact] diff --git a/AgileMapper.UnitTests/Members/MemberTestsBase.cs b/AgileMapper.UnitTests/Members/MemberTestsBase.cs index 9401f9be0..19e8c0cc1 100644 --- a/AgileMapper.UnitTests/Members/MemberTestsBase.cs +++ b/AgileMapper.UnitTests/Members/MemberTestsBase.cs @@ -3,7 +3,6 @@ using System; using System.Linq; using System.Linq.Expressions; - using AgileMapper.Extensions.Internal; using AgileMapper.Members; using NetStandardPolyfills; @@ -14,10 +13,10 @@ public abstract class MemberTestsBase internal IQualifiedMember SourceMemberFor(T sourceObject) { - var sourceParameter = Parameters.Create("source"); + var sourceParameter = Expression.Parameter(typeof(T), "source"); var sourceProperty = typeof(T).GetPublicInstanceProperties().First(); var sourcePropertyAccess = Expression.Property(sourceParameter, sourceProperty); - var sourcePropertyCastToObject = sourcePropertyAccess.GetConversionToObject(); + var sourcePropertyCastToObject = Expression.Convert(sourcePropertyAccess, typeof(object)); var sourcePropertyLambda = Expression.Lambda>(sourcePropertyCastToObject, sourceParameter); return SourceMemberFor(sourceObject, sourcePropertyLambda); diff --git a/AgileMapper.UnitTests/Members/WhenCreatingTargetMembersFromExpressions.cs b/AgileMapper.UnitTests/Members/WhenCreatingTargetMembersFromExpressions.cs index 9da189b01..7cccfe9e1 100644 --- a/AgileMapper.UnitTests/Members/WhenCreatingTargetMembersFromExpressions.cs +++ b/AgileMapper.UnitTests/Members/WhenCreatingTargetMembersFromExpressions.cs @@ -6,8 +6,13 @@ using System.Linq.Expressions; using AgileMapper.Members; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenCreatingTargetMembersFromExpressions : MemberTestsBase { [Fact] diff --git a/AgileMapper.UnitTests/Members/WhenDeterminingATypeIdentifier.cs b/AgileMapper.UnitTests/Members/WhenDeterminingATypeIdentifier.cs index 9f7f1f3f9..e37d292bb 100644 --- a/AgileMapper.UnitTests/Members/WhenDeterminingATypeIdentifier.cs +++ b/AgileMapper.UnitTests/Members/WhenDeterminingATypeIdentifier.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Members { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenDeterminingATypeIdentifier : MemberTestsBase { [Fact] diff --git a/AgileMapper.UnitTests/Members/WhenDeterminingRecursion.cs b/AgileMapper.UnitTests/Members/WhenDeterminingRecursion.cs index 2431be88b..a5894d869 100644 --- a/AgileMapper.UnitTests/Members/WhenDeterminingRecursion.cs +++ b/AgileMapper.UnitTests/Members/WhenDeterminingRecursion.cs @@ -2,8 +2,13 @@ { using AgileMapper.Members; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenDeterminingRecursion : MemberTestsBase { [Fact] diff --git a/AgileMapper.UnitTests/Members/WhenFindingDataSources.cs b/AgileMapper.UnitTests/Members/WhenFindingDataSources.cs index 4d75f546c..38a0dd9c8 100644 --- a/AgileMapper.UnitTests/Members/WhenFindingDataSources.cs +++ b/AgileMapper.UnitTests/Members/WhenFindingDataSources.cs @@ -5,8 +5,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Members using AgileMapper.Members; using ObjectPopulation; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenFindingDataSources : MemberTestsBase { [Fact] diff --git a/AgileMapper.UnitTests/Members/WhenFindingSourceMembers.cs b/AgileMapper.UnitTests/Members/WhenFindingSourceMembers.cs index 123c6609e..140b5e492 100644 --- a/AgileMapper.UnitTests/Members/WhenFindingSourceMembers.cs +++ b/AgileMapper.UnitTests/Members/WhenFindingSourceMembers.cs @@ -3,8 +3,13 @@ using System; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif // ReSharper disable PossibleNullReferenceException public class WhenFindingSourceMembers : MemberTestsBase { diff --git a/AgileMapper.UnitTests/Members/WhenFindingTargetMembers.cs b/AgileMapper.UnitTests/Members/WhenFindingTargetMembers.cs index a59c9e4a9..3f8383ce1 100644 --- a/AgileMapper.UnitTests/Members/WhenFindingTargetMembers.cs +++ b/AgileMapper.UnitTests/Members/WhenFindingTargetMembers.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif // ReSharper disable PossibleNullReferenceException public class WhenFindingTargetMembers : MemberTestsBase { diff --git a/AgileMapper.UnitTests/Members/WhenMatchingSourceToTargetMembers.cs b/AgileMapper.UnitTests/Members/WhenMatchingSourceToTargetMembers.cs index 9c3d60ff2..da4d088fc 100644 --- a/AgileMapper.UnitTests/Members/WhenMatchingSourceToTargetMembers.cs +++ b/AgileMapper.UnitTests/Members/WhenMatchingSourceToTargetMembers.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMatchingSourceToTargetMembers : MemberTestsBase { [Fact] diff --git a/AgileMapper.UnitTests/Reflection/WhenAccessingTypeInformation.cs b/AgileMapper.UnitTests/Reflection/WhenAccessingTypeInformation.cs index 9f8c52d8c..55b762852 100644 --- a/AgileMapper.UnitTests/Reflection/WhenAccessingTypeInformation.cs +++ b/AgileMapper.UnitTests/Reflection/WhenAccessingTypeInformation.cs @@ -5,8 +5,13 @@ using System.Collections.Generic; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenAccessingTypeInformation { #region IsEnumerable @@ -94,5 +99,17 @@ public void ShouldNotEvaluateANullableValueTypeAsComplex() } #endregion + + [Fact] + public void ShouldEvaluateATypeAsFromTheBcl() + { + typeof(Func<>).IsFromBcl().ShouldBeTrue(); + } + + [Fact] + public void ShouldEvaluateATypeAsNotFromTheBcl() + { + typeof(WhenAccessingTypeInformation).IsFromBcl().ShouldBeFalse(); + } } } diff --git a/AgileMapper.UnitTests/Should.cs b/AgileMapper.UnitTests/Should.cs index 26c900af5..ef48c977a 100644 --- a/AgileMapper.UnitTests/Should.cs +++ b/AgileMapper.UnitTests/Should.cs @@ -1,7 +1,9 @@ namespace AgileObjects.AgileMapper.UnitTests { using System; +#if !NET35 using System.Threading.Tasks; +#endif public static class Should { @@ -31,6 +33,7 @@ public static TException Throw(Func testFunc) throw new Exception("Expected exception of type " + typeof(TException).Name); } +#if !NET35 public static Task ThrowAsync(Func test) => ThrowAsync(test); public static async Task ThrowAsync(Func test) @@ -47,7 +50,7 @@ public static async Task ThrowAsync(Func test) throw new Exception("Expected exception of type " + typeof(TException).Name); } - +#endif public static void NotThrow(Action testAction) => NotThrow(testAction); public static void NotThrow(Action testAction) diff --git a/AgileMapper.UnitTests/ShouldExtensions.cs b/AgileMapper.UnitTests/ShouldExtensions.cs index 491c38b0b..511086e50 100644 --- a/AgileMapper.UnitTests/ShouldExtensions.cs +++ b/AgileMapper.UnitTests/ShouldExtensions.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; + using AgileMapper.Extensions.Internal; using NetStandardPolyfills; using ReadableExpressions.Extensions; @@ -125,8 +126,8 @@ public static void ShouldBe(this IEnumerable actualValues, IEnumerab void FailTest() { Asplode( - string.Join(", ", expectedValues.Select(v => v.ToString())), - string.Join(", ", actualValues.Select(v => v.ToString()))); + expectedValues.Project(v => v.ToString()).Join(", "), + actualValues.Project(v => v.ToString()).Join(", ")); } using (var expectedEnumerator = expectedValues.GetEnumerator()) @@ -169,7 +170,7 @@ public static void ShouldBe(this IEnumerable actualValues, IEnumerab { actualValues.ShouldNotBeNull(); actualValues.ShouldNotBeEmpty(); - actualValues.Select(converter).SequenceEqual(expectedValues).ShouldBeTrue(); + actualValues.Project(converter).SequenceEqual(expectedValues).ShouldBeTrue(); } public static void ShouldNotBe(this TActual value, TExpected expectedValue) @@ -262,6 +263,24 @@ public static void ShouldBeNull(this T actual, string errorMessage = null) } } + public static void ShouldHaveFlag(this Enum actual, Enum expected) + => HasFlag(actual, expected).ShouldBeTrue(); + + public static void ShouldNotHaveFlag(this Enum actual, Enum notExpected) + => HasFlag(actual, notExpected).ShouldBeFalse(); + + private static bool HasFlag(Enum actual, Enum expected) + { +#if NET35 + var actualValue = Convert.ToUInt64(actual); + var expectedValue = Convert.ToUInt64(expected); + + return (actualValue & expectedValue) == expectedValue; +#else + return actual.HasFlag(expected); +#endif + } + public static T ShouldHaveSingleItem(this IEnumerable items) { using (var enumerator = items.GetEnumerator()) diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBools.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBools.cs index 955034b96..6d6601468 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBools.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBools.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToBools { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBytes.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBytes.cs index 7ae1d97b1..aa8c03180 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBytes.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToBytes.cs @@ -2,8 +2,13 @@ { using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToBytes { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToCharacters.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToCharacters.cs index eaa01f5d7..f9fb523d7 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToCharacters.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToCharacters.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToCharacters { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDateTimes.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDateTimes.cs index bc4097021..c3c69f0c1 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDateTimes.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDateTimes.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToDateTimes { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDecimals.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDecimals.cs index 71ea36ed8..ef818b73d 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDecimals.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDecimals.cs @@ -2,8 +2,13 @@ { using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToDecimals { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDoubles.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDoubles.cs index e9283b5ac..333f73854 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDoubles.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToDoubles.cs @@ -3,8 +3,13 @@ using System; using System.Collections.ObjectModel; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToDoubles { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToEnums.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToEnums.cs index 461188346..3d7724370 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToEnums.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToEnums.cs @@ -1,9 +1,14 @@ namespace AgileObjects.AgileMapper.UnitTests.SimpleTypeConversion { using TestClasses; - using Xunit; using static TestClasses.Title; +#if !NET35 + using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToEnums { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToFlagsEnums.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToFlagsEnums.cs index 3c5ee218e..ecdeaf9aa 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToFlagsEnums.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToFlagsEnums.cs @@ -1,9 +1,14 @@ namespace AgileObjects.AgileMapper.UnitTests.SimpleTypeConversion { using TestClasses; - using Xunit; using static TestClasses.Status; +#if !NET35 + using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToFlagsEnums { [Fact] @@ -21,9 +26,9 @@ public void ShouldMapAMultiValueShortToAFlagsEnum() var source = new PublicField { Value = (short)(InProgress | Assigned) }; var result = Mapper.Map(source).ToANew>(); - result.Value.HasFlag(InProgress).ShouldBeTrue(); - result.Value.HasFlag(Assigned).ShouldBeTrue(); - result.Value.HasFlag(Cancelled).ShouldBeFalse(); + result.Value.ShouldHaveFlag(InProgress); + result.Value.ShouldHaveFlag(Assigned); + result.Value.ShouldNotHaveFlag(Cancelled); result.Value.ShouldBe(InProgress | Assigned); } diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToGuids.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToGuids.cs index ca37d912a..a3ff34f99 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToGuids.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToGuids.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToGuids { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToInts.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToInts.cs index c774de22e..42744c459 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToInts.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToInts.cs @@ -3,8 +3,13 @@ using System.Collections.Generic; using System.Globalization; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToInts { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToLongs.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToLongs.cs index 488fc42a4..3f46af755 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToLongs.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToLongs.cs @@ -2,8 +2,13 @@ { using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToLongs { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToShorts.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToShorts.cs index 43cdc9bed..5f2cd976e 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToShorts.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToShorts.cs @@ -2,8 +2,13 @@ { using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToShorts { [Fact] diff --git a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToStrings.cs b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToStrings.cs index 27fc03dd0..7b3e5c5fd 100644 --- a/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToStrings.cs +++ b/AgileMapper.UnitTests/SimpleTypeConversion/WhenConvertingToStrings.cs @@ -3,8 +3,13 @@ using System; using System.Text; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConvertingToStrings { [Fact] diff --git a/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructCreationCallbacks.cs b/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructCreationCallbacks.cs index a8547fa50..b1737b088 100644 --- a/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructCreationCallbacks.cs +++ b/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructCreationCallbacks.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Structs.Configuration { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringStructCreationCallbacks { [Fact] diff --git a/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructDataSources.cs b/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructDataSources.cs index b0e03065c..d58cb49a5 100644 --- a/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructDataSources.cs +++ b/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructDataSources.cs @@ -3,8 +3,13 @@ using System; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringStructDataSources { [Fact] diff --git a/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructMappingCallbacks.cs b/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructMappingCallbacks.cs index fb50f5e6c..7bc369f33 100644 --- a/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructMappingCallbacks.cs +++ b/AgileMapper.UnitTests/Structs/Configuration/WhenConfiguringStructMappingCallbacks.cs @@ -5,8 +5,13 @@ using AgileMapper.Configuration; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenConfiguringStructMappingCallbacks { [Fact] diff --git a/AgileMapper.UnitTests/Structs/Dictionaries/WhenMappingFromDictionariesToStructs.cs b/AgileMapper.UnitTests/Structs/Dictionaries/WhenMappingFromDictionariesToStructs.cs index 3ec0dc681..55046b8cc 100644 --- a/AgileMapper.UnitTests/Structs/Dictionaries/WhenMappingFromDictionariesToStructs.cs +++ b/AgileMapper.UnitTests/Structs/Dictionaries/WhenMappingFromDictionariesToStructs.cs @@ -4,8 +4,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingFromDictionariesToStructs { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingOnToStructMembers.cs b/AgileMapper.UnitTests/Structs/WhenMappingOnToStructMembers.cs index 5353becff..92bcdca9f 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingOnToStructMembers.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingOnToStructMembers.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Structs { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToStructMembers { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingOnToStructs.cs b/AgileMapper.UnitTests/Structs/WhenMappingOnToStructs.cs index ad9c0ce80..6cd6f80b8 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingOnToStructs.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingOnToStructs.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Structs { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToStructs { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingOverStructMembers.cs b/AgileMapper.UnitTests/Structs/WhenMappingOverStructMembers.cs index 07ad933c5..0f8bb783e 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingOverStructMembers.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingOverStructMembers.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Structs { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverStructMembers { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingOverStructs.cs b/AgileMapper.UnitTests/Structs/WhenMappingOverStructs.cs index 9c5d58ceb..d4998d35a 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingOverStructs.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingOverStructs.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverStructs { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingToNewStructMembers.cs b/AgileMapper.UnitTests/Structs/WhenMappingToNewStructMembers.cs index 023be87f2..49a668df3 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingToNewStructMembers.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingToNewStructMembers.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Structs { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewStructMembers { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingToNewStructs.cs b/AgileMapper.UnitTests/Structs/WhenMappingToNewStructs.cs index f3df470fd..2b168c74b 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingToNewStructs.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingToNewStructs.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests.Structs { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewStructs { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingToStructEnumerables.cs b/AgileMapper.UnitTests/Structs/WhenMappingToStructEnumerables.cs index d33a060e7..852443eb3 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingToStructEnumerables.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingToStructEnumerables.cs @@ -4,9 +4,14 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; - using Xunit; using static System.Decimal; +#if !NET35 + using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToStructEnumerables { [Fact] diff --git a/AgileMapper.UnitTests/Structs/WhenMappingToUnmappableStructMembers.cs b/AgileMapper.UnitTests/Structs/WhenMappingToUnmappableStructMembers.cs index 0f3b65b28..f95dcd279 100644 --- a/AgileMapper.UnitTests/Structs/WhenMappingToUnmappableStructMembers.cs +++ b/AgileMapper.UnitTests/Structs/WhenMappingToUnmappableStructMembers.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToUnmappableStructMembers { [Fact] diff --git a/AgileMapper.UnitTests/TestClasses/EntityBase.cs b/AgileMapper.UnitTests/TestClasses/EntityBase.cs index b1a666775..1b99da788 100644 --- a/AgileMapper.UnitTests/TestClasses/EntityBase.cs +++ b/AgileMapper.UnitTests/TestClasses/EntityBase.cs @@ -1,6 +1,12 @@ namespace AgileObjects.AgileMapper.UnitTests.TestClasses { +#if NET35 + using System; + + internal sealed class KeyAttribute : Attribute { } +#else using System.ComponentModel.DataAnnotations; +#endif internal abstract class EntityBase { @@ -8,3 +14,4 @@ internal abstract class EntityBase public int Id { get; set; } } } + diff --git a/AgileMapper.UnitTests/WhenAnalysingCollections.cs b/AgileMapper.UnitTests/WhenAnalysingCollections.cs index 591cd4e3f..5016bfa4b 100644 --- a/AgileMapper.UnitTests/WhenAnalysingCollections.cs +++ b/AgileMapper.UnitTests/WhenAnalysingCollections.cs @@ -4,8 +4,13 @@ using System.Linq; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenAnalysingCollections { [Fact] diff --git a/AgileMapper.UnitTests/WhenFlatteningToDictionaries.cs b/AgileMapper.UnitTests/WhenFlatteningToDictionaries.cs index 3444f0651..ffcdf44b0 100644 --- a/AgileMapper.UnitTests/WhenFlatteningToDictionaries.cs +++ b/AgileMapper.UnitTests/WhenFlatteningToDictionaries.cs @@ -3,8 +3,13 @@ using System; using System.Collections.Generic; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenFlatteningToDictionaries { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingCircularReferences.cs b/AgileMapper.UnitTests/WhenMappingCircularReferences.cs index 26f14b358..35ba72636 100644 --- a/AgileMapper.UnitTests/WhenMappingCircularReferences.cs +++ b/AgileMapper.UnitTests/WhenMappingCircularReferences.cs @@ -7,8 +7,13 @@ using AgileMapper.Extensions; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingCircularReferences { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingDerivedTypes.cs b/AgileMapper.UnitTests/WhenMappingDerivedTypes.cs index 3c256a62e..1ea197ea0 100644 --- a/AgileMapper.UnitTests/WhenMappingDerivedTypes.cs +++ b/AgileMapper.UnitTests/WhenMappingDerivedTypes.cs @@ -6,8 +6,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingDerivedTypes { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingEntities.cs b/AgileMapper.UnitTests/WhenMappingEntities.cs index c44da6669..8e37d70c7 100644 --- a/AgileMapper.UnitTests/WhenMappingEntities.cs +++ b/AgileMapper.UnitTests/WhenMappingEntities.cs @@ -5,8 +5,13 @@ using System.Linq; using AgileMapper.Extensions; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingEntities { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingOnToComplexTypeMembers.cs b/AgileMapper.UnitTests/WhenMappingOnToComplexTypeMembers.cs index d2ed57e53..52abb7c59 100644 --- a/AgileMapper.UnitTests/WhenMappingOnToComplexTypeMembers.cs +++ b/AgileMapper.UnitTests/WhenMappingOnToComplexTypeMembers.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToComplexTypeMembers { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingOnToComplexTypes.cs b/AgileMapper.UnitTests/WhenMappingOnToComplexTypes.cs index 1555fc498..256138160 100644 --- a/AgileMapper.UnitTests/WhenMappingOnToComplexTypes.cs +++ b/AgileMapper.UnitTests/WhenMappingOnToComplexTypes.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToComplexTypes { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingOnToEnumerableMembers.cs b/AgileMapper.UnitTests/WhenMappingOnToEnumerableMembers.cs index df151b40f..d99e1bbf8 100644 --- a/AgileMapper.UnitTests/WhenMappingOnToEnumerableMembers.cs +++ b/AgileMapper.UnitTests/WhenMappingOnToEnumerableMembers.cs @@ -5,8 +5,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToEnumerableMembers { [Fact] @@ -89,6 +94,7 @@ public void ShouldMergeAComplexTypeCollection() result.Value.ShouldBe(r => r.Value, 123, 456, 789); } +#if !NET35 [Fact] public void ShouldMergeAComplexTypeIReadOnlyCollectionList() { @@ -107,7 +113,7 @@ public void ShouldMergeAComplexTypeIReadOnlyCollectionList() result.Value.ShouldBeSameAs(target.Value); result.Value.ShouldBe(r => r.Value, 123, 456, 789); } - +#endif [Fact] public void ShouldMergeAnIdentifiableComplexTypeList() { @@ -165,6 +171,7 @@ public void ShouldMergeAnIdentifiableComplexTypeReadOnlyCollection() result.Value.ShouldBe(r => r.ProductId, "Science", "Magic"); } +#if !NET35 [Fact] public void ShouldMergeAnIdentifiableComplexTypeIReadOnlyCollectionArray() { @@ -193,7 +200,7 @@ public void ShouldMergeAnIdentifiableComplexTypeIReadOnlyCollectionArray() result.Value.Second().Price.ShouldBe(1000.00); result.Value.ShouldBe(r => r.ProductId, "Magic", "Science"); } - +#endif [Fact] public void ShouldHandleANullSourceMember() { @@ -246,6 +253,7 @@ public void ShouldHandleANullIdentifiableTargetEnumerable() result.Value.First().Id.ShouldBe(source.Value.First().Id); } +#if !NET35 [Fact] public void ShouldHandleANullIReadOnlyCollection() { @@ -261,7 +269,7 @@ public void ShouldHandleANullIReadOnlyCollection() result.Value.ShouldNotBeNull(); result.Value.ShouldBe('X', 'Y', 'Z'); } - +#endif [Fact] public void ShouldHandleNoMatchingSourceMember() { diff --git a/AgileMapper.UnitTests/WhenMappingOnToEnumerables.cs b/AgileMapper.UnitTests/WhenMappingOnToEnumerables.cs index 549af7429..a2c3d93f4 100644 --- a/AgileMapper.UnitTests/WhenMappingOnToEnumerables.cs +++ b/AgileMapper.UnitTests/WhenMappingOnToEnumerables.cs @@ -5,8 +5,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOnToEnumerables { [Fact] @@ -134,14 +139,16 @@ public void ShouldUpdateAnExistingObject() [Fact] public void ShouldUpdateAnExistingObjectByConvertedId() { + var id = Guid.NewGuid(); + var source = new[] { - new { Id = Guid.NewGuid().ToString(), Name = "Anonymous" } + new { Id = id.ToString(), Name = "Anonymous" } }; var target = new List { - new Person { Id = Guid.Parse(source.First().Id) } + new Person { Id = id } }; var originalObject = target.First(); diff --git a/AgileMapper.UnitTests/WhenMappingOverComplexTypeMembers.cs b/AgileMapper.UnitTests/WhenMappingOverComplexTypeMembers.cs index 81a3e146d..f4e5b03ce 100644 --- a/AgileMapper.UnitTests/WhenMappingOverComplexTypeMembers.cs +++ b/AgileMapper.UnitTests/WhenMappingOverComplexTypeMembers.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverComplexTypeMembers { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingOverComplexTypes.cs b/AgileMapper.UnitTests/WhenMappingOverComplexTypes.cs index 385eeafbf..b0fcc0f95 100644 --- a/AgileMapper.UnitTests/WhenMappingOverComplexTypes.cs +++ b/AgileMapper.UnitTests/WhenMappingOverComplexTypes.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverComplexTypes { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingOverEnumerableMembers.cs b/AgileMapper.UnitTests/WhenMappingOverEnumerableMembers.cs index 1aad2d506..e4dbda628 100644 --- a/AgileMapper.UnitTests/WhenMappingOverEnumerableMembers.cs +++ b/AgileMapper.UnitTests/WhenMappingOverEnumerableMembers.cs @@ -5,9 +5,14 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; - using Xunit; using static System.Decimal; +#if !NET35 + using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverEnumerableMembers { [Fact] @@ -68,6 +73,7 @@ public void ShouldOverwriteAReadOnlyCollection() result.Value.ShouldBe(MinValue, MaxValue); } +#if !NET35 [Fact] public void ShouldOverwriteAnIReadOnlyCollectionCollection() { @@ -90,7 +96,7 @@ public void ShouldOverwriteAnIReadOnlyCollectionCollection() result.Value.ShouldNotBeSameAs(preMappingCollection); result.Value.ShouldBe(MinusOne, Zero); } - +#endif [Fact] public void ShouldOverwriteAComplexTypeCollection() { @@ -192,6 +198,7 @@ public void ShouldHandleAReadOnlyNestedReadOnlyCollection() result.Value.ShouldBe("A", "B", "C"); } +#if !NET35 [Fact] public void ShouldHandleANullReadOnlyNestedIReadOnlyCollection() { @@ -201,5 +208,6 @@ public void ShouldHandleANullReadOnlyNestedIReadOnlyCollection() result.Value.ShouldBeNull(); } +#endif } } diff --git a/AgileMapper.UnitTests/WhenMappingOverEnumerables.cs b/AgileMapper.UnitTests/WhenMappingOverEnumerables.cs index 6a3a6ea8b..e378a75ca 100644 --- a/AgileMapper.UnitTests/WhenMappingOverEnumerables.cs +++ b/AgileMapper.UnitTests/WhenMappingOverEnumerables.cs @@ -5,8 +5,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingOverEnumerables { [Fact] @@ -143,6 +148,7 @@ public void ShouldOverwriteAnExistingObjectByIdInAReadOnlyCollection() result.First().Name.ShouldBe("Homer"); } +#if !NET35 [Fact] public void ShouldOverwriteASimpleTypeIReadOnlyCollectionArray() { @@ -176,7 +182,7 @@ public void ShouldOverwriteAComplexTypeIReadOnlyCollectionList() result.First().ProductId.ShouldBe("khujygtf"); result.First().Price.ShouldBe(0.75m); } - +#endif [Fact] public void ShouldOverwriteUsingAConfiguredDataSource() { diff --git a/AgileMapper.UnitTests/WhenMappingToConstructors.cs b/AgileMapper.UnitTests/WhenMappingToConstructors.cs index 59682d15a..271425d70 100644 --- a/AgileMapper.UnitTests/WhenMappingToConstructors.cs +++ b/AgileMapper.UnitTests/WhenMappingToConstructors.cs @@ -2,8 +2,13 @@ { using System; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToConstructors { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingToMetaMembers.cs b/AgileMapper.UnitTests/WhenMappingToMetaMembers.cs index b5a49b997..497fbf955 100644 --- a/AgileMapper.UnitTests/WhenMappingToMetaMembers.cs +++ b/AgileMapper.UnitTests/WhenMappingToMetaMembers.cs @@ -5,8 +5,13 @@ using System.Collections.ObjectModel; using AgileMapper.Extensions; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToMetaMembers { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingToNewComplexTypeMembers.cs b/AgileMapper.UnitTests/WhenMappingToNewComplexTypeMembers.cs index f795d42a4..e85e694f0 100644 --- a/AgileMapper.UnitTests/WhenMappingToNewComplexTypeMembers.cs +++ b/AgileMapper.UnitTests/WhenMappingToNewComplexTypeMembers.cs @@ -4,8 +4,13 @@ using AgileMapper.Extensions; using AgileMapper.Extensions.Internal; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewComplexTypeMembers { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingToNewComplexTypes.cs b/AgileMapper.UnitTests/WhenMappingToNewComplexTypes.cs index 1d37d3e67..35af7996e 100644 --- a/AgileMapper.UnitTests/WhenMappingToNewComplexTypes.cs +++ b/AgileMapper.UnitTests/WhenMappingToNewComplexTypes.cs @@ -1,8 +1,13 @@ namespace AgileObjects.AgileMapper.UnitTests { using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewComplexTypes { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingToNewEnumerableMembers.cs b/AgileMapper.UnitTests/WhenMappingToNewEnumerableMembers.cs index ba2583826..517f3a2e4 100644 --- a/AgileMapper.UnitTests/WhenMappingToNewEnumerableMembers.cs +++ b/AgileMapper.UnitTests/WhenMappingToNewEnumerableMembers.cs @@ -4,8 +4,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewEnumerableMembers { [Fact] diff --git a/AgileMapper.UnitTests/WhenMappingToNewEnumerables.cs b/AgileMapper.UnitTests/WhenMappingToNewEnumerables.cs index 45dc05b5a..11f4f826b 100644 --- a/AgileMapper.UnitTests/WhenMappingToNewEnumerables.cs +++ b/AgileMapper.UnitTests/WhenMappingToNewEnumerables.cs @@ -4,8 +4,13 @@ using System.Collections.ObjectModel; using System.Linq; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenMappingToNewEnumerables { [Fact] @@ -109,6 +114,7 @@ public void ShouldMapFromAReadOnlyCollection() result.ShouldBe(1, 2, 3); } +#if !NET35 [Fact] public void ShouldCreateAnIReadOnlyCollection() { @@ -118,7 +124,7 @@ public void ShouldCreateAnIReadOnlyCollection() result.ShouldNotBeNull(); result.ShouldBe((short)1, (short)2, (short)3); } - +#endif [Fact] public void ShouldHandleANullComplexTypeElement() { diff --git a/AgileMapper.UnitTests/WhenUsingPartialTrust.cs b/AgileMapper.UnitTests/WhenUsingPartialTrust.cs index e8bcb1132..3caa285d7 100644 --- a/AgileMapper.UnitTests/WhenUsingPartialTrust.cs +++ b/AgileMapper.UnitTests/WhenUsingPartialTrust.cs @@ -16,6 +16,18 @@ public void ShouldPerformASimpleMapping() ExecuteInPartialTrust(helper => helper.TestSimpleMapping()); } + [Fact] + public void ShouldPerformAStringToEnumMapping() + { + ExecuteInPartialTrust(helper => helper.TestStringToEnumMapping()); + } + + [Fact] + public void ShouldPerformADoubleToCharacterMapping() + { + ExecuteInPartialTrust(helper => helper.TestDoubleToCharacterMapping()); + } + [Fact] public void ShouldPerformAComplexMapping() { @@ -34,6 +46,12 @@ public void ShouldPerformARuntimeTypedMapping() ExecuteInPartialTrust(helper => helper.TestRuntimeTypedMapping()); } + [Fact] + public void ShouldPerformASourceDictionaryMapping() + { + ExecuteInPartialTrust(helper => helper.TestSourceDictionaryMapping()); + } + [Fact] public void ShouldPerformAComplexMappingWithReflectionPermitted() { @@ -125,6 +143,22 @@ public void TestSimpleMapping() Assert.Equal("I don't trust you...", result.Value); } + public void TestStringToEnumMapping() + { + var source = new PublicProperty { Value = "Mr" }; + var result = Mapper.Map(source).ToANew>(); + + Assert.Equal(Title.Mr, result.Value); + } + + public void TestDoubleToCharacterMapping() + { + var source = new PublicProperty { Value = 7 }; + var result = Mapper.Map(source).ToANew>(); + + Assert.Equal('7', result.Value); + } + public void TestComplexMapping() { var source = new Customer { Name = "Untrusted!", Discount = 0.2m }; @@ -143,6 +177,17 @@ public void TestDerivedMapping() Assert.Equal(0.1, result.Discount); } + public void TestSourceDictionaryMapping() + { + var source = new Dictionary + { + ["Value.Value"] = "123" + }; + var result = Mapper.Map(source).ToANew>>(); + + Assert.Equal(123, result.Value.Value); + } + public void TestRuntimeTypedMapping() { var source = new PublicProperty diff --git a/AgileMapper.UnitTests/WhenValidatingMappings.cs b/AgileMapper.UnitTests/WhenValidatingMappings.cs index fc4e9c48d..aad44c7b6 100644 --- a/AgileMapper.UnitTests/WhenValidatingMappings.cs +++ b/AgileMapper.UnitTests/WhenValidatingMappings.cs @@ -4,8 +4,13 @@ using System.Collections.Generic; using TestClasses; using Validation; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenValidatingMappings { [Fact] diff --git a/AgileMapper.UnitTests/WhenViewingMappingPlans.cs b/AgileMapper.UnitTests/WhenViewingMappingPlans.cs index acfe088b3..84f20ffd9 100644 --- a/AgileMapper.UnitTests/WhenViewingMappingPlans.cs +++ b/AgileMapper.UnitTests/WhenViewingMappingPlans.cs @@ -6,8 +6,13 @@ using System.Text.RegularExpressions; using MoreTestClasses; using TestClasses; +#if !NET35 using Xunit; +#else + using Fact = NUnit.Framework.TestAttribute; + [NUnit.Framework.TestFixture] +#endif public class WhenViewingMappingPlans { [Fact] diff --git a/AgileMapper.UnitTests/app.config b/AgileMapper.UnitTests/app.config index b4c3aaacc..b1d125491 100644 --- a/AgileMapper.UnitTests/app.config +++ b/AgileMapper.UnitTests/app.config @@ -4,7 +4,7 @@ - + diff --git a/AgileMapper.UnitTests/packages.config b/AgileMapper.UnitTests/packages.config index 719216dc0..1e81f9927 100644 --- a/AgileMapper.UnitTests/packages.config +++ b/AgileMapper.UnitTests/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/AgileMapper.sln b/AgileMapper.sln index 1ab866155..e44e9c731 100644 --- a/AgileMapper.sln +++ b/AgileMapper.sln @@ -46,6 +46,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileMapper.UnitTests.Orms. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileMapper.UnitTests.NetCore2.1", "AgileMapper.UnitTests.NetCore2.1\AgileMapper.UnitTests.NetCore2.1.csproj", "{26C562E5-43EB-47D7-801A-CF772C7B3A0B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgileMapper.UnitTests.Net35", "AgileMapper.UnitTests.Net35\AgileMapper.UnitTests.Net35.csproj", "{E0706509-4A4B-4C0D-A3B2-4A713FFC6ED4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -116,6 +118,10 @@ Global {26C562E5-43EB-47D7-801A-CF772C7B3A0B}.Debug|Any CPU.Build.0 = Debug|Any CPU {26C562E5-43EB-47D7-801A-CF772C7B3A0B}.Release|Any CPU.ActiveCfg = Release|Any CPU {26C562E5-43EB-47D7-801A-CF772C7B3A0B}.Release|Any CPU.Build.0 = Release|Any CPU + {E0706509-4A4B-4C0D-A3B2-4A713FFC6ED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0706509-4A4B-4C0D-A3B2-4A713FFC6ED4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0706509-4A4B-4C0D-A3B2-4A713FFC6ED4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0706509-4A4B-4C0D-A3B2-4A713FFC6ED4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AgileMapper.sln.DotSettings b/AgileMapper.sln.DotSettings index 10b838ca2..778c0de43 100644 --- a/AgileMapper.sln.DotSettings +++ b/AgileMapper.sln.DotSettings @@ -1,3 +1,5 @@  + <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> + <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> <data><IncludeFilters /><ExcludeFilters /></data> <data><AttributeFilter ClassMask="AgileObjects.AgileMapper.ExcludeFromCodeCoverageAttribute" IsEnabled="True" /></data> \ No newline at end of file diff --git a/AgileMapper/AgileMapper.csproj b/AgileMapper/AgileMapper.csproj index 8074fffa7..9ad050537 100644 --- a/AgileMapper/AgileMapper.csproj +++ b/AgileMapper/AgileMapper.csproj @@ -5,7 +5,7 @@ A zero-configuration, highly-configurable object-object mapper with viewable execution plans. Projects queries, transforms, deep clones, updates and merges via extension methods, or a static or instance API. Targets .NET Standard 1.0 and .NET 4.0. A zero-configuration, highly-configurable object-object mapper with viewable execution plans. Projects queries, transforms, deep clones, updates and merges via extension methods, or a static or instance API. Targets .NET Standard 1.0 and .NET 4.0. AgileObjects.AgileMapper - netstandard1.0;netstandard1.3;net40 + netstandard1.0;netstandard1.3;net35;net40 true true AgileObjects.AgileMapper @@ -15,7 +15,7 @@ https://github.com/AgileObjects/AgileMapper https://github.com/agileobjects/AgileMapper/blob/master/LICENCE.md $(PackageTargetFallback);dnxcore50 - 1.6.0 + 1.6.1 false false AgileObjects.AgileMapper @@ -23,8 +23,8 @@ - - + + @@ -35,7 +35,7 @@ - $(DefineConstants);NET_STANDARD; + $(DefineConstants);NET_STANDARD;DYNAMIC_SUPPORTED; @@ -47,7 +47,7 @@ - $(DefineConstants);NET_STANDARD;SERIALIZATION_SUPPORTED; + $(DefineConstants);NET_STANDARD;SERIALIZATION_SUPPORTED;DYNAMIC_SUPPORTED; @@ -56,7 +56,17 @@ - $(DefineConstants);SERIALIZATION_SUPPORTED; + $(DefineConstants);SERIALIZATION_SUPPORTED;DYNAMIC_SUPPORTED; + + + + + 1.1.2 + + + + + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client diff --git a/AgileMapper/Api/Configuration/CustomDataSourceTargetMemberSpecifier.cs b/AgileMapper/Api/Configuration/CustomDataSourceTargetMemberSpecifier.cs index 8f26eebc2..a76f26bf3 100644 --- a/AgileMapper/Api/Configuration/CustomDataSourceTargetMemberSpecifier.cs +++ b/AgileMapper/Api/Configuration/CustomDataSourceTargetMemberSpecifier.cs @@ -14,7 +14,12 @@ using NetStandardPolyfills; using Projection; using ReadableExpressions.Extensions; - +#if NET35 + using Dlr = Microsoft.Scripting.Ast; + using static Microsoft.Scripting.Ast.Expression; +#else + using static System.Linq.Expressions.Expression; +#endif internal class CustomDataSourceTargetMemberSpecifier : ICustomMappingDataSourceTargetMemberSpecifier, @@ -93,8 +98,11 @@ private ConfiguredDataSourceFactory CreateFromLambda(LambdaExpress { return new ConfiguredDictionaryEntryDataSourceFactory(_configInfo, valueLambdaInfo, dictionaryEntryMember); } - +#if NET35 + return new ConfiguredDataSourceFactory(_configInfo, valueLambdaInfo, targetMemberLambda.ToDlrExpression()); +#else return new ConfiguredDataSourceFactory(_configInfo, valueLambdaInfo, targetMemberLambda); +#endif } private bool IsDictionaryEntry(LambdaExpression targetMemberLambda, out DictionaryTargetMember entryMember) @@ -146,22 +154,29 @@ private ConfiguredLambdaInfo GetValueLambdaInfo() return _customValueLambdaInfo; } - if ((_customValueLambda.Body.NodeType != ExpressionType.Constant) || +#if NET35 + var customValueLambda = _customValueLambda.ToDlrExpression(); + const Dlr.ExpressionType CONSTANT = Dlr.ExpressionType.Constant; +#else + var customValueLambda = _customValueLambda; + const ExpressionType CONSTANT = ExpressionType.Constant; +#endif + if ((customValueLambda.Body.NodeType != CONSTANT) || (typeof(TTargetValue) == typeof(object)) || - _customValueLambda.ReturnType.IsAssignableTo(typeof(TTargetValue))) + customValueLambda.ReturnType.IsAssignableTo(typeof(TTargetValue))) { - return ConfiguredLambdaInfo.For(_customValueLambda); + return ConfiguredLambdaInfo.For(customValueLambda); } var convertedConstantValue = _configInfo .MapperContext .ValueConverters - .GetConversion(_customValueLambda.Body, typeof(TTargetValue)); + .GetConversion(customValueLambda.Body, typeof(TTargetValue)); - var valueLambda = Expression.Lambda>(convertedConstantValue); + var valueLambda = Lambda>(convertedConstantValue); var valueFunc = valueLambda.Compile(); var value = valueFunc.Invoke().ToConstantExpression(typeof(TTargetValue)); - var constantValueLambda = Expression.Lambda>(value); + var constantValueLambda = Lambda>(value); var valueLambdaInfo = ConfiguredLambdaInfo.For(constantValueLambda); return valueLambdaInfo; diff --git a/AgileMapper/Api/Configuration/Dictionaries/CustomDictionaryMappingTargetMemberSpecifier.cs b/AgileMapper/Api/Configuration/Dictionaries/CustomDictionaryMappingTargetMemberSpecifier.cs index ea636d44b..0aee57049 100644 --- a/AgileMapper/Api/Configuration/Dictionaries/CustomDictionaryMappingTargetMemberSpecifier.cs +++ b/AgileMapper/Api/Configuration/Dictionaries/CustomDictionaryMappingTargetMemberSpecifier.cs @@ -5,7 +5,12 @@ namespace AgileObjects.AgileMapper.Api.Configuration.Dictionaries using AgileMapper.Configuration; using AgileMapper.Configuration.Dictionaries; using DataSources; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif +#if NET35 + using Extensions.Internal; +#endif /// /// Provides options for specifying a target member to which a dictionary configuration should apply. @@ -15,8 +20,11 @@ namespace AgileObjects.AgileMapper.Api.Configuration.Dictionaries /// /// The target type to which the configuration should apply. public class CustomDictionaryMappingTargetMemberSpecifier : - CustomDictionaryKeySpecifierBase, + CustomDictionaryKeySpecifierBase +#if DYNAMIC_SUPPORTED + , ICustomDynamicMappingTargetMemberSpecifier +#endif { private readonly string _key; private readonly Action _dictionarySettingsAction; @@ -57,13 +65,22 @@ public ISourceDictionaryMappingConfigContinuation To>> targetSetMethod) => RegisterCustomKey(targetSetMethod); +#if DYNAMIC_SUPPORTED ISourceDynamicMappingConfigContinuation ICustomDynamicMappingTargetMemberSpecifier.To( Expression> targetMember) => RegisterCustomKey(targetMember); +#endif private DictionaryMappingConfigContinuation RegisterCustomKey(LambdaExpression targetMemberLambda) { - var configuredKey = CustomDictionaryKey.ForTargetMember(_key, targetMemberLambda, ConfigInfo); + var configuredKey = CustomDictionaryKey.ForTargetMember( + _key, +#if NET35 + targetMemberLambda.ToDlrExpression(), +#else + targetMemberLambda, +#endif + ConfigInfo); UserConfigurations.ThrowIfConflictingIgnoredMemberExists(configuredKey); UserConfigurations.ThrowIfConflictingDataSourceExists(configuredKey, GetConflictMessage); diff --git a/AgileMapper/Api/Configuration/Dictionaries/CustomTargetDictionaryKeySpecifier.cs b/AgileMapper/Api/Configuration/Dictionaries/CustomTargetDictionaryKeySpecifier.cs index 5990ee626..1f71b3136 100644 --- a/AgileMapper/Api/Configuration/Dictionaries/CustomTargetDictionaryKeySpecifier.cs +++ b/AgileMapper/Api/Configuration/Dictionaries/CustomTargetDictionaryKeySpecifier.cs @@ -3,13 +3,18 @@ namespace AgileObjects.AgileMapper.Api.Configuration.Dictionaries using System; using AgileMapper.Configuration; using AgileMapper.Configuration.Dictionaries; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif using Members; internal class CustomTargetDictionaryKeySpecifier : CustomDictionaryKeySpecifierBase, - ICustomTargetDictionaryKeySpecifier, + ICustomTargetDictionaryKeySpecifier +#if DYNAMIC_SUPPORTED + , ICustomTargetDynamicMemberNameSpecifier +#endif { internal CustomTargetDictionaryKeySpecifier(MappingConfigInfo configInfo, QualifiedMember sourceMember) : base(configInfo, sourceMember) @@ -21,8 +26,10 @@ internal CustomTargetDictionaryKeySpecifier(MappingConfigInfo configInfo, Qualif public ITargetDictionaryMappingConfigContinuation ToFullKey(string fullMemberNameKey) => RegisterFullMemberNameKey(fullMemberNameKey); +#if DYNAMIC_SUPPORTED public ITargetDynamicMappingConfigContinuation ToFullMemberName(string fullMemberName) => RegisterFullMemberNameKey(fullMemberName); +#endif private DictionaryMappingConfigContinuation RegisterFullMemberNameKey(string fullMemberNameKey) => RegisterMemberKey(fullMemberNameKey, (settings, customKey) => settings.AddFullKey(customKey)); @@ -34,8 +41,10 @@ private DictionaryMappingConfigContinuation RegisterFullMemberN public ITargetDictionaryMappingConfigContinuation ToMemberNameKey(string memberNameKeyPart) => RegisterMemberNamePartKey(memberNameKeyPart); +#if DYNAMIC_SUPPORTED public ITargetDynamicMappingConfigContinuation ToMemberName(string memberName) => RegisterMemberNamePartKey(memberName); +#endif private DictionaryMappingConfigContinuation RegisterMemberNamePartKey(string memberNameKeyPart) { diff --git a/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigContinuation.cs b/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigContinuation.cs index 9f4a22172..80bb24a8b 100644 --- a/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigContinuation.cs +++ b/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigContinuation.cs @@ -1,13 +1,18 @@ namespace AgileObjects.AgileMapper.Api.Configuration.Dictionaries { using AgileMapper.Configuration; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif internal class DictionaryMappingConfigContinuation : ISourceDictionaryMappingConfigContinuation, - ITargetDictionaryMappingConfigContinuation, + ITargetDictionaryMappingConfigContinuation +#if DYNAMIC_SUPPORTED + , ISourceDynamicMappingConfigContinuation, ITargetDynamicMappingConfigContinuation +#endif { private readonly MappingConfigInfo _configInfo; @@ -22,10 +27,12 @@ ISourceDictionaryMappingConfigurator ISourceDictionaryMappingCo ITargetDictionaryMappingConfigurator ITargetDictionaryMappingConfigContinuation.And => new TargetDictionaryMappingConfigurator(_configInfo.Clone()); +#if DYNAMIC_SUPPORTED ISourceDynamicMappingConfigurator ISourceDynamicMappingConfigContinuation.And => new SourceDynamicMappingConfigurator(_configInfo.Clone()); ITargetDynamicMappingConfigurator ITargetDynamicMappingConfigContinuation.And => new TargetDynamicMappingConfigurator(_configInfo.Clone()); +#endif } } \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigurator.cs b/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigurator.cs index f864583c1..7736210d2 100644 --- a/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigurator.cs +++ b/AgileMapper/Api/Configuration/Dictionaries/DictionaryMappingConfigurator.cs @@ -2,15 +2,20 @@ namespace AgileObjects.AgileMapper.Api.Configuration.Dictionaries { using AgileMapper.Configuration; using AgileMapper.Configuration.Dictionaries; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif using static AgileMapper.Configuration.Dictionaries.DictionaryContext; internal class DictionaryMappingConfigurator : DictionaryMappingConfiguratorBase, IGlobalDictionarySettings, - ISourceDictionaryTargetTypeSelector, + ISourceDictionaryTargetTypeSelector +#if DYNAMIC_SUPPORTED + , IGlobalDynamicSettings, ISourceDynamicTargetTypeSelector +#endif { private readonly MappingConfigInfo _configInfo; @@ -30,13 +35,13 @@ IGlobalDictionarySettings IGlobalDictionarySettings.UseFlattened public ISourceDictionarySettings UseFlattenedTargetMemberNames() => RegisterFlattenedTargetMemberNames(GetConfigInfo(SourceOnly)); - +#if DYNAMIC_SUPPORTED IGlobalDynamicSettings IGlobalDynamicSettings.UseFlattenedTargetMemberNames() => RegisterFlattenedTargetMemberNames(GetGlobalConfigInfo(All)); ISourceDynamicSettings ISourceDynamicSettings.UseFlattenedTargetMemberNames() => RegisterFlattenedTargetMemberNames(GetConfigInfo(SourceOnly)); - +#endif private DictionaryMappingConfigurator RegisterFlattenedTargetMemberNames(MappingConfigInfo configInfo) { SetupFlattenedTargetMemberNames(configInfo); @@ -53,12 +58,13 @@ IGlobalDictionarySettings IGlobalDictionarySettings.UseMemberNam public ISourceDictionarySettings UseMemberNameSeparator(string separator) => RegisterMemberNameSeparator(separator, GetConfigInfo(SourceOnly)); +#if DYNAMIC_SUPPORTED IGlobalDynamicSettings IGlobalDynamicSettings.UseMemberNameSeparator(string separator) => RegisterMemberNameSeparator(separator, GetGlobalConfigInfo(All)); ISourceDynamicSettings ISourceDynamicSettings.UseMemberNameSeparator(string separator) => RegisterMemberNameSeparator(separator, GetConfigInfo(SourceOnly)); - +#endif private DictionaryMappingConfigurator RegisterMemberNameSeparator( string separator, MappingConfigInfo configInfo) @@ -77,12 +83,13 @@ IGlobalDictionarySettings IGlobalDictionarySettings.UseElementKe public ISourceDictionarySettings UseElementKeyPattern(string pattern) => RegisterElementKeyPattern(pattern, GetConfigInfo(SourceOnly)); +#if DYNAMIC_SUPPORTED IGlobalDynamicSettings IGlobalDynamicSettings.UseElementKeyPattern(string pattern) => RegisterElementKeyPattern(pattern, GetGlobalConfigInfo(All)); ISourceDynamicSettings ISourceDynamicSettings.UseElementKeyPattern(string pattern) => RegisterElementKeyPattern(pattern, GetConfigInfo(SourceOnly)); - +#endif private DictionaryMappingConfigurator RegisterElementKeyPattern( string pattern, MappingConfigInfo configInfo) @@ -110,11 +117,12 @@ MappingConfigStartingPoint IGlobalDictionarySettings.AndWhenMapping public ISourceDictionaryTargetTypeSelector AndWhenMapping => this; +#if DYNAMIC_SUPPORTED MappingConfigStartingPoint IGlobalDynamicSettings.AndWhenMapping => new MappingConfigStartingPoint(_configInfo.MapperContext); ISourceDynamicTargetTypeSelector ISourceDynamicSettings.AndWhenMapping => this; - +#endif #endregion #endregion @@ -143,6 +151,7 @@ private static SourceDictionaryMappingConfigurator CreateDictio #endregion +#if DYNAMIC_SUPPORTED #region Dynamics ISourceDynamicMappingConfigurator ISourceDynamicTargetTypeSelector.To() @@ -166,5 +175,6 @@ private static SourceDynamicMappingConfigurator CreateDynamicConfigurat => new SourceDynamicMappingConfigurator(configInfo); #endregion +#endif } } diff --git a/AgileMapper/Api/Configuration/Dynamics/ICustomDynamicMappingTargetMemberSpecifier.cs b/AgileMapper/Api/Configuration/Dynamics/ICustomDynamicMappingTargetMemberSpecifier.cs index 280fa4c93..0ae6318e5 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ICustomDynamicMappingTargetMemberSpecifier.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ICustomDynamicMappingTargetMemberSpecifier.cs @@ -1,4 +1,5 @@ -namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics +#if DYNAMIC_SUPPORTED +namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { using System; using System.Linq.Expressions; @@ -21,4 +22,5 @@ public interface ICustomDynamicMappingTargetMemberSpecifier ISourceDynamicMappingConfigContinuation To( Expression> targetMember); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ICustomTargetDynamicMemberNameSpecifier.cs b/AgileMapper/Api/Configuration/Dynamics/ICustomTargetDynamicMemberNameSpecifier.cs index f012c85a0..21df03a1b 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ICustomTargetDynamicMemberNameSpecifier.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ICustomTargetDynamicMemberNameSpecifier.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// @@ -37,4 +38,5 @@ public interface ICustomTargetDynamicMemberNameSpecifier /// ITargetDynamicMappingConfigContinuation ToMemberName(string memberName); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicConfigSettings.cs b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicConfigSettings.cs index 05ce0cb3b..bc25f4376 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicConfigSettings.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicConfigSettings.cs @@ -1,4 +1,5 @@ -namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics +#if DYNAMIC_SUPPORTED +namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// /// Provides options for configuring how mappers will perform mappings from Dynamics to the given @@ -50,4 +51,5 @@ public interface ISourceDynamicConfigSettings /// ISourceDynamicMappingConfigurator And { get; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigContinuation.cs b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigContinuation.cs index 75f6e78dd..11e9976d6 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigContinuation.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigContinuation.cs @@ -1,4 +1,5 @@ -namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics +#if DYNAMIC_SUPPORTED +namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// /// Enables chaining of configurations for an ExpandoObject to the same target type. @@ -12,4 +13,5 @@ public interface ISourceDynamicMappingConfigContinuation /// ISourceDynamicMappingConfigurator And { get; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigurator.cs b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigurator.cs index 9359a0319..062a33356 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigurator.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicMappingConfigurator.cs @@ -1,4 +1,5 @@ -namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics +#if DYNAMIC_SUPPORTED +namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { using System.Collections.Generic; @@ -38,4 +39,5 @@ public interface ISourceDynamicMappingConfigurator : /// ICustomDynamicMappingTargetMemberSpecifier MapMemberName(string memberNamePart); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicSettings.cs b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicSettings.cs index 78631f210..e613f0289 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicSettings.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicSettings.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// @@ -59,4 +60,5 @@ public interface ISourceDynamicSettings /// ISourceDynamicTargetTypeSelector AndWhenMapping { get; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicTargetTypeSelector.cs b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicTargetTypeSelector.cs index ce0dadb62..18aa063cf 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicTargetTypeSelector.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ISourceDynamicTargetTypeSelector.cs @@ -1,4 +1,5 @@ -namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics +#if DYNAMIC_SUPPORTED +namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// /// Provides options for specifying the type of ExpandoObject mapping to perform. @@ -38,3 +39,4 @@ public interface ISourceDynamicTargetTypeSelector : ISourceDynamicSettings ISourceDynamicMappingConfigurator Over(); } } +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicConfigSettings.cs b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicConfigSettings.cs index 48d35a6c4..f9fd0d358 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicConfigSettings.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicConfigSettings.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// @@ -56,4 +57,5 @@ public interface ITargetDynamicConfigSettings /// ITargetDynamicMappingConfigurator And { get; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigContinuation.cs b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigContinuation.cs index e498f786f..be9cdc857 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigContinuation.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigContinuation.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// @@ -12,4 +13,5 @@ public interface ITargetDynamicMappingConfigContinuation /// ITargetDynamicMappingConfigurator And { get; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigurator.cs b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigurator.cs index 892fe8938..623af97c5 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigurator.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingConfigurator.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { using System; @@ -25,4 +26,5 @@ public interface ITargetDynamicMappingConfigurator : ICustomTargetDynamicMemberNameSpecifier MapMember( Expression> sourceMember); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingInlineConfigurator.cs b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingInlineConfigurator.cs index d3239eb85..bc2eede68 100644 --- a/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingInlineConfigurator.cs +++ b/AgileMapper/Api/Configuration/Dynamics/ITargetDynamicMappingInlineConfigurator.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { /// @@ -8,4 +9,5 @@ public interface ITargetDynamicMappingInlineConfigurator : ITargetDynamicMappingConfigurator { } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/SourceDynamicMappingConfigurator.cs b/AgileMapper/Api/Configuration/Dynamics/SourceDynamicMappingConfigurator.cs index 22e311607..03d670519 100644 --- a/AgileMapper/Api/Configuration/Dynamics/SourceDynamicMappingConfigurator.cs +++ b/AgileMapper/Api/Configuration/Dynamics/SourceDynamicMappingConfigurator.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { using System.Collections.Generic; @@ -37,4 +38,5 @@ public ICustomDynamicMappingTargetMemberSpecifier MapFullMemberName(str public ICustomDynamicMappingTargetMemberSpecifier MapMemberName(string memberNamePart) => MapMemberNameKey(memberNamePart); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/Dynamics/TargetDynamicMappingConfigurator.cs b/AgileMapper/Api/Configuration/Dynamics/TargetDynamicMappingConfigurator.cs index 233358bd5..a4fee44e2 100644 --- a/AgileMapper/Api/Configuration/Dynamics/TargetDynamicMappingConfigurator.cs +++ b/AgileMapper/Api/Configuration/Dynamics/TargetDynamicMappingConfigurator.cs @@ -1,3 +1,4 @@ +#if DYNAMIC_SUPPORTED namespace AgileObjects.AgileMapper.Api.Configuration.Dynamics { using System; @@ -67,4 +68,5 @@ private QualifiedMember GetSourceMemberOrThrow(LambdaExpression lambda) $"Source member {lambda.Body.ToReadableString()} is not readable."); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/FactorySpecifier.cs b/AgileMapper/Api/Configuration/FactorySpecifier.cs index 5a2c3c2b2..23d2eec8a 100644 --- a/AgileMapper/Api/Configuration/FactorySpecifier.cs +++ b/AgileMapper/Api/Configuration/FactorySpecifier.cs @@ -4,6 +4,9 @@ namespace AgileObjects.AgileMapper.Api.Configuration using System.Globalization; using System.Linq.Expressions; using AgileMapper.Configuration; +#if NET35 + using Extensions.Internal; +#endif using Members; using ObjectPopulation; using Projection; @@ -22,14 +25,23 @@ public FactorySpecifier(MappingConfigInfo configInfo) public IMappingConfigContinuation Using( Expression, TObject>> factory) +#if NET35 + => RegisterObjectFactory(factory.ToDlrExpression(), ConfiguredObjectFactory.For); +#else => RegisterObjectFactory(factory, ConfiguredObjectFactory.For); - +#endif public IProjectionConfigContinuation Using(Expression> factory) +#if NET35 + => RegisterObjectFactory(factory.ToDlrExpression(), ConfiguredObjectFactory.For); +#else => RegisterObjectFactory(factory, ConfiguredObjectFactory.For); - - public IMappingConfigContinuation Using(LambdaExpression factory) +#endif + public IMappingConfigContinuation Using(LambdaExpression factory) +#if NET35 + => RegisterObjectFactory(factory.ToDlrExpression(), ConfiguredObjectFactory.For); +#else => RegisterObjectFactory(factory, ConfiguredObjectFactory.For); - +#endif public IMappingConfigContinuation Using(TFactory factory) where TFactory : class { diff --git a/AgileMapper/Api/Configuration/IFullMappingInlineConfigurator.cs b/AgileMapper/Api/Configuration/IFullMappingInlineConfigurator.cs index caf84b2c9..e4ccaca68 100644 --- a/AgileMapper/Api/Configuration/IFullMappingInlineConfigurator.cs +++ b/AgileMapper/Api/Configuration/IFullMappingInlineConfigurator.cs @@ -2,7 +2,9 @@ { using System.Reflection; using Dictionaries; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif /// /// Provides options for configuring mappings from and to a given source and target type, inline. @@ -24,12 +26,13 @@ public interface IFullMappingInlineConfigurator : IFullMapping /// ITargetDictionaryMappingInlineConfigurator ForDictionaries { get; } +#if DYNAMIC_SUPPORTED /// /// Configure how this mapper performs a target ExpandoObject mapping, inline. Use this property /// to access ExpandoObject-specific configuration; separators, etc. /// ITargetDynamicMappingInlineConfigurator ForDynamics { get; } - +#endif /// /// Throw an exception upon execution of this statement if the mapping being configured has any target members /// which will not be mapped, maps from a source enum to a target enum which does not support all of its values, diff --git a/AgileMapper/Api/Configuration/IPostInstanceCreationCallbackSpecifier.cs b/AgileMapper/Api/Configuration/IPostInstanceCreationCallbackSpecifier.cs index fde81ccd1..d9adb65c9 100644 --- a/AgileMapper/Api/Configuration/IPostInstanceCreationCallbackSpecifier.cs +++ b/AgileMapper/Api/Configuration/IPostInstanceCreationCallbackSpecifier.cs @@ -1,17 +1,21 @@ -namespace AgileObjects.AgileMapper.Api.Configuration -{ - using System; - using ObjectPopulation; - +namespace AgileObjects.AgileMapper.Api.Configuration +{ + using System; + using ObjectPopulation; + /// - /// Provides options for specifying a callback to be called after a particular type of event for mappings + /// Provides options for specifying a callback to be called after a particular type of event for mappings /// from and to the source and target types being configured. /// /// The source type to which the configuration should apply. /// The target type to which the configuration should apply. - /// The type of created object to which the configuration should apply. - public interface IPostInstanceCreationCallbackSpecifier - { + /// The type of created object to which the configuration should apply. +#if NET35 + public interface IPostInstanceCreationCallbackSpecifier +#else + public interface IPostInstanceCreationCallbackSpecifier +#endif + { /// /// Configure a callback to call in the configured conditions. The callback is passed a context /// object containing the current mapping's source, target and created objects. @@ -20,10 +24,10 @@ public interface IPostInstanceCreationCallbackSpecifier /// An IMappingConfigContinuation to enable further configuration of mappings from and to the source and /// target type being configured. - /// - IMappingConfigContinuation Call( - Action> callback); - + /// + IMappingConfigContinuation Call( + Action> callback); + /// /// Configure a callback to call in the configured conditions. The callback is passed the current /// mapping's source and target objects. @@ -33,8 +37,8 @@ IMappingConfigContinuation Call( /// An IMappingConfigContinuation to enable further configuration of mappings from and to the source and /// target type being configured. /// - IMappingConfigContinuation Call(Action callback); - + IMappingConfigContinuation Call(Action callback); + /// /// Configure a callback to call in the configured conditions. The callback is passed the current /// mapping's source and target objects and the current enumerable index, if applicable. @@ -44,8 +48,8 @@ IMappingConfigContinuation Call( /// An IMappingConfigContinuation to enable further configuration of mappings from and to the source and /// target type being configured. /// - IMappingConfigContinuation Call(Action callback); - + IMappingConfigContinuation Call(Action callback); + /// /// Configure a callback to call in the configured conditions. The callback is passed the current /// mapping's source, target and created objects and the current enumerable index, if applicable. @@ -54,7 +58,7 @@ IMappingConfigContinuation Call( /// /// An IMappingConfigContinuation to enable further configuration of mappings from and to the source and /// target type being configured. - /// - IMappingConfigContinuation Call(Action callback); - } + /// + IMappingConfigContinuation Call(Action callback); + } } \ No newline at end of file diff --git a/AgileMapper/Api/Configuration/InstanceConfigurator.cs b/AgileMapper/Api/Configuration/InstanceConfigurator.cs index 127a52964..0b944614c 100644 --- a/AgileMapper/Api/Configuration/InstanceConfigurator.cs +++ b/AgileMapper/Api/Configuration/InstanceConfigurator.cs @@ -3,6 +3,9 @@ namespace AgileObjects.AgileMapper.Api.Configuration using System; using System.Linq.Expressions; using AgileMapper.Configuration; +#if NET35 + using Extensions.Internal; +#endif using Members; /// @@ -29,7 +32,13 @@ internal InstanceConfigurator(MappingConfigInfo configInfo) /// public void IdentifyUsing(Expression> idExpression) { - _configInfo.MapperContext.UserConfigurations.Identifiers.Add(typeof(TObject), idExpression); + _configInfo.MapperContext.UserConfigurations.Identifiers.Add( + typeof(TObject), + idExpression +#if NET35 + .ToDlrExpression() +#endif + ); } /// diff --git a/AgileMapper/Api/Configuration/MappingConfigStartingPoint.cs b/AgileMapper/Api/Configuration/MappingConfigStartingPoint.cs index 1405c804f..89cc20262 100644 --- a/AgileMapper/Api/Configuration/MappingConfigStartingPoint.cs +++ b/AgileMapper/Api/Configuration/MappingConfigStartingPoint.cs @@ -1,13 +1,17 @@ namespace AgileObjects.AgileMapper.Api.Configuration { using System; +#if DYNAMIC_SUPPORTED using System.Dynamic; +#endif using System.Linq.Expressions; using System.Reflection; using AgileMapper.Configuration; using AgileMapper.Configuration.Dictionaries; using Dictionaries; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif using Extensions.Internal; using Members; using Projection; @@ -301,7 +305,11 @@ public IGlobalMappingSettings IgnoreTargetMembersOfType() /// public IGlobalMappingSettings IgnoreTargetMembersWhere(Expression> memberFilter) { +#if NET35 + var configuredIgnoredMember = new ConfiguredIgnoredMember(GlobalConfigInfo, memberFilter.ToDlrExpression()); +#else var configuredIgnoredMember = new ConfiguredIgnoredMember(GlobalConfigInfo, memberFilter); +#endif MapperContext.UserConfigurations.Add(configuredIgnoredMember); return this; @@ -409,6 +417,7 @@ public ISourceDictionaryTargetTypeSelector FromDictionaries public ISourceDictionaryTargetTypeSelector FromDictionariesWithValueType() => CreateDictionaryConfigurator(Dictionary); +#if DYNAMIC_SUPPORTED /// /// Configure how this mapper performs mappings from or to ExpandoObject instances. /// @@ -420,7 +429,7 @@ public IGlobalDynamicSettings Dynamics /// public ISourceDynamicTargetTypeSelector FromDynamics => CreateDictionaryConfigurator(Expando, typeof(ExpandoObject), sourceValueType: AllTypes); - +#endif private DictionaryMappingConfigurator CreateDictionaryConfigurator( DictionaryType dictionaryType, Type sourceType = null, diff --git a/AgileMapper/Api/Configuration/MappingConfigurator.cs b/AgileMapper/Api/Configuration/MappingConfigurator.cs index e6d278ebb..c42d01815 100644 --- a/AgileMapper/Api/Configuration/MappingConfigurator.cs +++ b/AgileMapper/Api/Configuration/MappingConfigurator.cs @@ -7,7 +7,9 @@ using AgileMapper.Configuration; using AgileMapper.Configuration.Projection; using Dictionaries; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif using Extensions.Internal; using Members; using Projection; @@ -44,9 +46,10 @@ IProjectionConfigStartingPoint IFullProjectionInlineConfigurator ForDictionaries => new TargetDictionaryMappingConfigurator(ConfigInfo); +#if DYNAMIC_SUPPORTED public ITargetDynamicMappingInlineConfigurator ForDynamics => new TargetDynamicMappingConfigurator(ConfigInfo); - +#endif public void ThrowNowIfMappingPlanIsIncomplete() => MappingValidator.Validate(ConfigInfo); public IFullMappingInlineConfigurator LookForDerivedTypesIn(params Assembly[] assemblies) @@ -265,8 +268,11 @@ IProjectionConfigContinuation IRootProjectionConfigurator IgnoreMembersByFilter( Expression> memberFilter) { +#if NET35 + var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, memberFilter.ToDlrExpression()); +#else var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, memberFilter); - +#endif MapperContext.UserConfigurations.Add(configuredIgnoredMember); return new MappingConfigContinuation(ConfigInfo); @@ -286,9 +292,11 @@ private MappingConfigContinuation IgnoreMembers( { foreach (var targetMember in targetMembers) { - var configuredIgnoredMember = - new ConfiguredIgnoredMember(ConfigInfo, targetMember); - +#if NET35 + var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, targetMember.ToDlrExpression()); +#else + var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, targetMember); +#endif MapperContext.UserConfigurations.Add(configuredIgnoredMember); ConfigInfo.NegateCondition(); } @@ -364,8 +372,11 @@ private CustomDataSourceTargetMemberSpecifier GetConstantValue ConfigInfo.ForSourceValueType(valueLambdaInfo.ReturnType), valueLambdaInfo); } - +#if NET35 + var valueConstant = Expression.Constant(value, typeof(TSourceValue)); +#else var valueConstant = value.ToConstantExpression(); +#endif var valueLambda = Expression.Lambda>(valueConstant); return new CustomDataSourceTargetMemberSpecifier( diff --git a/AgileMapper/Api/Configuration/TargetSpecifier.cs b/AgileMapper/Api/Configuration/TargetSpecifier.cs index 8a396b79f..23e1dbd59 100644 --- a/AgileMapper/Api/Configuration/TargetSpecifier.cs +++ b/AgileMapper/Api/Configuration/TargetSpecifier.cs @@ -2,7 +2,9 @@ { using AgileMapper.Configuration; using Dictionaries; +#if DYNAMIC_SUPPORTED using Dynamics; +#endif using Projection; /// @@ -87,11 +89,13 @@ private MappingConfigurator UsingRuleSet(string name) public ITargetDictionaryMappingConfigurator ToDictionariesWithValueType() => new TargetDictionaryMappingConfigurator(_configInfo.ForAllRuleSets()); +#if DYNAMIC_SUPPORTED /// /// Configure how this mapper performs mappings from the source type being configured in all MappingRuleSets /// (create new, overwrite, etc), to target ExpandoObjects. /// public ITargetDynamicMappingConfigurator ToDynamics => new TargetDynamicMappingConfigurator(_configInfo); +#endif } } \ No newline at end of file diff --git a/AgileMapper/Api/IFlatteningSelector.cs b/AgileMapper/Api/IFlatteningSelector.cs index b6cb63d7b..0351ebae0 100644 --- a/AgileMapper/Api/IFlatteningSelector.cs +++ b/AgileMapper/Api/IFlatteningSelector.cs @@ -2,7 +2,9 @@ { using System; using System.Collections.Generic; +#if DYNAMIC_SUPPORTED using System.Dynamic; +#endif using System.Linq.Expressions; using Configuration; @@ -12,6 +14,7 @@ /// The Type of object to be flattened. public interface IFlatteningSelector { +#if DYNAMIC_SUPPORTED /// /// Flatten to an ExpandoObject using the default and any given /// . @@ -24,6 +27,7 @@ public interface IFlatteningSelector /// An ExpandoObject dynamic containing the flattened source object. dynamic ToDynamic( params Expression>>[] configurations); +#endif /// /// Flatten to an IDictionary{string, object} using the default and any given diff --git a/AgileMapper/Api/ITargetSelector.cs b/AgileMapper/Api/ITargetSelector.cs index 86394c7a9..767ee5fa6 100644 --- a/AgileMapper/Api/ITargetSelector.cs +++ b/AgileMapper/Api/ITargetSelector.cs @@ -1,8 +1,8 @@ namespace AgileObjects.AgileMapper.Api { using System; - using System.Linq.Expressions; using Configuration; + using System.Linq.Expressions; /// /// Provides options for specifying the type of mapping to perform. diff --git a/AgileMapper/Api/PlanTargetSelector.cs b/AgileMapper/Api/PlanTargetSelector.cs index 15b2a749a..83282efa5 100644 --- a/AgileMapper/Api/PlanTargetSelector.cs +++ b/AgileMapper/Api/PlanTargetSelector.cs @@ -87,7 +87,11 @@ private static MappingPlan GetMappingPlan( if (configurations?.Any() == true) { InlineMappingConfigurator +#if NET35 + .ConfigureMapperContext(configurations.Project(c => c.ToDlrExpression()), planContext); +#else .ConfigureMapperContext(configurations, planContext); +#endif } var mappingData = mappingDataFactory.Invoke(planContext); diff --git a/AgileMapper/Configuration/ConfiguredIgnoredMember.cs b/AgileMapper/Configuration/ConfiguredIgnoredMember.cs index a3e975fc8..7d01add58 100644 --- a/AgileMapper/Configuration/ConfiguredIgnoredMember.cs +++ b/AgileMapper/Configuration/ConfiguredIgnoredMember.cs @@ -1,13 +1,22 @@ namespace AgileObjects.AgileMapper.Configuration { using System; - using System.Linq.Expressions; using DataSources; using Members; using ReadableExpressions; - - internal class ConfiguredIgnoredMember - : UserConfiguredItemBase, IPotentialClone, IReverseConflictable +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif + + internal class ConfiguredIgnoredMember : + UserConfiguredItemBase, + IPotentialClone, + IReverseConflictable +#if NET35 + , IComparable +#endif { private readonly Expression _memberFilterLambda; private readonly Func _memberFilter; @@ -152,5 +161,10 @@ public bool IsReplacementFor(IPotentialClone clonedItem) } #endregion + +#if NET35 + int IComparable.CompareTo(ConfiguredIgnoredMember other) + => DoComparisonTo(other); +#endif } } \ No newline at end of file diff --git a/AgileMapper/Configuration/ConfiguredLambdaInfo.cs b/AgileMapper/Configuration/ConfiguredLambdaInfo.cs index b4ba65abd..79117da3f 100644 --- a/AgileMapper/Configuration/ConfiguredLambdaInfo.cs +++ b/AgileMapper/Configuration/ConfiguredLambdaInfo.cs @@ -2,12 +2,16 @@ { using System; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members; using Members.Dictionaries; using NetStandardPolyfills; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ConfiguredLambdaInfo { diff --git a/AgileMapper/Configuration/DerivedTypePair.cs b/AgileMapper/Configuration/DerivedTypePair.cs index 089bc42b6..9281da7a1 100644 --- a/AgileMapper/Configuration/DerivedTypePair.cs +++ b/AgileMapper/Configuration/DerivedTypePair.cs @@ -7,7 +7,7 @@ using NetStandardPolyfills; using ReadableExpressions.Extensions; - internal class DerivedTypePair : UserConfiguredItemBase + internal class DerivedTypePair : UserConfiguredItemBase, IComparable { public DerivedTypePair( MappingConfigInfo configInfo, @@ -85,6 +85,24 @@ private static void ThrowIfPairingIsUnnecessary( public override bool AppliesTo(IBasicMapperData mapperData) => mapperData.SourceType.IsAssignableTo(DerivedSourceType) && base.AppliesTo(mapperData); + int IComparable.CompareTo(DerivedTypePair other) + { + var targetTypeX = DerivedTargetType; + var targetTypeY = other.DerivedTargetType; + + if (targetTypeX == targetTypeY) + { + return 0; + } + + if (targetTypeX.IsAssignableTo(targetTypeY)) + { + return -1; + } + + return 1; + } + #region ToString #if DEBUG [ExcludeFromCodeCoverage] diff --git a/AgileMapper/Configuration/DerivedTypePairSet.cs b/AgileMapper/Configuration/DerivedTypePairSet.cs index 0bed3f42c..7f0bc632c 100644 --- a/AgileMapper/Configuration/DerivedTypePairSet.cs +++ b/AgileMapper/Configuration/DerivedTypePairSet.cs @@ -31,8 +31,7 @@ public void Add(DerivedTypePair typePair) { RemoveConflictingPairIfAppropriate(typePair, typePairs); - typePairs.Add(typePair); - typePairs.Sort(DerivedTypePairComparer.Instance); + typePairs.AddSorted(typePair); } else { @@ -272,39 +271,7 @@ private static DerivedTypePair CreatePairFor( #endregion - public void Reset() - { - _typePairsByTargetType.Clear(); - } - - #region Helper Class - - private class DerivedTypePairComparer : IComparer - { - public static readonly IComparer Instance = new DerivedTypePairComparer(); - - public int Compare(DerivedTypePair x, DerivedTypePair y) - { - // ReSharper disable PossibleNullReferenceException - var targetTypeX = x.DerivedTargetType; - var targetTypeY = y.DerivedTargetType; - // ReSharper restore PossibleNullReferenceException - - if (targetTypeX == targetTypeY) - { - return 0; - } - - if (targetTypeX.IsAssignableTo(targetTypeY)) - { - return -1; - } - - return 1; - } - } - - #endregion + public void Reset() => _typePairsByTargetType.Clear(); public void CloneTo(DerivedTypePairSet derivedTypes) { diff --git a/AgileMapper/Configuration/Dictionaries/CustomDictionaryKey.cs b/AgileMapper/Configuration/Dictionaries/CustomDictionaryKey.cs index 65577db3d..d28df0cd7 100644 --- a/AgileMapper/Configuration/Dictionaries/CustomDictionaryKey.cs +++ b/AgileMapper/Configuration/Dictionaries/CustomDictionaryKey.cs @@ -2,10 +2,14 @@ { using System; using System.Dynamic; - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class CustomDictionaryKey : UserConfiguredItemBase { diff --git a/AgileMapper/Configuration/Dictionaries/DictionarySettings.cs b/AgileMapper/Configuration/Dictionaries/DictionarySettings.cs index 70713d6bc..51721c330 100644 --- a/AgileMapper/Configuration/Dictionaries/DictionarySettings.cs +++ b/AgileMapper/Configuration/Dictionaries/DictionarySettings.cs @@ -3,11 +3,15 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; - using System.Linq.Expressions; using Api.Configuration.Dictionaries; using Extensions.Internal; using Members; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionarySettings { diff --git a/AgileMapper/Configuration/Dictionaries/ElementKeyPartFactory.cs b/AgileMapper/Configuration/Dictionaries/ElementKeyPartFactory.cs index 35dbd8cf4..12713b85a 100644 --- a/AgileMapper/Configuration/Dictionaries/ElementKeyPartFactory.cs +++ b/AgileMapper/Configuration/Dictionaries/ElementKeyPartFactory.cs @@ -2,11 +2,15 @@ { using System.Collections.Generic; using System.Dynamic; - using System.Linq.Expressions; using System.Text.RegularExpressions; using Extensions.Internal; using Members; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ElementKeyPartFactory : DictionaryKeyPartFactoryBase { @@ -74,7 +78,7 @@ public static ElementKeyPartFactory SquareBracketedIndex(MapperContext mapperCon public static ElementKeyPartFactory For(string pattern, MappingConfigInfo configInfo) { - if (string.IsNullOrWhiteSpace(pattern)) + if (pattern.IsNullOrWhiteSpace()) { throw InvalidPattern(); } diff --git a/AgileMapper/Configuration/Dictionaries/JoiningNameFactory.cs b/AgileMapper/Configuration/Dictionaries/JoiningNameFactory.cs index cf247d216..92d308b24 100644 --- a/AgileMapper/Configuration/Dictionaries/JoiningNameFactory.cs +++ b/AgileMapper/Configuration/Dictionaries/JoiningNameFactory.cs @@ -2,11 +2,15 @@ { using System; using System.Dynamic; - using System.Linq.Expressions; using Extensions.Internal; using Members; using Members.Dictionaries; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif using static DictionaryContext; internal class JoiningNameFactory : DictionaryKeyPartFactoryBase diff --git a/AgileMapper/Configuration/EnumComparisonFixer.cs b/AgileMapper/Configuration/EnumComparisonFixer.cs index 988102f22..d42ae0a01 100644 --- a/AgileMapper/Configuration/EnumComparisonFixer.cs +++ b/AgileMapper/Configuration/EnumComparisonFixer.cs @@ -2,9 +2,13 @@ { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumComparisonFixer : ExpressionVisitor { diff --git a/AgileMapper/Configuration/ExceptionCallback.cs b/AgileMapper/Configuration/ExceptionCallback.cs index 246338e63..d426ad798 100644 --- a/AgileMapper/Configuration/ExceptionCallback.cs +++ b/AgileMapper/Configuration/ExceptionCallback.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Configuration { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal class ExceptionCallback : UserConfiguredItemBase { diff --git a/AgileMapper/Configuration/Inline/IInlineMapperKey.cs b/AgileMapper/Configuration/Inline/IInlineMapperKey.cs index 46319ecb7..f2b5c4e97 100644 --- a/AgileMapper/Configuration/Inline/IInlineMapperKey.cs +++ b/AgileMapper/Configuration/Inline/IInlineMapperKey.cs @@ -2,8 +2,11 @@ namespace AgileObjects.AgileMapper.Configuration.Inline { using System; using System.Collections.Generic; +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; - using Members; +#endif internal interface IInlineMapperKey { diff --git a/AgileMapper/Configuration/Inline/InlineMapperContextSet.cs b/AgileMapper/Configuration/Inline/InlineMapperContextSet.cs index 060cc666a..cd060a9f1 100644 --- a/AgileMapper/Configuration/Inline/InlineMapperContextSet.cs +++ b/AgileMapper/Configuration/Inline/InlineMapperContextSet.cs @@ -3,10 +3,16 @@ using System; using System.Collections; using System.Collections.Generic; +#if NET35 + using System.Linq; +#endif using System.Linq.Expressions; using Api.Configuration; using Api.Configuration.Projection; using Caching; +#if NET35 + using Extensions.Internal; +#endif internal class InlineMapperContextSet : IEnumerable { @@ -51,7 +57,11 @@ private MapperContext GetContextFor( IMappingContext mappingContext) { var key = new InlineMapperKey( +#if NET35 + configurations.Project(c => c.ToDlrExpression()).ToArray(), +#else configurations, +#endif configuratorFactory, mappingContext); diff --git a/AgileMapper/Configuration/Inline/InlineMapperKey.cs b/AgileMapper/Configuration/Inline/InlineMapperKey.cs index c77b9b502..4453c6e34 100644 --- a/AgileMapper/Configuration/Inline/InlineMapperKey.cs +++ b/AgileMapper/Configuration/Inline/InlineMapperKey.cs @@ -2,9 +2,12 @@ namespace AgileObjects.AgileMapper.Configuration.Inline { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; - using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class InlineMapperKey : IInlineMapperKey { diff --git a/AgileMapper/Configuration/Inline/InlineMappingConfigurator.cs b/AgileMapper/Configuration/Inline/InlineMappingConfigurator.cs index 7da8de485..11320c274 100644 --- a/AgileMapper/Configuration/Inline/InlineMappingConfigurator.cs +++ b/AgileMapper/Configuration/Inline/InlineMappingConfigurator.cs @@ -2,8 +2,12 @@ namespace AgileObjects.AgileMapper.Configuration.Inline { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Api.Configuration; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class InlineMappingConfigurator { diff --git a/AgileMapper/Configuration/MapToNullCondition.cs b/AgileMapper/Configuration/MapToNullCondition.cs index 7ed62d6e4..bafa283c1 100644 --- a/AgileMapper/Configuration/MapToNullCondition.cs +++ b/AgileMapper/Configuration/MapToNullCondition.cs @@ -1,11 +1,19 @@ namespace AgileObjects.AgileMapper.Configuration { using System; - using System.Linq.Expressions; using Members; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif - internal class MapToNullCondition : UserConfiguredItemBase + internal class MapToNullCondition : + UserConfiguredItemBase +#if NET35 + , IComparable +#endif { private readonly Type _targetType; @@ -42,5 +50,10 @@ protected override Expression GetConditionOrNull(IMemberMapperData mapperData, C return base.GetConditionOrNull(mapperData, position); } + +#if NET35 + int IComparable.CompareTo(MapToNullCondition other) + => DoComparisonTo(other); +#endif } } \ No newline at end of file diff --git a/AgileMapper/Configuration/MappedObjectCachingSettings.cs b/AgileMapper/Configuration/MappedObjectCachingSettings.cs index 295013082..0bf8bfe4a 100644 --- a/AgileMapper/Configuration/MappedObjectCachingSettings.cs +++ b/AgileMapper/Configuration/MappedObjectCachingSettings.cs @@ -1,8 +1,15 @@ namespace AgileObjects.AgileMapper.Configuration { +#if NET35 + using System; +#endif using ReadableExpressions.Extensions; - internal class MappedObjectCachingSettings : UserConfiguredItemBase + internal class MappedObjectCachingSettings : + UserConfiguredItemBase +#if NET35 + , IComparable +#endif { #region Singleton Instances @@ -72,6 +79,11 @@ public string GetConflictMessage(MappedObjectCachingSettings conflicting) return GetRedundantSettingsConflictMessage(conflicting, typeSettings); } +#if NET35 + int IComparable.CompareTo(MappedObjectCachingSettings other) + => DoComparisonTo(other); +#endif + private string GetRedundantSettingsConflictMessage( MappedObjectCachingSettings conflicting, string typeSettings = null) diff --git a/AgileMapper/Configuration/MappingConfigInfo.cs b/AgileMapper/Configuration/MappingConfigInfo.cs index e8e93bd24..38aa8de71 100644 --- a/AgileMapper/Configuration/MappingConfigInfo.cs +++ b/AgileMapper/Configuration/MappingConfigInfo.cs @@ -3,11 +3,16 @@ using System; using System.Collections.Generic; using System.Globalization; - using System.Linq.Expressions; using Extensions.Internal; using Members; using ObjectPopulation; using ReadableExpressions; +#if NET35 + using LinqExp = System.Linq.Expressions; + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class MappingConfigInfo : ITypePair { @@ -105,6 +110,10 @@ public bool ConditionUsesMappingDataObjectParameter public bool ConditionSupports(MappingRuleSet ruleSet) => _conditionLambda.Supports(ruleSet); +#if NET35 + public void AddConditionOrThrow(LinqExp.LambdaExpression conditionLambda) + => AddConditionOrThrow(conditionLambda.ToDlrExpression()); +#endif public void AddConditionOrThrow(LambdaExpression conditionLambda) { ErrorIfConditionHasTypeTest(conditionLambda); diff --git a/AgileMapper/Configuration/ParametersSwapper.cs b/AgileMapper/Configuration/ParametersSwapper.cs index d58bb47f8..05d72d979 100644 --- a/AgileMapper/Configuration/ParametersSwapper.cs +++ b/AgileMapper/Configuration/ParametersSwapper.cs @@ -3,11 +3,15 @@ namespace AgileObjects.AgileMapper.Configuration using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members; using NetStandardPolyfills; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif using static Members.Member; internal class ParametersSwapper diff --git a/AgileMapper/Configuration/PotentialCloneExtensions.cs b/AgileMapper/Configuration/PotentialCloneExtensions.cs index 95b72119b..2492d24f1 100644 --- a/AgileMapper/Configuration/PotentialCloneExtensions.cs +++ b/AgileMapper/Configuration/PotentialCloneExtensions.cs @@ -1,5 +1,6 @@ namespace AgileObjects.AgileMapper.Configuration { + using System; using System.Collections.Generic; using System.Linq; using Extensions.Internal; @@ -19,8 +20,29 @@ public static IList CloneItems(this IList cloneableItems) return clonedItems; } + public static void AddSorted(this List items, T newItem) + where T : IComparable + { + if (items.None()) + { + items.Add(newItem); + return; + } + + for (var i = 0; i < items.Count; i++) + { + if (items[i].CompareTo(newItem) == 1) + { + items.Insert(i, newItem); + return; + } + } + + items.Add(newItem); + } + public static void AddSortFilter(this List cloneableItems, T newItem) - where T : IPotentialClone + where T : IPotentialClone, IComparable { if (cloneableItems.None()) { @@ -40,8 +62,7 @@ public static void AddSortFilter(this List cloneableItems, T newItem) return; } - cloneableItems.Add(newItem); - cloneableItems.Sort(); + cloneableItems.AddSorted(newItem); } } } \ No newline at end of file diff --git a/AgileMapper/Configuration/UserConfigurationSet.cs b/AgileMapper/Configuration/UserConfigurationSet.cs index 275a0741e..045c5b452 100644 --- a/AgileMapper/Configuration/UserConfigurationSet.cs +++ b/AgileMapper/Configuration/UserConfigurationSet.cs @@ -3,13 +3,17 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using DataSources; using Dictionaries; using Extensions.Internal; using Members; using ObjectPopulation; using Projection; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class UserConfigurationSet { @@ -48,13 +52,12 @@ public void Add(MappedObjectCachingSettings settings) _mappedObjectCachingSettings, (s, conflicting) => conflicting.GetConflictMessage(s)); - MappedObjectCachingSettings.Add(settings); - _mappedObjectCachingSettings.Sort(); + MappedObjectCachingSettings.AddSorted(settings); } public MappedObjectCachingMode CacheMappedObjects(IBasicMapperData basicData) { - if (MappedObjectCachingSettings.None()) + if (MappedObjectCachingSettings.None() || !basicData.TargetMember.IsComplex) { return MappedObjectCachingMode.AutoDetect; } @@ -85,8 +88,7 @@ public void Add(MapToNullCondition condition) ThrowIfConflictingItemExists(condition, conditions, (c, cC) => c.GetConflictMessage()); - conditions.Add(condition); - conditions.Sort(); + conditions.AddSorted(condition); } public Expression GetMapToNullConditionOrNull(IMemberMapperData mapperData) diff --git a/AgileMapper/Configuration/UserConfiguredItemBase.cs b/AgileMapper/Configuration/UserConfiguredItemBase.cs index 89ffa45ec..5669b881b 100644 --- a/AgileMapper/Configuration/UserConfiguredItemBase.cs +++ b/AgileMapper/Configuration/UserConfiguredItemBase.cs @@ -1,12 +1,17 @@ namespace AgileObjects.AgileMapper.Configuration { using System; - using System.Linq.Expressions; + using System.Collections.Generic; using Members; using NetStandardPolyfills; using ObjectPopulation; using ReadableExpressions; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal abstract class UserConfiguredItemBase : IComparable { @@ -155,6 +160,9 @@ protected bool MemberPathHasMatchingSourceAndTargetTypes(IBasicMapperData mapper } int IComparable.CompareTo(UserConfiguredItemBase other) + => DoComparisonTo(other); + + protected int DoComparisonTo(UserConfiguredItemBase other) { if (ReferenceEquals(this, other)) { diff --git a/AgileMapper/Constants.cs b/AgileMapper/Constants.cs index b7a2993ee..10f7e9bc8 100644 --- a/AgileMapper/Constants.cs +++ b/AgileMapper/Constants.cs @@ -3,9 +3,13 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class Constants { diff --git a/AgileMapper/DataSources/AdHocDataSource.cs b/AgileMapper/DataSources/AdHocDataSource.cs index 5340f5797..ecdcd95ef 100644 --- a/AgileMapper/DataSources/AdHocDataSource.cs +++ b/AgileMapper/DataSources/AdHocDataSource.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.DataSources { using System.Collections.Generic; - using System.Linq.Expressions; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class AdHocDataSource : DataSourceBase { diff --git a/AgileMapper/DataSources/ComplexTypeMappingDataSource.cs b/AgileMapper/DataSources/ComplexTypeMappingDataSource.cs index 1fe7f65c2..3b9e1f717 100644 --- a/AgileMapper/DataSources/ComplexTypeMappingDataSource.cs +++ b/AgileMapper/DataSources/ComplexTypeMappingDataSource.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.DataSources { - using System.Linq.Expressions; using Members; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ComplexTypeMappingDataSource : DataSourceBase { diff --git a/AgileMapper/DataSources/ConfiguredDataSource.cs b/AgileMapper/DataSources/ConfiguredDataSource.cs index 18c8b2f00..3aac9712f 100644 --- a/AgileMapper/DataSources/ConfiguredDataSource.cs +++ b/AgileMapper/DataSources/ConfiguredDataSource.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.DataSources { - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ConfiguredDataSource : DataSourceBase, IConfiguredDataSource { diff --git a/AgileMapper/DataSources/ConfiguredDataSourceFactory.cs b/AgileMapper/DataSources/ConfiguredDataSourceFactory.cs index 619b59e7b..35ad90e0e 100644 --- a/AgileMapper/DataSources/ConfiguredDataSourceFactory.cs +++ b/AgileMapper/DataSources/ConfiguredDataSourceFactory.cs @@ -1,10 +1,22 @@ namespace AgileObjects.AgileMapper.DataSources { - using System.Linq.Expressions; +#if NET35 + using System; +#endif using Configuration; using Members; - - internal class ConfiguredDataSourceFactory : UserConfiguredItemBase, IPotentialClone +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif + + internal class ConfiguredDataSourceFactory : + UserConfiguredItemBase, + IPotentialClone +#if NET35 + , IComparable +#endif { private readonly ConfiguredLambdaInfo _dataSourceLambda; @@ -113,5 +125,10 @@ public bool IsReplacementFor(IPotentialClone clonedDataSourceFactory) => ConflictsWith((ConfiguredDataSourceFactory)clonedDataSourceFactory); #endregion + +#if NET35 + int IComparable.CompareTo(ConfiguredDataSourceFactory other) + => DoComparisonTo(other); +#endif } } \ No newline at end of file diff --git a/AgileMapper/DataSources/DataSourceBase.cs b/AgileMapper/DataSources/DataSourceBase.cs index 7a8240d4a..35a0174a6 100644 --- a/AgileMapper/DataSources/DataSourceBase.cs +++ b/AgileMapper/DataSources/DataSourceBase.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.DataSources { using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using Members; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal abstract class DataSourceBase : IDataSource { diff --git a/AgileMapper/DataSources/DataSourceSet.cs b/AgileMapper/DataSources/DataSourceSet.cs index 06860175f..910289a6a 100644 --- a/AgileMapper/DataSources/DataSourceSet.cs +++ b/AgileMapper/DataSources/DataSourceSet.cs @@ -1,146 +1,150 @@ -namespace AgileObjects.AgileMapper.DataSources -{ - using System.Collections; - using System.Collections.Generic; - using System.Linq.Expressions; - using Extensions.Internal; - using Members; - - internal class DataSourceSet : IEnumerable - { - private readonly IList _dataSources; - private readonly List _variables; - private Expression _value; - - public DataSourceSet( - IMemberMapperData mapperData, - params IDataSource[] dataSources) - { - MapperData = mapperData; - _dataSources = dataSources; - _variables = new List(); - None = dataSources.Length == 0; - - if (None) - { - return; +namespace AgileObjects.AgileMapper.DataSources +{ + using System.Collections; + using System.Collections.Generic; + using Extensions.Internal; + using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif + + internal class DataSourceSet : IEnumerable + { + private readonly IList _dataSources; + private readonly List _variables; + private Expression _value; + + public DataSourceSet( + IMemberMapperData mapperData, + params IDataSource[] dataSources) + { + MapperData = mapperData; + _dataSources = dataSources; + _variables = new List(); + None = dataSources.Length == 0; + + if (None) + { + return; + } + + for (var i = 0; i < dataSources.Length; i++) + { + var dataSource = dataSources[i]; + + if (dataSource.IsValid) + { + HasValue = true; + } + + if (dataSource.Variables.Any()) + { + _variables.AddRange(dataSource.Variables); + } + + if (dataSource.SourceMemberTypeTest != null) + { + SourceMemberTypeTest = dataSource.SourceMemberTypeTest; + } } + } + + public IMemberMapperData MapperData { get; } + + public bool None { get; } - for (var i = 0; i < dataSources.Length; i++) - { - var dataSource = dataSources[i]; - - if (dataSource.IsValid) - { - HasValue = true; - } - - if (dataSource.Variables.Any()) - { - _variables.AddRange(dataSource.Variables); - } - - if (dataSource.SourceMemberTypeTest != null) - { - SourceMemberTypeTest = dataSource.SourceMemberTypeTest; - } - } - } - - public IMemberMapperData MapperData { get; } - - public bool None { get; } - public bool HasValue { get; } - public Expression SourceMemberTypeTest { get; } - - public ICollection Variables => _variables; - - public IDataSource this[int index] => _dataSources[index]; - - public Expression ValueExpression => _value ?? (_value = BuildValueExpression()); - - private Expression BuildValueExpression() - { - var value = default(Expression); - - for (var i = _dataSources.Count - 1; i >= 0; --i) - { - var dataSource = _dataSources[i]; - - value = dataSource.AddPreConditionIfNecessary(value == default(Expression) - ? dataSource.Value - : Expression.Condition( - dataSource.Condition, - dataSource.Value.GetConversionTo(value.Type), - value)); - } - - return value; - } - - public Expression GetPopulationExpression() - { + public Expression SourceMemberTypeTest { get; } + + public ICollection Variables => _variables; + + public IDataSource this[int index] => _dataSources[index]; + + public Expression ValueExpression => _value ?? (_value = BuildValueExpression()); + + private Expression BuildValueExpression() + { + var value = default(Expression); + + for (var i = _dataSources.Count - 1; i >= 0; --i) + { + var dataSource = _dataSources[i]; + + value = dataSource.AddPreConditionIfNecessary(value == default(Expression) + ? dataSource.Value + : Expression.Condition( + dataSource.Condition, + dataSource.Value.GetConversionTo(value.Type), + value)); + } + + return value; + } + + public Expression GetPopulationExpression() + { var fallbackValue = GetFallbackValueOrNull(); - var excludeFallback = fallbackValue == null; - - Expression population = null; - - for (var i = _dataSources.Count - 1; i >= 0; --i) - { - var dataSource = _dataSources[i]; - - if (i == _dataSources.Count - 1) - { - if (excludeFallback) - { - continue; - } - - population = MapperData.GetTargetMemberPopulation(fallbackValue); - - if (dataSource.IsConditional) - { - population = dataSource.AddCondition(population); - } - - population = dataSource.AddPreCondition(population); - continue; - } - + var excludeFallback = fallbackValue == null; + + Expression population = null; + + for (var i = _dataSources.Count - 1; i >= 0; --i) + { + var dataSource = _dataSources[i]; + + if (i == _dataSources.Count - 1) + { + if (excludeFallback) + { + continue; + } + + population = MapperData.GetTargetMemberPopulation(fallbackValue); + + if (dataSource.IsConditional) + { + population = dataSource.AddCondition(population); + } + + population = dataSource.AddPreCondition(population); + continue; + } + var memberPopulation = MapperData.GetTargetMemberPopulation(dataSource.Value); population = dataSource.AddCondition(memberPopulation, population); - population = dataSource.AddPreCondition(population); - } - - return population; - } - - private Expression GetFallbackValueOrNull() - { - var finalDataSource = _dataSources.Last(); + population = dataSource.AddPreCondition(population); + } + + return population; + } + + private Expression GetFallbackValueOrNull() + { + var finalDataSource = _dataSources.Last(); var fallbackValue = finalDataSource.Value; - if (finalDataSource.IsConditional || _dataSources.HasOne()) - { - return fallbackValue; - } - - if (fallbackValue.NodeType == ExpressionType.Coalesce) - { - return ((BinaryExpression)fallbackValue).Right; - } - - var targetMemberAccess = MapperData.GetTargetMemberAccess(); - - if (ExpressionEvaluation.AreEqual(fallbackValue, targetMemberAccess)) - { - return null; - } - - return fallbackValue; + if (finalDataSource.IsConditional || _dataSources.HasOne()) + { + return fallbackValue; + } + + if (fallbackValue.NodeType == ExpressionType.Coalesce) + { + return ((BinaryExpression)fallbackValue).Right; + } + + var targetMemberAccess = MapperData.GetTargetMemberAccess(); + + if (ExpressionEvaluation.AreEqual(fallbackValue, targetMemberAccess)) + { + return null; + } + + return fallbackValue; } #region IEnumerable Members diff --git a/AgileMapper/DataSources/DictionaryEntryDataSource.cs b/AgileMapper/DataSources/DictionaryEntryDataSource.cs index fd796ed1a..d6b6d76b0 100644 --- a/AgileMapper/DataSources/DictionaryEntryDataSource.cs +++ b/AgileMapper/DataSources/DictionaryEntryDataSource.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.DataSources { - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionaryEntryDataSource : DataSourceBase { diff --git a/AgileMapper/DataSources/DictionaryEntryVariablePair.cs b/AgileMapper/DataSources/DictionaryEntryVariablePair.cs index ea8dc6086..27155c5b1 100644 --- a/AgileMapper/DataSources/DictionaryEntryVariablePair.cs +++ b/AgileMapper/DataSources/DictionaryEntryVariablePair.cs @@ -3,12 +3,16 @@ namespace AgileObjects.AgileMapper.DataSources using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using Members; using Members.Dictionaries; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionaryEntryVariablePair { diff --git a/AgileMapper/DataSources/EnumerableMappingDataSource.cs b/AgileMapper/DataSources/EnumerableMappingDataSource.cs index f81ff28a9..0c7f21d31 100644 --- a/AgileMapper/DataSources/EnumerableMappingDataSource.cs +++ b/AgileMapper/DataSources/EnumerableMappingDataSource.cs @@ -2,12 +2,16 @@ { using System; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members; using NetStandardPolyfills; using ObjectPopulation; using ObjectPopulation.Enumerables; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumerableMappingDataSource : DataSourceBase { diff --git a/AgileMapper/DataSources/ExistingMemberValueOrDefaultDataSource.cs b/AgileMapper/DataSources/ExistingMemberValueOrDefaultDataSource.cs index 77d1ddcca..4525eb024 100644 --- a/AgileMapper/DataSources/ExistingMemberValueOrDefaultDataSource.cs +++ b/AgileMapper/DataSources/ExistingMemberValueOrDefaultDataSource.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.DataSources { - using System.Linq.Expressions; using Members; using Members.Dictionaries; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ExistingMemberValueOrDefaultDataSource : DataSourceBase { diff --git a/AgileMapper/DataSources/Finders/MetaMemberDataSourceFinder.cs b/AgileMapper/DataSources/Finders/MetaMemberDataSourceFinder.cs index 6762dcc2c..7fafa2691 100644 --- a/AgileMapper/DataSources/Finders/MetaMemberDataSourceFinder.cs +++ b/AgileMapper/DataSources/Finders/MetaMemberDataSourceFinder.cs @@ -3,13 +3,17 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members; using NetStandardPolyfills; using ObjectPopulation; using ObjectPopulation.Enumerables; using TypeConversion; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif using static System.StringComparison; internal struct MetaMemberDataSourceFinder : IDataSourceFinder diff --git a/AgileMapper/DataSources/IDataSource.cs b/AgileMapper/DataSources/IDataSource.cs index 6476e71c8..f343b67ee 100644 --- a/AgileMapper/DataSources/IDataSource.cs +++ b/AgileMapper/DataSources/IDataSource.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.DataSources { using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal interface IDataSource : IConditionallyChainable { diff --git a/AgileMapper/DataSources/NullDataSource.cs b/AgileMapper/DataSources/NullDataSource.cs index da50cb235..90eb535a3 100644 --- a/AgileMapper/DataSources/NullDataSource.cs +++ b/AgileMapper/DataSources/NullDataSource.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.DataSources { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif using Members; internal class NullDataSource : DataSourceBase diff --git a/AgileMapper/DataSources/SourceMemberDataSource.cs b/AgileMapper/DataSources/SourceMemberDataSource.cs index 08796af3a..9726d581b 100644 --- a/AgileMapper/DataSources/SourceMemberDataSource.cs +++ b/AgileMapper/DataSources/SourceMemberDataSource.cs @@ -1,11 +1,15 @@ namespace AgileObjects.AgileMapper.DataSources { - using System.Linq.Expressions; using System.Collections.Generic; using Extensions.Internal; using Members; using ObjectPopulation; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceMemberDataSource : DataSourceBase { diff --git a/AgileMapper/DerivedTypesCache.cs b/AgileMapper/DerivedTypesCache.cs index f52ba32b9..161776135 100644 --- a/AgileMapper/DerivedTypesCache.cs +++ b/AgileMapper/DerivedTypesCache.cs @@ -14,13 +14,13 @@ internal class DerivedTypesCache private readonly List _assemblies; private readonly ICache> _typesByAssembly; - private readonly ICache> _derivedTypesByType; + private readonly ICache> _derivedTypesByType; public DerivedTypesCache(CacheSet cacheSet) { _assemblies = new List(); _typesByAssembly = cacheSet.CreateScoped>(default(ReferenceEqualsComparer)); - _derivedTypesByType = cacheSet.CreateScoped>(default(ReferenceEqualsComparer)); + _derivedTypesByType = cacheSet.CreateScoped>(default(ReferenceEqualsComparer)); } public void AddAssemblies(Assembly[] assemblies) @@ -41,7 +41,7 @@ public ICollection GetTypesDerivedFrom(Type type) return _derivedTypesByType.GetOrAdd(type, GetDerivedTypesForType); } - private IList GetDerivedTypesForType(Type type) + private ICollection GetDerivedTypesForType(Type type) { var typeAssemblies = new[] { type.GetAssembly() }; @@ -65,9 +65,9 @@ private IList GetDerivedTypesForType(Type type) return Enumerable.EmptyArray; } - var derivedTypesList = new List(derivedTypes); - - derivedTypesList.Sort(TypeComparer.MostToLeastDerived); + var derivedTypesList = derivedTypes + .OrderBy(t => t, TypeComparer.MostToLeastDerived) + .ToArray(); return derivedTypesList; } diff --git a/AgileMapper/Extensions/Internal/EnumerableExtensions.cs b/AgileMapper/Extensions/Internal/EnumerableExtensions.cs index ae3e9dbab..dd727c64d 100644 --- a/AgileMapper/Extensions/Internal/EnumerableExtensions.cs +++ b/AgileMapper/Extensions/Internal/EnumerableExtensions.cs @@ -4,9 +4,13 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class EnumerableExtensions { @@ -52,6 +56,17 @@ public static IEnumerable Filter(this IEnumerable items, Fu } } +#if NET35 + public static void AddRange(this List items, IEnumerable newItems) + where TItem : TContained + { + foreach (var newItem in newItems) + { + items.Add(newItem); + } + } +#endif + [DebuggerStepThrough] public static T First(this IList items) => items[0]; diff --git a/AgileMapper/Extensions/Internal/ExpressionEvaluation.cs b/AgileMapper/Extensions/Internal/ExpressionEvaluation.cs index 5d4257675..a2f5b0293 100644 --- a/AgileMapper/Extensions/Internal/ExpressionEvaluation.cs +++ b/AgileMapper/Extensions/Internal/ExpressionEvaluation.cs @@ -2,9 +2,15 @@ namespace AgileObjects.AgileMapper.Extensions.Internal { using System; using System.Collections.Generic; - using System.Linq.Expressions; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; + using LinqExp = System.Linq.Expressions; + using static Microsoft.Scripting.Ast.ExpressionType; +#else + using System.Linq.Expressions; using static System.Linq.Expressions.ExpressionType; +#endif internal static class ExpressionEvaluation { @@ -73,7 +79,11 @@ public bool Equals(Expression x, Expression y) return AreEqual((ConditionalExpression)x, (ConditionalExpression)y); case Constant: +#if NET35 + return AreEqualNet35((ConstantExpression)x, (ConstantExpression)y); +#else return AreEqual((ConstantExpression)x, (ConstantExpression)y); +#endif case ArrayLength: case ExpressionType.Convert: @@ -181,11 +191,21 @@ private bool AreEqual(ConditionalExpression x, ConditionalExpression y) return (x.Type == y.Type) && Equals(x.Test, y.Test) && Equals(x.IfTrue, y.IfTrue) && Equals(x.IfFalse, y.IfFalse); } - - private static bool AreEqual(ConstantExpression x, ConstantExpression y) +#if NET35 + private bool AreEqualNet35(ConstantExpression x, ConstantExpression y) { - return ReferenceEquals(x.Value, y.Value) || x.Value.Equals(y.Value); + if (AreEqual(x, y)) + { + return true; + } + + return (x.Type == y.Type) && + (x.Value is LinqExp.Expression xExpression) && + Equals(xExpression.ToDlrExpression(), ((LinqExp.Expression)y.Value).ToDlrExpression()); } +#endif + private static bool AreEqual(ConstantExpression x, ConstantExpression y) + => ReferenceEquals(x.Value, y.Value) || x.Value.Equals(y.Value); private bool AreEqual(UnaryExpression x, UnaryExpression y) { diff --git a/AgileMapper/Extensions/Internal/ExpressionExtensions.CanBeProjected.cs b/AgileMapper/Extensions/Internal/ExpressionExtensions.CanBeProjected.cs index f1574a0fb..e33939805 100644 --- a/AgileMapper/Extensions/Internal/ExpressionExtensions.CanBeProjected.cs +++ b/AgileMapper/Extensions/Internal/ExpressionExtensions.CanBeProjected.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.Extensions.Internal { using System.Collections.Generic; - using System.Linq.Expressions; using Members; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static partial class ExpressionExtensions { diff --git a/AgileMapper/Extensions/Internal/ExpressionExtensions.Replace.cs b/AgileMapper/Extensions/Internal/ExpressionExtensions.Replace.cs index 38fc57487..16255ce38 100644 --- a/AgileMapper/Extensions/Internal/ExpressionExtensions.Replace.cs +++ b/AgileMapper/Extensions/Internal/ExpressionExtensions.Replace.cs @@ -3,9 +3,14 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Caching; +#if NET35 + using Microsoft.Scripting.Ast; + using static Microsoft.Scripting.Ast.ExpressionType; +#else + using System.Linq.Expressions; using static System.Linq.Expressions.ExpressionType; +#endif internal static partial class ExpressionExtensions { diff --git a/AgileMapper/Extensions/Internal/ExpressionExtensions.cs b/AgileMapper/Extensions/Internal/ExpressionExtensions.cs index 26874ea9a..4257e9583 100644 --- a/AgileMapper/Extensions/Internal/ExpressionExtensions.cs +++ b/AgileMapper/Extensions/Internal/ExpressionExtensions.cs @@ -4,12 +4,19 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using NetStandardPolyfills; using ObjectPopulation.Enumerables; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; + using ReadableExpressions.Translators; + using LinqExp = System.Linq.Expressions; + using static Microsoft.Scripting.Ast.ExpressionType; +#else + using System.Linq.Expressions; using static System.Linq.Expressions.ExpressionType; +#endif internal static partial class ExpressionExtensions { @@ -506,5 +513,16 @@ public static bool TryGetVariableAssignment(this IList mappingExpres binaryExpression = null; return false; } + +#if NET35 + public static LambdaExpression ToDlrExpression(this LinqExp.LambdaExpression linqLambda) + => LinqExpressionToDlrExpressionConverter.Convert(linqLambda); + + public static Expression ToDlrExpression(this LinqExp.Expression linqLambda) + => (Expression)LinqExpressionToDlrExpressionConverter.Convert(linqLambda); + + public static Expression ToDlrExpression(this LinqExp.Expression linqExpression) + => LinqExpressionToDlrExpressionConverter.Convert(linqExpression); +#endif } } diff --git a/AgileMapper/Extensions/Internal/ExpressionReplacementDictionary.cs b/AgileMapper/Extensions/Internal/ExpressionReplacementDictionary.cs index 3c2eacb7c..a6311140e 100644 --- a/AgileMapper/Extensions/Internal/ExpressionReplacementDictionary.cs +++ b/AgileMapper/Extensions/Internal/ExpressionReplacementDictionary.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Extensions.Internal { using System.Collections.Generic; +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal class ExpressionReplacementDictionary : Dictionary { diff --git a/AgileMapper/Extensions/Internal/IConditionallyChainable.cs b/AgileMapper/Extensions/Internal/IConditionallyChainable.cs index 4560f3325..894f7c9fc 100644 --- a/AgileMapper/Extensions/Internal/IConditionallyChainable.cs +++ b/AgileMapper/Extensions/Internal/IConditionallyChainable.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Extensions.Internal { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IConditionallyChainable { diff --git a/AgileMapper/Extensions/Internal/Lazy.cs b/AgileMapper/Extensions/Internal/Lazy.cs new file mode 100644 index 000000000..a7b087ab4 --- /dev/null +++ b/AgileMapper/Extensions/Internal/Lazy.cs @@ -0,0 +1,42 @@ +#if NET35 +namespace AgileObjects.AgileMapper.Extensions.Internal +{ + using System; + + internal class Lazy + { + private readonly object _syncLock; + private readonly Func _valueFactory; + private bool _valueCreated; + private T _value; + + public Lazy(Func valueFactory) + { + _syncLock = new object(); + _valueFactory = valueFactory; + } + + public T Value + { + get + { + if (_valueCreated) + { + return _value; + } + + lock (_syncLock) + { + if (_valueCreated) + { + return _value; + } + + _valueCreated = true; + return _value = _valueFactory.Invoke(); + } + } + } + } +} +#endif \ No newline at end of file diff --git a/AgileMapper/Extensions/Internal/PublicStringExtensions.cs b/AgileMapper/Extensions/Internal/PublicStringExtensions.cs new file mode 100644 index 000000000..a57188c23 --- /dev/null +++ b/AgileMapper/Extensions/Internal/PublicStringExtensions.cs @@ -0,0 +1,158 @@ +namespace AgileObjects.AgileMapper.Extensions.Internal +{ + using System; + using System.Text.RegularExpressions; + + /// + /// Provides extension methods used by compiled mapping functions. + /// + public static class PublicStringExtensions + { + /// + /// Gets the string value of the first character of the . + /// + /// The value from which to get the first character. + /// + /// The first character of the value if it has a length of greater than one, otherwise returns + /// . + /// + public static string FirstOrDefault(this string value) + { + if (string.IsNullOrEmpty(value) || (value.Length == 1)) + { + return value; + } + + return value[0].ToString(); + } + + /// + /// Determines if the matches the given , + /// given the given and . + /// + /// The subject key for which to make the determination. + /// The query key for which to make the determination. + /// The separator to use to separate key parts while making the determination. + /// + /// A Regex with which to match element key parts while making the determination. + /// + /// + /// True if the matches the given , otherwise false. + /// + public static bool MatchesKey( + this string subjectKey, + string queryKey, + string separator, + Regex elementKeyPartMatcher) + { + if (queryKey == null) + { + // This can happen when mapping to types with multiple, nested + // recursive relationships, e.g: + // Dictionary<,> -> Order -> OrderItems -> Order -> OrderItems + // ...it's basically not supported + return false; + } + + if (subjectKey.EqualsIgnoreCase(queryKey)) + { + return true; + } + + var elementKeyParts = elementKeyPartMatcher.Matches(queryKey); + + var searchEndIndex = queryKey.Length; + + for (var i = elementKeyParts.Count; i > 0; --i) + { + var elementKeyPart = elementKeyParts[i - 1]; + var matchStartIndex = elementKeyPart.Index; + var matchEndIndex = matchStartIndex + elementKeyPart.Length; + + ReplaceSeparatorsInSubstring(matchStartIndex, matchEndIndex, ref queryKey, separator, ref searchEndIndex); + } + + ReplaceSeparatorsInSubstring(searchEndIndex, 0, ref queryKey, separator, ref searchEndIndex); + + return subjectKey.EqualsIgnoreCase(queryKey); + } + + private static void ReplaceSeparatorsInSubstring( + int matchStartIndex, + int matchEndIndex, + ref string queryKey, + string separator, + ref int searchEndIndex) + { + var querySubstring = queryKey.Substring(matchEndIndex, searchEndIndex - matchEndIndex); + + if (querySubstring.IndexOf(separator, StringComparison.Ordinal) == -1) + { + searchEndIndex = matchStartIndex; + return; + } + + var flattenedQuerySubstring = querySubstring.Replace(separator, null); + + queryKey = queryKey + .Remove(matchEndIndex, searchEndIndex - matchEndIndex) + .Insert(matchEndIndex, flattenedQuerySubstring); + + searchEndIndex = matchStartIndex; + } + + /// + /// Determines if the matches the given , using + /// the given and the default element key part pattern. + /// + /// The subject key for which to make the determination. + /// The query key for which to make the determination. + /// The separator to use to separate key parts while making the determination. + /// + /// True if the matches the given , otherwise false. + /// + public static bool MatchesKey(this string subjectKey, string queryKey, string separator) + { + if (queryKey == null) + { + // This can happen when mapping to types with multiple, nested + // recursive relationships, e.g: + // Dictionary<,> -> Order -> OrderItems -> Order -> OrderItems + // ...it's basically not supported + return false; + } + + return subjectKey.EqualsIgnoreCase(queryKey) || + subjectKey.MatchesFlattenedKey(queryKey, separator); + } + + private static bool MatchesFlattenedKey(this string subjectKey, string queryKey, string separator) + { + return (queryKey.IndexOf(separator, StringComparison.Ordinal) != -1) && + subjectKey.EqualsIgnoreCase(queryKey.Replace(separator, null)); + } + + /// + /// Determines if the matches the given , using + /// the default separator and element key part pattern. + /// + /// The subject key for which to make the determination. + /// The query key for which to make the determination. + /// + /// True if the matches the given , otherwise false. + /// + public static bool MatchesKey(this string subjectKey, string queryKey) + { + if (queryKey == null) + { + // This can happen when mapping to types with multiple, nested + // recursive relationships, e.g: + // Dictionary<,> -> Order -> OrderItems -> Order -> OrderItems + // ...it's basically not supported + return false; + } + + return subjectKey.EqualsIgnoreCase(queryKey); + } + } +} \ No newline at end of file diff --git a/AgileMapper/Extensions/Internal/QuickUnwindExpressionVisitor.cs b/AgileMapper/Extensions/Internal/QuickUnwindExpressionVisitor.cs index 6de35f514..4f2a1d318 100644 --- a/AgileMapper/Extensions/Internal/QuickUnwindExpressionVisitor.cs +++ b/AgileMapper/Extensions/Internal/QuickUnwindExpressionVisitor.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Extensions.Internal { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal abstract class QuickUnwindExpressionVisitor : ExpressionVisitor { diff --git a/AgileMapper/Extensions/Internal/ReflectionExtensions.cs b/AgileMapper/Extensions/Internal/ReflectionExtensions.cs index 477bf1c5c..c285cc58d 100644 --- a/AgileMapper/Extensions/Internal/ReflectionExtensions.cs +++ b/AgileMapper/Extensions/Internal/ReflectionExtensions.cs @@ -2,7 +2,9 @@ { using System; using System.Collections.Generic; +#if NET_STANDARD using System.Linq; +#endif using System.Reflection; using NetStandardPolyfills; @@ -20,7 +22,7 @@ static ReflectionExtensions() { try { -#if !NET_STANDARD +#if !NET_STANDARD && !NET35 if (typeof(ReflectionExtensions).Assembly.IsFullyTrusted) { return; @@ -36,23 +38,6 @@ static ReflectionExtensions() } } - public static bool IsReadable(this PropertyInfo property) => property.GetGetter() != null; - - public static bool IsWriteable(this PropertyInfo property) => property.GetSetter() != null; - - public static bool HasAttribute(this MemberInfo memberInfo) - { -#if NET_STANDARD - return memberInfo - .CustomAttributes - .Any(a => a.AttributeType == typeof(TAttribute)); -#else - return memberInfo - .GetCustomAttributes(typeof(TAttribute), inherit: false) - .Any(); -#endif - } - public static bool HasKeyAttribute(this MemberInfo memberInfo) { #if NET_STANDARD diff --git a/AgileMapper/Extensions/Internal/StringExpressionExtensions.cs b/AgileMapper/Extensions/Internal/StringExpressionExtensions.cs index ff9554562..b5dcbc7ee 100644 --- a/AgileMapper/Extensions/Internal/StringExpressionExtensions.cs +++ b/AgileMapper/Extensions/Internal/StringExpressionExtensions.cs @@ -2,10 +2,14 @@ { using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using System.Text.RegularExpressions; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class StringExpressionExtensions { @@ -108,7 +112,7 @@ private static void OptimiseForStringConcat(IList expressions) public static Expression GetFirstOrDefaultCall(this Expression stringAccess) { return Expression.Call( - typeof(StringExtensions).GetPublicStaticMethod("FirstOrDefault"), + typeof(PublicStringExtensions).GetPublicStaticMethod("FirstOrDefault"), stringAccess); } @@ -121,7 +125,7 @@ public static Expression GetMatchesKeyCall( if (separator == null) { return Expression.Call( - typeof(StringExtensions).GetPublicStaticMethod("MatchesKey", parameterCount: 2), + typeof(PublicStringExtensions).GetPublicStaticMethod("MatchesKey", parameterCount: 2), stringAccess, keyValue); } @@ -141,7 +145,7 @@ public static Expression GetMatchesKeyCall( } return Expression.Call( - typeof(StringExtensions).GetPublicStaticMethod("MatchesKey", parameterCount: 4), + typeof(PublicStringExtensions).GetPublicStaticMethod("MatchesKey", parameterCount: 4), stringAccess, keyValue, separator, @@ -152,7 +156,7 @@ private static Expression GetMatchesKeyWithSeparatorCall(Expression stringAccess Expression separator) { return Expression.Call( - typeof(StringExtensions).GetPublicStaticMethod("MatchesKey", parameterCount: 3), + typeof(PublicStringExtensions).GetPublicStaticMethod("MatchesKey", parameterCount: 3), stringAccess, keyValue, separator); diff --git a/AgileMapper/Extensions/Internal/StringExtensions.cs b/AgileMapper/Extensions/Internal/StringExtensions.cs index ef4582947..316936a18 100644 --- a/AgileMapper/Extensions/Internal/StringExtensions.cs +++ b/AgileMapper/Extensions/Internal/StringExtensions.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Extensions.Internal { - using System.Text.RegularExpressions; + using System; + using System.Collections.Generic; +#if NET35 + using System.Linq; +#endif using static System.StringComparison; internal static class StringExtensions @@ -11,119 +15,46 @@ public static string ToPascalCase(this string value) public static string ToCamelCase(this string value) => char.ToLowerInvariant(value[0]) + value.Substring(1); - public static string FirstOrDefault(this string value) - { - if (string.IsNullOrEmpty(value) || (value.Length <= 1)) - { - return value; - } - - return value[0].ToString(); - } - public static bool EqualsIgnoreCase(this string value, string otherValue) => value.Equals(otherValue, OrdinalIgnoreCase); public static bool StartsWithIgnoreCase(this string value, string substring) => value.StartsWith(substring, OrdinalIgnoreCase); - public static bool MatchesKey( - this string subjectKey, - string queryKey, - string separator, - Regex elementKeyPartMatcher) - { - if (queryKey == null) - { - // This can happen when mapping to types with multiple, nested - // recursive relationships, e.g: - // Dictionary<,> -> Order -> OrderItems -> Order -> OrderItems - // ...it's basically not supported - return false; - } - - if (subjectKey.EqualsIgnoreCase(queryKey)) - { - return true; - } - - var elementKeyParts = elementKeyPartMatcher.Matches(queryKey); - - var searchEndIndex = queryKey.Length; - - for (var i = elementKeyParts.Count; i > 0; --i) - { - var elementKeyPart = elementKeyParts[i - 1]; - var matchStartIndex = elementKeyPart.Index; - var matchEndIndex = matchStartIndex + elementKeyPart.Length; +#if NET35 + public static Guid ToGuid(this string value) + => TryParseGuid(value, out var guid) ? guid.GetValueOrDefault() : default(Guid); - ReplaceSeparatorsInSubstring(matchStartIndex, matchEndIndex, ref queryKey, separator, ref searchEndIndex); - } - - ReplaceSeparatorsInSubstring(searchEndIndex, 0, ref queryKey, separator, ref searchEndIndex); - - return subjectKey.EqualsIgnoreCase(queryKey); - } + public static Guid? ToGuidNullable(this string value) + => TryParseGuid(value, out var guid) ? guid : default(Guid?); - private static void ReplaceSeparatorsInSubstring( - int matchStartIndex, - int matchEndIndex, - ref string queryKey, - string separator, - ref int searchEndIndex) + private static bool TryParseGuid(string value, out Guid? guid) { - var querySubstring = queryKey.Substring(matchEndIndex, searchEndIndex - matchEndIndex); - - if (querySubstring.IndexOf(separator, Ordinal) == -1) + if (value.IsNullOrWhiteSpace() || (value.Length != 36)) { - searchEndIndex = matchStartIndex; - return; + guid = default(Guid?); + return false; } - var flattenedQuerySubstring = querySubstring.Replace(separator, null); - - queryKey = queryKey - .Remove(matchEndIndex, searchEndIndex - matchEndIndex) - .Insert(matchEndIndex, flattenedQuerySubstring); - - searchEndIndex = matchStartIndex; - } - - public static bool MatchesKey(this string subjectKey, string queryKey, string separator) - { - if (queryKey == null) + if ((value[8] != '-') || (value[13] != '-') || (value[18] != '-') || (value[23] != '-')) { - // This can happen when mapping to types with multiple, nested - // recursive relationships, e.g: - // Dictionary<,> -> Order -> OrderItems -> Order -> OrderItems - // ...it's basically not supported + guid = default(Guid?); return false; } - return subjectKey.EqualsIgnoreCase(queryKey) || - subjectKey.MatchesFlattenedKey(queryKey, separator); - } - - private static bool MatchesFlattenedKey(this string subjectKey, string queryKey, string separator) - { - return (queryKey.IndexOf(separator, Ordinal) != -1) && - subjectKey.EqualsIgnoreCase(queryKey.Replace(separator, null)); - } - - public static bool MatchesKey(this string subjectKey, string queryKey) - { - if (queryKey == null) + foreach (var character in value) { - // This can happen when mapping to types with multiple, nested - // recursive relationships, e.g: - // Dictionary<,> -> Order -> OrderItems -> Order -> OrderItems - // ...it's basically not supported - return false; + if ((character != '-') && !char.IsLetterOrDigit(character)) + { + guid = default(Guid?); + return false; + } } - return subjectKey.EqualsIgnoreCase(queryKey); + guid = new Guid(value); + return true; } - +#endif public static string Pluralise(this string value) { if (value.Length == 1) @@ -171,5 +102,32 @@ private static bool IsConsonant(char character) return true; } + + public static string Join(this IEnumerable strings, string separator) + { +#if NET35 + return string.Join(separator, strings.ToArray()); +#else + return string.Join(separator, strings); +#endif + } + + public static string Join(this IEnumerable values, string separator) + { +#if NET35 + return string.Join(separator, values.Project(v => v.ToString()).ToArray()); +#else + return string.Join(separator, values); +#endif + } + + public static bool IsNullOrWhiteSpace(this string value) + { +#if NET35 + return (value == null) || (value.Trim() == string.Empty); +#else + return string.IsNullOrWhiteSpace(value); +#endif + } } } \ No newline at end of file diff --git a/AgileMapper/Extensions/Internal/Tuple.cs b/AgileMapper/Extensions/Internal/Tuple.cs new file mode 100644 index 000000000..f6f5ee061 --- /dev/null +++ b/AgileMapper/Extensions/Internal/Tuple.cs @@ -0,0 +1,23 @@ +#if NET35 +namespace AgileObjects.AgileMapper.Extensions.Internal +{ + internal static class Tuple + { + public static Tuple Create(T1 item1, T2 item2) + => new Tuple(item1, item2); + } + + internal class Tuple + { + public Tuple(T1 item1, T2 item2) + { + Item1 = item1; + Item2 = item2; + } + + public T1 Item1 { get; } + + public T2 Item2 { get; } + } +} +#endif \ No newline at end of file diff --git a/AgileMapper/Extensions/Internal/TypeExtensions.cs b/AgileMapper/Extensions/Internal/TypeExtensions.cs index ca751b860..0813dc9ce 100644 --- a/AgileMapper/Extensions/Internal/TypeExtensions.cs +++ b/AgileMapper/Extensions/Internal/TypeExtensions.cs @@ -12,6 +12,9 @@ internal static class TypeExtensions { private static readonly Assembly _msCorLib = typeof(string).GetAssembly(); +#if NET35 + private static readonly Assembly _systemCoreLib = typeof(Func<>).GetAssembly(); +#endif public static string GetShortVariableName(this Type type) { @@ -19,9 +22,7 @@ public static string GetShortVariableName(this Type type) var shortVariableName = variableName[0] + - string.Join( - string.Empty, - variableName.ToCharArray().Skip(1).Filter(char.IsUpper)); + variableName.ToCharArray().Skip(1).Filter(char.IsUpper).Join(string.Empty); shortVariableName = shortVariableName.ToLowerInvariant(); @@ -76,9 +77,9 @@ private static string GetGenericTypeVariableName(string variableName, Type namin variableName = variableName.Substring(0, variableName.IndexOf('`')); - variableName += string.Join( - string.Empty, - genericTypeArguments.Project(arg => "_" + arg.GetVariableNameInPascalCase())); + variableName += genericTypeArguments + .Project(arg => "_" + arg.GetVariableNameInPascalCase()) + .Join(string.Empty); return variableName; } @@ -120,7 +121,14 @@ public static bool RuntimeTypeNeeded(this Type type) (type == typeof(ICollection)); } - public static bool IsFromBcl(this Type type) => ReferenceEquals(type.GetAssembly(), _msCorLib); + public static bool IsFromBcl(this Type type) + { + return ReferenceEquals(type.GetAssembly(), _msCorLib) +#if NET35 + || ReferenceEquals(type.GetAssembly(), _systemCoreLib) +#endif + ; + } public static bool IsEnumerable(this Type type) { diff --git a/AgileMapper/MappingException.cs b/AgileMapper/MappingException.cs index 36c608995..9416dcce3 100644 --- a/AgileMapper/MappingException.cs +++ b/AgileMapper/MappingException.cs @@ -1,7 +1,6 @@ namespace AgileObjects.AgileMapper { using System; - using System.Linq.Expressions; using System.Reflection; #if SERIALIZATION_SUPPORTED using System.Runtime.Serialization; @@ -9,6 +8,11 @@ using Extensions.Internal; using Members; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif /// /// Represents an error that occurred during a mapping. diff --git a/AgileMapper/MappingExecutor.cs b/AgileMapper/MappingExecutor.cs index 5736a077a..91279b44a 100644 --- a/AgileMapper/MappingExecutor.cs +++ b/AgileMapper/MappingExecutor.cs @@ -2,48 +2,15 @@ { using System; using System.Collections.Generic; +#if DYNAMIC_SUPPORTED using System.Dynamic; - using System.Linq; +#endif using System.Linq.Expressions; - using System.Reflection; using Api; using Api.Configuration; - using Caching; using Extensions.Internal; - using NetStandardPolyfills; using ObjectPopulation; - internal static class MappingExecutorBridge - { - private static readonly ParameterExpression _selectorParameter = - Parameters.Create(typeof(ITargetSelector)); - - private static readonly MethodInfo _typedToANewMethod = typeof(ITargetSelector) - .GetPublicInstanceMethods("ToANew") - .First(m => m.IsGenericMethod && m.GetParameters().None()); - - private static readonly ICache, object>> _createNewCallersByTargetType = - GlobalContext.Instance.Cache.CreateScoped, object>>(); - - public static object CreateNew(Type resultType, ITargetSelector selector) - { - var typedCaller = _createNewCallersByTargetType.GetOrAdd(resultType, rt => - { - var typedCreateNewCall = Expression.Call( - _selectorParameter, - _typedToANewMethod.MakeGenericMethod(rt)); - - var createNewCaller = Expression.Lambda, object>>( - typedCreateNewCall, - _selectorParameter); - - return createNewCaller.Compile(); - }); - - return typedCaller.Invoke(selector); - } - } - internal class MappingExecutor : ITargetSelector, IFlatteningSelector, @@ -179,11 +146,13 @@ private TTarget PerformMapping(TTarget target) #region IFlatteningSelector Members +#if DYNAMIC_SUPPORTED dynamic IFlatteningSelector.ToDynamic( params Expression>>[] configurations) { return configurations.Any() ? ToANew(configurations) : ToANew(); } +#endif Dictionary IFlatteningSelector.ToDictionary( params Expression>>>[] configurations) @@ -202,10 +171,12 @@ string IFlatteningSelector.ToQueryString( { var flattened = configurations.Any() ? ToANew(configurations) : ToANew>(); - var queryString = string.Join( - "&", - flattened.Project(kvp => Uri.EscapeDataString(kvp.Key) + "=" + Uri.EscapeDataString(kvp.Value))); - + var queryString = flattened + .Project(kvp => Uri.EscapeDataString(kvp.Key) + "=" + Uri.EscapeDataString(kvp.Value)) + .Join("&"); +#if NET35 + queryString = queryString.Replace("!", "%21"); +#endif return queryString.Replace(".", "%2E"); } diff --git a/AgileMapper/MappingExecutorBridge.cs b/AgileMapper/MappingExecutorBridge.cs new file mode 100644 index 000000000..cb6a53f01 --- /dev/null +++ b/AgileMapper/MappingExecutorBridge.cs @@ -0,0 +1,46 @@ +namespace AgileObjects.AgileMapper +{ + using System; + using System.Linq; + using System.Reflection; + using Api; + using Caching; + using Extensions.Internal; + using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif + + internal static class MappingExecutorBridge + { + private static readonly ParameterExpression _selectorParameter = + Parameters.Create(typeof(ITargetSelector)); + + private static readonly MethodInfo _typedToANewMethod = typeof(ITargetSelector) + .GetPublicInstanceMethods("ToANew") + .First(m => m.IsGenericMethod && m.GetParameters().None()); + + private static readonly ICache, object>> _createNewCallersByTargetType = + GlobalContext.Instance.Cache.CreateScoped, object>>(); + + public static object CreateNew(Type resultType, ITargetSelector selector) + { + var typedCaller = _createNewCallersByTargetType.GetOrAdd(resultType, rt => + { + var typedCreateNewCall = Expression.Call( + _selectorParameter, + _typedToANewMethod.MakeGenericMethod(rt)); + + var createNewCaller = Expression.Lambda, object>>( + typedCreateNewCall, + _selectorParameter); + + return createNewCaller.Compile(); + }); + + return typedCaller.Invoke(selector); + } + } +} \ No newline at end of file diff --git a/AgileMapper/MappingRuleSet.cs b/AgileMapper/MappingRuleSet.cs index 77aad73aa..bfcf5b163 100644 --- a/AgileMapper/MappingRuleSet.cs +++ b/AgileMapper/MappingRuleSet.cs @@ -1,12 +1,16 @@ namespace AgileObjects.AgileMapper { - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members.Population; using ObjectPopulation.Enumerables; using ObjectPopulation.MapperKeys; using ObjectPopulation.Recursion; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class MappingRuleSet { diff --git a/AgileMapper/MappingRuleSetSettings.cs b/AgileMapper/MappingRuleSetSettings.cs index da9a5534e..be12f844c 100644 --- a/AgileMapper/MappingRuleSetSettings.cs +++ b/AgileMapper/MappingRuleSetSettings.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper { using System; +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal class MappingRuleSetSettings { diff --git a/AgileMapper/Members/ChildMemberMapperData.cs b/AgileMapper/Members/ChildMemberMapperData.cs index 192069737..f6f9868f3 100644 --- a/AgileMapper/Members/ChildMemberMapperData.cs +++ b/AgileMapper/Members/ChildMemberMapperData.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Members { - using System.Linq.Expressions; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ChildMemberMapperData : BasicMapperData, IMemberMapperData { diff --git a/AgileMapper/Members/ConfiguredSourceMember.cs b/AgileMapper/Members/ConfiguredSourceMember.cs index f8aa643d9..72b04fbc6 100644 --- a/AgileMapper/Members/ConfiguredSourceMember.cs +++ b/AgileMapper/Members/ConfiguredSourceMember.cs @@ -3,11 +3,15 @@ namespace AgileObjects.AgileMapper.Members using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Caching; using Extensions.Internal; using ReadableExpressions; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ConfiguredSourceMember : IQualifiedMember { diff --git a/AgileMapper/Members/Dictionaries/DictionaryEntrySourceMember.cs b/AgileMapper/Members/Dictionaries/DictionaryEntrySourceMember.cs index 9f229646d..0da751b3d 100644 --- a/AgileMapper/Members/Dictionaries/DictionaryEntrySourceMember.cs +++ b/AgileMapper/Members/Dictionaries/DictionaryEntrySourceMember.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.Members.Dictionaries { using System; - using System.Linq.Expressions; using Extensions.Internal; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionaryEntrySourceMember : IQualifiedMember { diff --git a/AgileMapper/Members/Dictionaries/DictionaryMemberMapperDataExtensions.cs b/AgileMapper/Members/Dictionaries/DictionaryMemberMapperDataExtensions.cs index c260da662..74f0af668 100644 --- a/AgileMapper/Members/Dictionaries/DictionaryMemberMapperDataExtensions.cs +++ b/AgileMapper/Members/Dictionaries/DictionaryMemberMapperDataExtensions.cs @@ -2,9 +2,13 @@ namespace AgileObjects.AgileMapper.Members.Dictionaries { using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class DictionaryMemberMapperDataExtensions { diff --git a/AgileMapper/Members/Dictionaries/DictionarySourceMember.cs b/AgileMapper/Members/Dictionaries/DictionarySourceMember.cs index 01359babc..4379a61b6 100644 --- a/AgileMapper/Members/Dictionaries/DictionarySourceMember.cs +++ b/AgileMapper/Members/Dictionaries/DictionarySourceMember.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.Members.Dictionaries { using System; - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionarySourceMember : IQualifiedMember { diff --git a/AgileMapper/Members/Dictionaries/DictionaryTargetMember.cs b/AgileMapper/Members/Dictionaries/DictionaryTargetMember.cs index 93e05d103..e63018ec8 100644 --- a/AgileMapper/Members/Dictionaries/DictionaryTargetMember.cs +++ b/AgileMapper/Members/Dictionaries/DictionaryTargetMember.cs @@ -2,11 +2,16 @@ namespace AgileObjects.AgileMapper.Members.Dictionaries { using System; using System.Dynamic; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; + using static Microsoft.Scripting.Ast.ExpressionType; +#else + using System.Linq.Expressions; using static System.Linq.Expressions.ExpressionType; +#endif internal class DictionaryTargetMember : QualifiedMember { diff --git a/AgileMapper/Members/ExpressionInfoFinder.cs b/AgileMapper/Members/ExpressionInfoFinder.cs index db0ff845c..ee964dfa3 100644 --- a/AgileMapper/Members/ExpressionInfoFinder.cs +++ b/AgileMapper/Members/ExpressionInfoFinder.cs @@ -3,12 +3,17 @@ namespace AgileObjects.AgileMapper.Members using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; using ReadableExpressions.Extensions; using TypeConversion; +#if NET35 + using Microsoft.Scripting.Ast; + using static Microsoft.Scripting.Ast.ExpressionType; +#else + using System.Linq.Expressions; using static System.Linq.Expressions.ExpressionType; +#endif using static Member; internal class ExpressionInfoFinder diff --git a/AgileMapper/Members/IMemberMapperData.cs b/AgileMapper/Members/IMemberMapperData.cs index 47b7d81de..207e38684 100644 --- a/AgileMapper/Members/IMemberMapperData.cs +++ b/AgileMapper/Members/IMemberMapperData.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Members { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif using ObjectPopulation; internal interface IMemberMapperData : IBasicMapperData diff --git a/AgileMapper/Members/IQualifiedMember.cs b/AgileMapper/Members/IQualifiedMember.cs index ce997244d..b00ef482c 100644 --- a/AgileMapper/Members/IQualifiedMember.cs +++ b/AgileMapper/Members/IQualifiedMember.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Members { using System; +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IQualifiedMember { diff --git a/AgileMapper/Members/Member.cs b/AgileMapper/Members/Member.cs index 2aaf32975..843d84c33 100644 --- a/AgileMapper/Members/Member.cs +++ b/AgileMapper/Members/Member.cs @@ -1,13 +1,17 @@ namespace AgileObjects.AgileMapper.Members { using System; - using System.Linq.Expressions; using System.Reflection; using Dictionaries; using Extensions.Internal; using NetStandardPolyfills; using ObjectPopulation; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class Member { @@ -123,7 +127,7 @@ public static Member Property(PropertyInfo property) property.PropertyType, property, (instance, p) => Expression.Property(instance, (PropertyInfo)p), - property.IsWriteable()); + property.IsWritable()); } public static Member GetMethod(MethodInfo method) diff --git a/AgileMapper/Members/MemberExtensions.cs b/AgileMapper/Members/MemberExtensions.cs index c6abe5da6..4555ea49a 100644 --- a/AgileMapper/Members/MemberExtensions.cs +++ b/AgileMapper/Members/MemberExtensions.cs @@ -5,18 +5,23 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using NetStandardPolyfills; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; + using LinqExp = System.Linq.Expressions; +#else + using System.Linq.Expressions; +#endif using static System.StringComparison; using static Constants; internal static class MemberExtensions { public static string GetFullName(this IEnumerable members) - => string.Join(string.Empty, members.Project(m => m.JoiningName)); + => members.Project(m => m.JoiningName).Join(string.Empty); public static string GetFriendlySourcePath(this IQualifiedMember sourceMember, IMemberMapperData rootMapperData) => GetFriendlyMemberPath(sourceMember, rootMapperData.SourceMember); @@ -250,6 +255,10 @@ public static Expression GetPopulation(this Member targetMember, Expression inst return population; } +#if NET35 + public static QualifiedMember ToSourceMember(this LinqExp.Expression memberAccess, MapperContext mapperContext) + => memberAccess.ToDlrExpression().ToSourceMember(mapperContext); +#endif public static QualifiedMember ToSourceMember(this Expression memberAccess, MapperContext mapperContext) { return CreateMember( @@ -259,6 +268,10 @@ public static QualifiedMember ToSourceMember(this Expression memberAccess, Mappe mapperContext); } +#if NET35 + public static QualifiedMember ToTargetMember(this LinqExp.LambdaExpression memberAccess, MapperContext mapperContext) + => memberAccess.ToDlrExpression().ToTargetMember(mapperContext); +#endif public static QualifiedMember ToTargetMember(this LambdaExpression memberAccess, MapperContext mapperContext) { return CreateMember( @@ -360,10 +373,16 @@ private static Expression GetMethodCallMemberAccess(MethodCallExpression methodC { return methodCall; } - - // ReSharper disable once PossibleNullReferenceException - var methodInfo = (MethodInfo)((ConstantExpression)methodCall.Object).Value; +#if NET35 + var methodInfoValue = methodCall.Arguments.Last(); + var instance = methodCall.Arguments[1]; +#else + var methodInfoValue = methodCall.Object; var instance = methodCall.Arguments.Last(); +#endif + // ReSharper disable once PossibleNullReferenceException + var methodInfo = (MethodInfo)((ConstantExpression)methodInfoValue).Value; + var valueParameter = Parameters.Create(methodInfo.GetParameters().First().ParameterType, "value"); return Expression.Call(instance, methodInfo, valueParameter); diff --git a/AgileMapper/Members/MemberIdentifierSet.cs b/AgileMapper/Members/MemberIdentifierSet.cs index c7b0a71cf..f5f16e3fa 100644 --- a/AgileMapper/Members/MemberIdentifierSet.cs +++ b/AgileMapper/Members/MemberIdentifierSet.cs @@ -3,10 +3,14 @@ namespace AgileObjects.AgileMapper.Members using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Configuration; using NetStandardPolyfills; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class MemberIdentifierSet { diff --git a/AgileMapper/Members/MemberMapperDataExtensions.cs b/AgileMapper/Members/MemberMapperDataExtensions.cs index a47c1485b..7e983fb3c 100644 --- a/AgileMapper/Members/MemberMapperDataExtensions.cs +++ b/AgileMapper/Members/MemberMapperDataExtensions.cs @@ -4,13 +4,17 @@ namespace AgileObjects.AgileMapper.Members using System.Collections.Generic; using System.Diagnostics; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using DataSources; using Dictionaries; using Extensions.Internal; using NetStandardPolyfills; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif using static Member; internal static class MemberMapperDataExtensions diff --git a/AgileMapper/Members/NamingSettings.cs b/AgileMapper/Members/NamingSettings.cs index b28ac7f78..58c3c1849 100644 --- a/AgileMapper/Members/NamingSettings.cs +++ b/AgileMapper/Members/NamingSettings.cs @@ -28,8 +28,8 @@ public NamingSettings(CacheSet mapperScopedCache) _joinedNameFactories = new List, string>> { - names => string.Join(string.Empty, names), - names => string.Join(".", names) + names => names.Join(string.Empty), + names => names.Join(".") }; _customNameMatchers = new List(); diff --git a/AgileMapper/Members/Population/DefaultMemberPopulationFactory.cs b/AgileMapper/Members/Population/DefaultMemberPopulationFactory.cs index 1c13a98fc..c1c8206e5 100644 --- a/AgileMapper/Members/Population/DefaultMemberPopulationFactory.cs +++ b/AgileMapper/Members/Population/DefaultMemberPopulationFactory.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Members.Population { - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DefaultMemberPopulationFactory : MemberPopulationFactoryBase { diff --git a/AgileMapper/Members/Population/IMemberPopulationContext.cs b/AgileMapper/Members/Population/IMemberPopulationContext.cs index da75c487f..277554294 100644 --- a/AgileMapper/Members/Population/IMemberPopulationContext.cs +++ b/AgileMapper/Members/Population/IMemberPopulationContext.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Members.Population { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif using DataSources; internal interface IMemberPopulationContext diff --git a/AgileMapper/Members/Population/IMemberPopulationFactory.cs b/AgileMapper/Members/Population/IMemberPopulationFactory.cs index bec1b445e..0d1582192 100644 --- a/AgileMapper/Members/Population/IMemberPopulationFactory.cs +++ b/AgileMapper/Members/Population/IMemberPopulationFactory.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Members.Population { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IMemberPopulationFactory { diff --git a/AgileMapper/Members/Population/IMemberPopulator.cs b/AgileMapper/Members/Population/IMemberPopulator.cs index 3dd455d80..ff8c9146b 100644 --- a/AgileMapper/Members/Population/IMemberPopulator.cs +++ b/AgileMapper/Members/Population/IMemberPopulator.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Members.Population { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IMemberPopulator { diff --git a/AgileMapper/Members/Population/MemberMergePopulationFactory.cs b/AgileMapper/Members/Population/MemberMergePopulationFactory.cs index c349a7059..f81f14429 100644 --- a/AgileMapper/Members/Population/MemberMergePopulationFactory.cs +++ b/AgileMapper/Members/Population/MemberMergePopulationFactory.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Members.Population { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal class MemberMergePopulationFactory : MemberPopulationFactoryBase { diff --git a/AgileMapper/Members/Population/MemberPopulationFactoryBase.cs b/AgileMapper/Members/Population/MemberPopulationFactoryBase.cs index 38254d26b..8822c52be 100644 --- a/AgileMapper/Members/Population/MemberPopulationFactoryBase.cs +++ b/AgileMapper/Members/Population/MemberPopulationFactoryBase.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Members.Population { - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal abstract class MemberPopulationFactoryBase : IMemberPopulationFactory { diff --git a/AgileMapper/Members/Population/MemberPopulator.cs b/AgileMapper/Members/Population/MemberPopulator.cs index 4ef9a06a1..91cd82338 100644 --- a/AgileMapper/Members/Population/MemberPopulator.cs +++ b/AgileMapper/Members/Population/MemberPopulator.cs @@ -2,10 +2,14 @@ namespace AgileObjects.AgileMapper.Members.Population { using System; using System.Linq; - using System.Linq.Expressions; using Configuration; using DataSources; using ReadableExpressions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class MemberPopulator : IMemberPopulationContext, IMemberPopulator { diff --git a/AgileMapper/Members/Population/MemberPopulatorFactory.cs b/AgileMapper/Members/Population/MemberPopulatorFactory.cs index 99ff1b953..33a9578ce 100644 --- a/AgileMapper/Members/Population/MemberPopulatorFactory.cs +++ b/AgileMapper/Members/Population/MemberPopulatorFactory.cs @@ -2,12 +2,16 @@ namespace AgileObjects.AgileMapper.Members.Population { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Configuration; using DataSources.Finders; using Extensions.Internal; using Members; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class MemberPopulatorFactory { diff --git a/AgileMapper/Members/QualifiedMember.cs b/AgileMapper/Members/QualifiedMember.cs index 9b48c0094..3d506fbf7 100644 --- a/AgileMapper/Members/QualifiedMember.cs +++ b/AgileMapper/Members/QualifiedMember.cs @@ -4,12 +4,16 @@ namespace AgileObjects.AgileMapper.Members using System.Collections.Generic; using System.Diagnostics; using System.Linq; - using System.Linq.Expressions; using Caching; using Dictionaries; using Extensions.Internal; using NetStandardPolyfills; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class QualifiedMember : IQualifiedMember { diff --git a/AgileMapper/ObjectPopulation/CachingExtensions.cs b/AgileMapper/ObjectPopulation/CachingExtensions.cs index 10bf84480..a93ea1160 100644 --- a/AgileMapper/ObjectPopulation/CachingExtensions.cs +++ b/AgileMapper/ObjectPopulation/CachingExtensions.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; - using System.Linq.Expressions; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class CachingExtensions { diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeConstructionFactory.cs b/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeConstructionFactory.cs index 853e77d6e..5c3f897df 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeConstructionFactory.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeConstructionFactory.cs @@ -3,7 +3,6 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using Caching; using DataSources; @@ -12,6 +11,12 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes using MapperKeys; using Members; using NetStandardPolyfills; +#if NET35 + using Extensions; + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ComplexTypeConstructionFactory { diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeMappingExpressionFactory.cs b/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeMappingExpressionFactory.cs index e901d8cf4..be378d39d 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeMappingExpressionFactory.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/ComplexTypeMappingExpressionFactory.cs @@ -1,12 +1,16 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes { using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using Members; using NetStandardPolyfills; using ReadableExpressions; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ComplexTypeMappingExpressionFactory : MappingExpressionFactoryBase { diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/ISourceShortCircuitFactory.cs b/AgileMapper/ObjectPopulation/ComplexTypes/ISourceShortCircuitFactory.cs index 09ba15676..46de515a3 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/ISourceShortCircuitFactory.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/ISourceShortCircuitFactory.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface ISourceShortCircuitFactory { diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/MemberInitPopulationExpressionFactory.cs b/AgileMapper/ObjectPopulation/ComplexTypes/MemberInitPopulationExpressionFactory.cs index 3656ed29c..0784408f6 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/MemberInitPopulationExpressionFactory.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/MemberInitPopulationExpressionFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes { using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using Members.Population; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class MemberInitPopulationExpressionFactory : PopulationExpressionFactoryBase { diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/MultiStatementPopulationExpressionFactory.cs b/AgileMapper/ObjectPopulation/ComplexTypes/MultiStatementPopulationExpressionFactory.cs index fe368a0a8..a9e8cdb3e 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/MultiStatementPopulationExpressionFactory.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/MultiStatementPopulationExpressionFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes { using System.Collections.Generic; - using System.Linq.Expressions; using Members; using Members.Population; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif using static CallbackPosition; internal class MultiStatementPopulationExpressionFactory : PopulationExpressionFactoryBase diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/PopulationExpressionFactoryBase.cs b/AgileMapper/ObjectPopulation/ComplexTypes/PopulationExpressionFactoryBase.cs index ffcc4180b..5a7cbd05e 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/PopulationExpressionFactoryBase.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/PopulationExpressionFactoryBase.cs @@ -2,11 +2,15 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes { using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members; using Members.Population; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif using static CallbackPosition; internal abstract class PopulationExpressionFactoryBase diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/SourceDictionaryShortCircuitFactory.cs b/AgileMapper/ObjectPopulation/ComplexTypes/SourceDictionaryShortCircuitFactory.cs index 3b26db8ee..e583d8bb7 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/SourceDictionaryShortCircuitFactory.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/SourceDictionaryShortCircuitFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes { - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceDictionaryShortCircuitFactory : ISourceShortCircuitFactory { diff --git a/AgileMapper/ObjectPopulation/ComplexTypes/TargetObjectResolutionFactory.cs b/AgileMapper/ObjectPopulation/ComplexTypes/TargetObjectResolutionFactory.cs index 29c238a80..ee6425386 100644 --- a/AgileMapper/ObjectPopulation/ComplexTypes/TargetObjectResolutionFactory.cs +++ b/AgileMapper/ObjectPopulation/ComplexTypes/TargetObjectResolutionFactory.cs @@ -2,9 +2,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class TargetObjectResolutionFactory { diff --git a/AgileMapper/ObjectPopulation/ConfiguredObjectFactory.cs b/AgileMapper/ObjectPopulation/ConfiguredObjectFactory.cs index d65a4bd3d..bf2db6f14 100644 --- a/AgileMapper/ObjectPopulation/ConfiguredObjectFactory.cs +++ b/AgileMapper/ObjectPopulation/ConfiguredObjectFactory.cs @@ -1,13 +1,22 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; - using System.Linq.Expressions; using Configuration; using Members; using NetStandardPolyfills; using ReadableExpressions.Extensions; - - internal class ConfiguredObjectFactory : UserConfiguredItemBase, IPotentialClone +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif + + internal class ConfiguredObjectFactory : + UserConfiguredItemBase, + IPotentialClone +#if NET35 + , IComparable +#endif { private readonly Type _objectType; private readonly ConfiguredLambdaInfo _factoryInfo; @@ -81,5 +90,10 @@ public bool IsReplacementFor(IPotentialClone clonedObjectFactory) => ConflictsWith((ConfiguredObjectFactory)clonedObjectFactory); #endregion + +#if NET35 + int IComparable.CompareTo(ConfiguredObjectFactory other) + => DoComparisonTo(other); +#endif } } \ No newline at end of file diff --git a/AgileMapper/ObjectPopulation/DerivedComplexTypeMappingsFactory.cs b/AgileMapper/ObjectPopulation/DerivedComplexTypeMappingsFactory.cs index 368fa7b28..2167f9c4e 100644 --- a/AgileMapper/ObjectPopulation/DerivedComplexTypeMappingsFactory.cs +++ b/AgileMapper/ObjectPopulation/DerivedComplexTypeMappingsFactory.cs @@ -3,10 +3,14 @@ namespace AgileObjects.AgileMapper.ObjectPopulation using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Configuration; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class DerivedComplexTypeMappingsFactory { diff --git a/AgileMapper/ObjectPopulation/DerivedMappingFactory.cs b/AgileMapper/ObjectPopulation/DerivedMappingFactory.cs index d30227485..a08975c5c 100644 --- a/AgileMapper/ObjectPopulation/DerivedMappingFactory.cs +++ b/AgileMapper/ObjectPopulation/DerivedMappingFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class DerivedMappingFactory { diff --git a/AgileMapper/ObjectPopulation/DerivedSourceTypeCheck.cs b/AgileMapper/ObjectPopulation/DerivedSourceTypeCheck.cs index 29fde6b8a..23f7b532d 100644 --- a/AgileMapper/ObjectPopulation/DerivedSourceTypeCheck.cs +++ b/AgileMapper/ObjectPopulation/DerivedSourceTypeCheck.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DerivedSourceTypeCheck { diff --git a/AgileMapper/ObjectPopulation/DictionaryMappingExpressionFactory.cs b/AgileMapper/ObjectPopulation/DictionaryMappingExpressionFactory.cs index bc5b8f934..c01b5138a 100644 --- a/AgileMapper/ObjectPopulation/DictionaryMappingExpressionFactory.cs +++ b/AgileMapper/ObjectPopulation/DictionaryMappingExpressionFactory.cs @@ -3,7 +3,6 @@ namespace AgileObjects.AgileMapper.ObjectPopulation using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using ComplexTypes; using DataSources; @@ -14,6 +13,11 @@ namespace AgileObjects.AgileMapper.ObjectPopulation using Members.Population; using NetStandardPolyfills; using ReadableExpressions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionaryMappingExpressionFactory : MappingExpressionFactoryBase { diff --git a/AgileMapper/ObjectPopulation/Enumerables/CopySourceEnumerablePopulationStrategy.cs b/AgileMapper/ObjectPopulation/Enumerables/CopySourceEnumerablePopulationStrategy.cs index 57e6e932d..b527a8ad0 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/CopySourceEnumerablePopulationStrategy.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/CopySourceEnumerablePopulationStrategy.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal struct CopySourceEnumerablePopulationStrategy : IEnumerablePopulationStrategy { diff --git a/AgileMapper/ObjectPopulation/Enumerables/DefaultSourceEnumerableAdapter.cs b/AgileMapper/ObjectPopulation/Enumerables/DefaultSourceEnumerableAdapter.cs index 1095d5d2b..5dd111103 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/DefaultSourceEnumerableAdapter.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/DefaultSourceEnumerableAdapter.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal class DefaultSourceEnumerableAdapter : SourceEnumerableAdapterBase, ISourceEnumerableAdapter { diff --git a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryPopulationBuilder.cs b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryPopulationBuilder.cs index ceb47013a..8a1f4f7bf 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryPopulationBuilder.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryPopulationBuilder.cs @@ -3,12 +3,16 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members; using Members.Dictionaries; using Members.Population; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionaryPopulationBuilder { diff --git a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryToDictionaryPopulationLoopData.cs b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryToDictionaryPopulationLoopData.cs index e33314747..1e568182e 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryToDictionaryPopulationLoopData.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/DictionaryToDictionaryPopulationLoopData.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Dictionaries { using System.Collections.Generic; - using System.Linq.Expressions; using Members.Dictionaries; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DictionaryToDictionaryPopulationLoopData : EnumerableSourcePopulationLoopData { diff --git a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryAdapter.cs b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryAdapter.cs index c67e039ea..c168868cd 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryAdapter.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryAdapter.cs @@ -2,12 +2,16 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Dictionaries { using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members; using Members.Dictionaries; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceElementsDictionaryAdapter : SourceEnumerableAdapterBase, ISourceEnumerableAdapter { diff --git a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryPopulationLoopData.cs b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryPopulationLoopData.cs index 45ad8a862..7ab23d8b6 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryPopulationLoopData.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceElementsDictionaryPopulationLoopData.cs @@ -2,10 +2,14 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Dictionaries { using System; using System.Collections.Generic; - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceElementsDictionaryPopulationLoopData : IPopulationLoopData { diff --git a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceInstanceDictionaryAdapter.cs b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceInstanceDictionaryAdapter.cs index 2e3ccc9e1..4d8903c55 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceInstanceDictionaryAdapter.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceInstanceDictionaryAdapter.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Dictionaries { - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members.Dictionaries; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceInstanceDictionaryAdapter : SourceEnumerableAdapterBase, ISourceEnumerableAdapter { diff --git a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryAdapter.cs b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryAdapter.cs index efec1e291..cda0543ed 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryAdapter.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryAdapter.cs @@ -2,10 +2,14 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Dictionaries { using System.Collections; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members.Dictionaries; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceObjectDictionaryAdapter : SourceEnumerableAdapterBase, ISourceEnumerableAdapter { diff --git a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryPopulationLoopData.cs b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryPopulationLoopData.cs index 9cde53b83..fe7240217 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryPopulationLoopData.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/Dictionaries/SourceObjectDictionaryPopulationLoopData.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Dictionaries { - using System.Linq.Expressions; using DataSources; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceObjectDictionaryPopulationLoopData : IPopulationLoopData { diff --git a/AgileMapper/ObjectPopulation/Enumerables/EnumerableMappingExpressionFactory.cs b/AgileMapper/ObjectPopulation/Enumerables/EnumerableMappingExpressionFactory.cs index 7748802a0..5c3e699a2 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/EnumerableMappingExpressionFactory.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/EnumerableMappingExpressionFactory.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using Members; using ReadableExpressions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumerableMappingExpressionFactory : MappingExpressionFactoryBase { diff --git a/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationBuilder.cs b/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationBuilder.cs index 8ed548568..f6c70d2b3 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationBuilder.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationBuilder.cs @@ -3,12 +3,16 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using Caching; using Extensions.Internal; using Members; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumerablePopulationBuilder { diff --git a/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationContext.cs b/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationContext.cs index 4298046b7..1d690cd7d 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationContext.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/EnumerablePopulationContext.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { using System; - using System.Linq.Expressions; using Extensions.Internal; using Members; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumerablePopulationContext { diff --git a/AgileMapper/ObjectPopulation/Enumerables/EnumerableSourcePopulationLoopData.cs b/AgileMapper/ObjectPopulation/Enumerables/EnumerableSourcePopulationLoopData.cs index 2c933b3ed..ec6837d97 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/EnumerableSourcePopulationLoopData.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/EnumerableSourcePopulationLoopData.cs @@ -3,10 +3,14 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables using System; using System.Collections; using System.Collections.Generic; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumerableSourcePopulationLoopData : IPopulationLoopData { diff --git a/AgileMapper/ObjectPopulation/Enumerables/EnumerableTypeHelper.cs b/AgileMapper/ObjectPopulation/Enumerables/EnumerableTypeHelper.cs index 70875ddfe..e6a655843 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/EnumerableTypeHelper.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/EnumerableTypeHelper.cs @@ -3,10 +3,14 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables using System; using System.Collections.Generic; using System.Collections.ObjectModel; - using System.Linq.Expressions; using Extensions.Internal; using Members; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumerableTypeHelper { diff --git a/AgileMapper/ObjectPopulation/Enumerables/IEnumerablePopulationStrategy.cs b/AgileMapper/ObjectPopulation/Enumerables/IEnumerablePopulationStrategy.cs index ebba1ed87..18187c10c 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/IEnumerablePopulationStrategy.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/IEnumerablePopulationStrategy.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IEnumerablePopulationStrategy { diff --git a/AgileMapper/ObjectPopulation/Enumerables/IPopulationLoopData.cs b/AgileMapper/ObjectPopulation/Enumerables/IPopulationLoopData.cs index c3849ab69..906259723 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/IPopulationLoopData.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/IPopulationLoopData.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IPopulationLoopData { diff --git a/AgileMapper/ObjectPopulation/Enumerables/ISourceEnumerableAdapter.cs b/AgileMapper/ObjectPopulation/Enumerables/ISourceEnumerableAdapter.cs index 3c0ac8277..b66b515c7 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/ISourceEnumerableAdapter.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/ISourceEnumerableAdapter.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface ISourceEnumerableAdapter { diff --git a/AgileMapper/ObjectPopulation/Enumerables/IndexedSourcePopulationLoopData.cs b/AgileMapper/ObjectPopulation/Enumerables/IndexedSourcePopulationLoopData.cs index c3bfb842f..0df05c34f 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/IndexedSourcePopulationLoopData.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/IndexedSourcePopulationLoopData.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class IndexedSourcePopulationLoopData : IPopulationLoopData { diff --git a/AgileMapper/ObjectPopulation/Enumerables/MergeEnumerablePopulationStrategy.cs b/AgileMapper/ObjectPopulation/Enumerables/MergeEnumerablePopulationStrategy.cs index a733f5a3d..fd4a22833 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/MergeEnumerablePopulationStrategy.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/MergeEnumerablePopulationStrategy.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal struct MergeEnumerablePopulationStrategy : IEnumerablePopulationStrategy { diff --git a/AgileMapper/ObjectPopulation/Enumerables/OverwriteEnumerablePopulationStrategy.cs b/AgileMapper/ObjectPopulation/Enumerables/OverwriteEnumerablePopulationStrategy.cs index caeb01ad3..5f8c43a72 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/OverwriteEnumerablePopulationStrategy.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/OverwriteEnumerablePopulationStrategy.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal struct OverwriteEnumerablePopulationStrategy : IEnumerablePopulationStrategy { diff --git a/AgileMapper/ObjectPopulation/Enumerables/PopulationLoopDataExtensions.cs b/AgileMapper/ObjectPopulation/Enumerables/PopulationLoopDataExtensions.cs index a43649afc..4b3b08bc3 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/PopulationLoopDataExtensions.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/PopulationLoopDataExtensions.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { using System; - using System.Linq.Expressions; using Extensions.Internal; using TypeConversion; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class PopulationLoopDataExtensions { diff --git a/AgileMapper/ObjectPopulation/Enumerables/ProjectSourceEnumerablePopulationStrategy.cs b/AgileMapper/ObjectPopulation/Enumerables/ProjectSourceEnumerablePopulationStrategy.cs index 425dfa996..031aecd31 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/ProjectSourceEnumerablePopulationStrategy.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/ProjectSourceEnumerablePopulationStrategy.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal struct ProjectSourceEnumerablePopulationStrategy : IEnumerablePopulationStrategy { diff --git a/AgileMapper/ObjectPopulation/Enumerables/SourceEnumerableAdapterBase.cs b/AgileMapper/ObjectPopulation/Enumerables/SourceEnumerableAdapterBase.cs index 0f0873326..2a191d31a 100644 --- a/AgileMapper/ObjectPopulation/Enumerables/SourceEnumerableAdapterBase.cs +++ b/AgileMapper/ObjectPopulation/Enumerables/SourceEnumerableAdapterBase.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.Enumerables { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal abstract class SourceEnumerableAdapterBase { diff --git a/AgileMapper/ObjectPopulation/IObjectCreationMappingData.cs b/AgileMapper/ObjectPopulation/IObjectCreationMappingData.cs index 0d8a60191..729ea5db3 100644 --- a/AgileMapper/ObjectPopulation/IObjectCreationMappingData.cs +++ b/AgileMapper/ObjectPopulation/IObjectCreationMappingData.cs @@ -8,7 +8,8 @@ /// The type of source object being mapped from during the object creation. /// The type of target object being mapped to during the object creation. /// The type of object that was created. - public interface IObjectCreationMappingData : IMappingData + public interface IObjectCreationMappingData + : IMappingData { /// /// Gets the object that was created. diff --git a/AgileMapper/ObjectPopulation/IObjectMapper.cs b/AgileMapper/ObjectPopulation/IObjectMapper.cs index 84651d5be..a59f2f512 100644 --- a/AgileMapper/ObjectPopulation/IObjectMapper.cs +++ b/AgileMapper/ObjectPopulation/IObjectMapper.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System.Collections.Generic; - using System.Linq.Expressions; using Recursion; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal interface IObjectMapper : IObjectMapperFunc { diff --git a/AgileMapper/ObjectPopulation/IObjectMapperFunc.cs b/AgileMapper/ObjectPopulation/IObjectMapperFunc.cs index ddc76a4c7..f9187d0a6 100644 --- a/AgileMapper/ObjectPopulation/IObjectMapperFunc.cs +++ b/AgileMapper/ObjectPopulation/IObjectMapperFunc.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IObjectMapperFunc { diff --git a/AgileMapper/ObjectPopulation/MapperKeys/SourceMemberTypeDependentKeyBase.cs b/AgileMapper/ObjectPopulation/MapperKeys/SourceMemberTypeDependentKeyBase.cs index a3cab72e0..c3dec84d5 100644 --- a/AgileMapper/ObjectPopulation/MapperKeys/SourceMemberTypeDependentKeyBase.cs +++ b/AgileMapper/ObjectPopulation/MapperKeys/SourceMemberTypeDependentKeyBase.cs @@ -2,9 +2,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation.MapperKeys { using System; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal abstract class SourceMemberTypeDependentKeyBase { diff --git a/AgileMapper/ObjectPopulation/MappingCallbackFactory.cs b/AgileMapper/ObjectPopulation/MappingCallbackFactory.cs index 018a13d1d..9449c0fd7 100644 --- a/AgileMapper/ObjectPopulation/MappingCallbackFactory.cs +++ b/AgileMapper/ObjectPopulation/MappingCallbackFactory.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { - using System.Linq.Expressions; using Configuration; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class MappingCallbackFactory : UserConfiguredItemBase { diff --git a/AgileMapper/ObjectPopulation/MappingDataCreationFactory.cs b/AgileMapper/ObjectPopulation/MappingDataCreationFactory.cs index 4a263dba6..59fce1258 100644 --- a/AgileMapper/ObjectPopulation/MappingDataCreationFactory.cs +++ b/AgileMapper/ObjectPopulation/MappingDataCreationFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System.Diagnostics; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class MappingDataCreationFactory { diff --git a/AgileMapper/ObjectPopulation/MappingExpressionFactoryBase.cs b/AgileMapper/ObjectPopulation/MappingExpressionFactoryBase.cs index bd2874a3b..98f57f13c 100644 --- a/AgileMapper/ObjectPopulation/MappingExpressionFactoryBase.cs +++ b/AgileMapper/ObjectPopulation/MappingExpressionFactoryBase.cs @@ -3,14 +3,19 @@ namespace AgileObjects.AgileMapper.ObjectPopulation using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using MapperKeys; using Members; using Members.Sources; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; + using static Microsoft.Scripting.Ast.ExpressionType; +#else + using System.Linq.Expressions; using static System.Linq.Expressions.ExpressionType; +#endif using static CallbackPosition; internal abstract class MappingExpressionFactoryBase diff --git a/AgileMapper/ObjectPopulation/MappingFactory.cs b/AgileMapper/ObjectPopulation/MappingFactory.cs index 592f88456..ce0d49e52 100644 --- a/AgileMapper/ObjectPopulation/MappingFactory.cs +++ b/AgileMapper/ObjectPopulation/MappingFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class MappingFactory { diff --git a/AgileMapper/ObjectPopulation/MappingValues.cs b/AgileMapper/ObjectPopulation/MappingValues.cs index a58e07282..97e957b1a 100644 --- a/AgileMapper/ObjectPopulation/MappingValues.cs +++ b/AgileMapper/ObjectPopulation/MappingValues.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal class MappingValues { diff --git a/AgileMapper/ObjectPopulation/ObjectCreationCallbackFactory.cs b/AgileMapper/ObjectPopulation/ObjectCreationCallbackFactory.cs index 2e5a37eec..4c24fd16d 100644 --- a/AgileMapper/ObjectPopulation/ObjectCreationCallbackFactory.cs +++ b/AgileMapper/ObjectPopulation/ObjectCreationCallbackFactory.cs @@ -1,11 +1,15 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; - using System.Linq.Expressions; using Configuration; using Extensions.Internal; using Members; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ObjectCreationCallbackFactory : MappingCallbackFactory { diff --git a/AgileMapper/ObjectPopulation/ObjectMapper.cs b/AgileMapper/ObjectPopulation/ObjectMapper.cs index e10559b97..705ce938c 100644 --- a/AgileMapper/ObjectPopulation/ObjectMapper.cs +++ b/AgileMapper/ObjectPopulation/ObjectMapper.cs @@ -2,11 +2,15 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Caching; using MapperKeys; using Recursion; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ObjectMapper : IObjectMapper { diff --git a/AgileMapper/ObjectPopulation/ObjectMapperData.cs b/AgileMapper/ObjectPopulation/ObjectMapperData.cs index ead69d5c3..72e7dbb77 100644 --- a/AgileMapper/ObjectPopulation/ObjectMapperData.cs +++ b/AgileMapper/ObjectPopulation/ObjectMapperData.cs @@ -4,7 +4,6 @@ namespace AgileObjects.AgileMapper.ObjectPopulation using System.Collections.Generic; using System.Globalization; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using DataSources; using Enumerables; @@ -13,6 +12,11 @@ namespace AgileObjects.AgileMapper.ObjectPopulation using Members; using Members.Sources; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif using static Members.Member; internal class ObjectMapperData : BasicMapperData, IMemberMapperData diff --git a/AgileMapper/ObjectPopulation/ObjectMapperFactory.cs b/AgileMapper/ObjectPopulation/ObjectMapperFactory.cs index 5c40d281e..f4986fc44 100644 --- a/AgileMapper/ObjectPopulation/ObjectMapperFactory.cs +++ b/AgileMapper/ObjectPopulation/ObjectMapperFactory.cs @@ -2,13 +2,17 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Caching; using ComplexTypes; using Enumerables; using Extensions.Internal; using MapperKeys; using Queryables; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ObjectMapperFactory { diff --git a/AgileMapper/ObjectPopulation/ObjectMappingData.cs b/AgileMapper/ObjectPopulation/ObjectMappingData.cs index bef9e042a..5b7622148 100644 --- a/AgileMapper/ObjectPopulation/ObjectMappingData.cs +++ b/AgileMapper/ObjectPopulation/ObjectMappingData.cs @@ -2,13 +2,17 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System; using System.Collections.Generic; - using System.Linq.Expressions; using Caching; using Extensions.Internal; using MapperKeys; using Members; using NetStandardPolyfills; using Validation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ObjectMappingData : MappingInstanceData, diff --git a/AgileMapper/ObjectPopulation/ObjectMappingDataFactory.cs b/AgileMapper/ObjectPopulation/ObjectMappingDataFactory.cs index 398b53ad0..f8fc1044c 100644 --- a/AgileMapper/ObjectPopulation/ObjectMappingDataFactory.cs +++ b/AgileMapper/ObjectPopulation/ObjectMappingDataFactory.cs @@ -3,13 +3,18 @@ namespace AgileObjects.AgileMapper.ObjectPopulation using System; using System.Dynamic; using System.Linq; - using System.Linq.Expressions; using Enumerables; using Extensions.Internal; using MapperKeys; using Members; using Members.Sources; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; + using Microsoft.Scripting.Utils; +#else + using System.Linq.Expressions; +#endif internal class ObjectMappingDataFactory : IObjectMappingDataFactoryBridge { @@ -392,7 +397,7 @@ private static MappingDataCreator GetMappingDataCreator : IRecursionMapperFunc { diff --git a/AgileMapper/ObjectPopulation/SimpleTypeMappingExpressionFactory.cs b/AgileMapper/ObjectPopulation/SimpleTypeMappingExpressionFactory.cs index 03d7816a3..c8e5719ca 100644 --- a/AgileMapper/ObjectPopulation/SimpleTypeMappingExpressionFactory.cs +++ b/AgileMapper/ObjectPopulation/SimpleTypeMappingExpressionFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using Members; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SimpleTypeMappingExpressionFactory : MappingExpressionFactoryBase { diff --git a/AgileMapper/ObjectPopulation/SourceAccessCounter.cs b/AgileMapper/ObjectPopulation/SourceAccessCounter.cs index f0ffb3e0c..defb25ad9 100644 --- a/AgileMapper/ObjectPopulation/SourceAccessCounter.cs +++ b/AgileMapper/ObjectPopulation/SourceAccessCounter.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.ObjectPopulation { - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class SourceAccessCounter : QuickUnwindExpressionVisitor { diff --git a/AgileMapper/Parameters.cs b/AgileMapper/Parameters.cs index 714acfa0a..6f0a60deb 100644 --- a/AgileMapper/Parameters.cs +++ b/AgileMapper/Parameters.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper { using System; - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class Parameters { diff --git a/AgileMapper/Plans/MappingPlan.cs b/AgileMapper/Plans/MappingPlan.cs index 1795d15f0..b21406935 100644 --- a/AgileMapper/Plans/MappingPlan.cs +++ b/AgileMapper/Plans/MappingPlan.cs @@ -38,9 +38,10 @@ internal static MappingPlan For(IObjectMappingData mappingData) /// The string representation of the given . public static implicit operator string(MappingPlan mappingPlan) { - return string.Join( - Environment.NewLine + Environment.NewLine, - mappingPlan._mappingPlanFunctions.Project(pd => pd.GetDescription())); + return mappingPlan + ._mappingPlanFunctions + .Project(pd => pd.GetDescription()) + .Join(Environment.NewLine + Environment.NewLine); } /// diff --git a/AgileMapper/Plans/MappingPlanSet.cs b/AgileMapper/Plans/MappingPlanSet.cs index 40ec7071e..a21e097df 100644 --- a/AgileMapper/Plans/MappingPlanSet.cs +++ b/AgileMapper/Plans/MappingPlanSet.cs @@ -37,9 +37,10 @@ internal static MappingPlanSet For(MapperContext mapperContext) /// public static implicit operator string(MappingPlanSet mappingPlans) { - return string.Join( - Environment.NewLine + Environment.NewLine, - mappingPlans._mappingPlans.Project(plan => plan.ToString())); + return mappingPlans + ._mappingPlans + .Project(plan => plan.ToString()) + .Join(Environment.NewLine + Environment.NewLine); } /// diff --git a/AgileMapper/Plans/RecursionMapperMappingPlanFunction.cs b/AgileMapper/Plans/RecursionMapperMappingPlanFunction.cs index 0976e5f82..983f6e13f 100644 --- a/AgileMapper/Plans/RecursionMapperMappingPlanFunction.cs +++ b/AgileMapper/Plans/RecursionMapperMappingPlanFunction.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.Plans { using System; - using System.Linq.Expressions; using ObjectPopulation.Recursion; using ReadableExpressions; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class RecursionMapperMappingPlanFunction : IMappingPlanFunction { diff --git a/AgileMapper/Plans/RootMapperMappingPlanFunction.cs b/AgileMapper/Plans/RootMapperMappingPlanFunction.cs index 9558de777..6503789ec 100644 --- a/AgileMapper/Plans/RootMapperMappingPlanFunction.cs +++ b/AgileMapper/Plans/RootMapperMappingPlanFunction.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.Plans { - using System.Linq.Expressions; using ObjectPopulation; using ReadableExpressions; using ReadableExpressions.Extensions; using Validation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class RootMapperMappingPlanFunction : IMappingPlanFunction { diff --git a/AgileMapper/Properties/AssemblyInfo.cs b/AgileMapper/Properties/AssemblyInfo.cs index 86f45d629..dced5b504 100644 --- a/AgileMapper/Properties/AssemblyInfo.cs +++ b/AgileMapper/Properties/AssemblyInfo.cs @@ -4,11 +4,12 @@ using System.Security; [assembly: AssemblyTitle("AgileObjects.AgileMapper")] -[assembly: AssemblyDescription("A zero-configuration, highly-configurable object-object mapper with viewable execution plans. Performs deep clones, updates and merges via extension methods, or a static or instance API. Targets .NET Standard 1.0 and .NET 4.0.")] +[assembly: AssemblyDescription("A zero-configuration, highly-configurable object-object mapper with viewable execution plans. Performs deep clones, updates and merges via extension methods, or a static or instance API. Targets .NET Standard 1.0+ and .NET 3.5+")] [assembly: AllowPartiallyTrustedCallers] [assembly: CLSCompliant(true)] [assembly: InternalsVisibleTo("AgileObjects.AgileMapper.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100570b21a39fbc3df774a5e60b41cd41078ebae1c9210a3ae4355d518a0abecab27f9346fbfe941618dc835e99ab21b75ff38e5815dceebdd8480dc14c0ee14f5cdcd3ace7f980173238c9d827f95a6f46100ff19a7dcf912c9291bf95dcd64694692a193428f2a35023bbed186f3c8f9769e01e5077a8ea5cabafe5d7948024af")] +[assembly: InternalsVisibleTo("AgileObjects.AgileMapper.UnitTests.Net35, PublicKey=0024000004800000940000000602000000240000525341310004000001000100570b21a39fbc3df774a5e60b41cd41078ebae1c9210a3ae4355d518a0abecab27f9346fbfe941618dc835e99ab21b75ff38e5815dceebdd8480dc14c0ee14f5cdcd3ace7f980173238c9d827f95a6f46100ff19a7dcf912c9291bf95dcd64694692a193428f2a35023bbed186f3c8f9769e01e5077a8ea5cabafe5d7948024af")] [assembly: InternalsVisibleTo("AgileObjects.AgileMapper.UnitTests.NetCore, PublicKey=0024000004800000940000000602000000240000525341310004000001000100570b21a39fbc3df774a5e60b41cd41078ebae1c9210a3ae4355d518a0abecab27f9346fbfe941618dc835e99ab21b75ff38e5815dceebdd8480dc14c0ee14f5cdcd3ace7f980173238c9d827f95a6f46100ff19a7dcf912c9291bf95dcd64694692a193428f2a35023bbed186f3c8f9769e01e5077a8ea5cabafe5d7948024af")] [assembly: InternalsVisibleTo("AgileObjects.AgileMapper.UnitTests.NetCore2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100570b21a39fbc3df774a5e60b41cd41078ebae1c9210a3ae4355d518a0abecab27f9346fbfe941618dc835e99ab21b75ff38e5815dceebdd8480dc14c0ee14f5cdcd3ace7f980173238c9d827f95a6f46100ff19a7dcf912c9291bf95dcd64694692a193428f2a35023bbed186f3c8f9769e01e5077a8ea5cabafe5d7948024af")] [assembly: InternalsVisibleTo("AgileObjects.AgileMapper.UnitTests.NetCore2_1, PublicKey=0024000004800000940000000602000000240000525341310004000001000100570b21a39fbc3df774a5e60b41cd41078ebae1c9210a3ae4355d518a0abecab27f9346fbfe941618dc835e99ab21b75ff38e5815dceebdd8480dc14c0ee14f5cdcd3ace7f980173238c9d827f95a6f46100ff19a7dcf912c9291bf95dcd64694692a193428f2a35023bbed186f3c8f9769e01e5077a8ea5cabafe5d7948024af")] diff --git a/AgileMapper/Queryables/Converters/ComplexTypeConditionalConverter.cs b/AgileMapper/Queryables/Converters/ComplexTypeConditionalConverter.cs index 92ab026fc..6f811af1c 100644 --- a/AgileMapper/Queryables/Converters/ComplexTypeConditionalConverter.cs +++ b/AgileMapper/Queryables/Converters/ComplexTypeConditionalConverter.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { - using System.Linq.Expressions; using Extensions.Internal; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class ComplexTypeConditionalConverter { diff --git a/AgileMapper/Queryables/Converters/ComplexTypeToNullComparisonConverter.cs b/AgileMapper/Queryables/Converters/ComplexTypeToNullComparisonConverter.cs index 365995a75..6b900ba01 100644 --- a/AgileMapper/Queryables/Converters/ComplexTypeToNullComparisonConverter.cs +++ b/AgileMapper/Queryables/Converters/ComplexTypeToNullComparisonConverter.cs @@ -2,10 +2,14 @@ { using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using Members; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class ComplexTypeToNullComparisonConverter { diff --git a/AgileMapper/Queryables/Converters/DefaultValueConstantExpressionFactory.cs b/AgileMapper/Queryables/Converters/DefaultValueConstantExpressionFactory.cs index 0829df5c5..c648532c0 100644 --- a/AgileMapper/Queryables/Converters/DefaultValueConstantExpressionFactory.cs +++ b/AgileMapper/Queryables/Converters/DefaultValueConstantExpressionFactory.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { using System; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class DefaultValueConstantExpressionFactory { diff --git a/AgileMapper/Queryables/Converters/DerivedTypeMappingConverter.cs b/AgileMapper/Queryables/Converters/DerivedTypeMappingConverter.cs index 69cc879ec..72526cafa 100644 --- a/AgileMapper/Queryables/Converters/DerivedTypeMappingConverter.cs +++ b/AgileMapper/Queryables/Converters/DerivedTypeMappingConverter.cs @@ -2,9 +2,14 @@ { using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; + using static Microsoft.Scripting.Ast.ExpressionType; +#else + using System.Linq.Expressions; using static System.Linq.Expressions.ExpressionType; +#endif internal static class DerivedTypeMappingConverter { diff --git a/AgileMapper/Queryables/Converters/GetValueOrDefaultConverter.cs b/AgileMapper/Queryables/Converters/GetValueOrDefaultConverter.cs index 15f9f9ad3..415f58f43 100644 --- a/AgileMapper/Queryables/Converters/GetValueOrDefaultConverter.cs +++ b/AgileMapper/Queryables/Converters/GetValueOrDefaultConverter.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { using System; - using System.Linq.Expressions; using Extensions.Internal; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class GetValueOrDefaultConverter { diff --git a/AgileMapper/Queryables/Converters/IQueryProjectionModifier.cs b/AgileMapper/Queryables/Converters/IQueryProjectionModifier.cs index af95a4561..ce476a08b 100644 --- a/AgileMapper/Queryables/Converters/IQueryProjectionModifier.cs +++ b/AgileMapper/Queryables/Converters/IQueryProjectionModifier.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { - using System.Linq.Expressions; using Members; using Settings; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal interface IQueryProjectionModifier { diff --git a/AgileMapper/Queryables/Converters/NestedProjectionAssignmentConverter.cs b/AgileMapper/Queryables/Converters/NestedProjectionAssignmentConverter.cs index bbd3d0809..bf08af2f5 100644 --- a/AgileMapper/Queryables/Converters/NestedProjectionAssignmentConverter.cs +++ b/AgileMapper/Queryables/Converters/NestedProjectionAssignmentConverter.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class NestedProjectionAssignmentConverter { diff --git a/AgileMapper/Queryables/Converters/NullableConversionConverter.cs b/AgileMapper/Queryables/Converters/NullableConversionConverter.cs index 47036f820..0622ad52d 100644 --- a/AgileMapper/Queryables/Converters/NullableConversionConverter.cs +++ b/AgileMapper/Queryables/Converters/NullableConversionConverter.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { - using System.Linq.Expressions; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class NullableConversionConverter { diff --git a/AgileMapper/Queryables/Converters/StringConcatConverter.cs b/AgileMapper/Queryables/Converters/StringConcatConverter.cs index 31c4bee34..f3938390b 100644 --- a/AgileMapper/Queryables/Converters/StringConcatConverter.cs +++ b/AgileMapper/Queryables/Converters/StringConcatConverter.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using Members; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class StringConcatConverter { diff --git a/AgileMapper/Queryables/Converters/StringEqualsIgnoreCaseConverter.cs b/AgileMapper/Queryables/Converters/StringEqualsIgnoreCaseConverter.cs index fb70af77d..32d11709a 100644 --- a/AgileMapper/Queryables/Converters/StringEqualsIgnoreCaseConverter.cs +++ b/AgileMapper/Queryables/Converters/StringEqualsIgnoreCaseConverter.cs @@ -1,6 +1,10 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal static class StringEqualsIgnoreCaseConverter { diff --git a/AgileMapper/Queryables/Converters/StringToEnumConversionConverter.cs b/AgileMapper/Queryables/Converters/StringToEnumConversionConverter.cs index c57ffa224..00f82358f 100644 --- a/AgileMapper/Queryables/Converters/StringToEnumConversionConverter.cs +++ b/AgileMapper/Queryables/Converters/StringToEnumConversionConverter.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { - using System.Linq.Expressions; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class StringToEnumConversionConverter { @@ -32,7 +36,7 @@ private static bool IsNotStringToEnumConversion(ConditionalExpression conditiona return !testMethodCall.Method.IsStatic || (testMethodCall.Method.DeclaringType != typeof(string)) || - testMethodCall.Method.Name != nameof(string.IsNullOrWhiteSpace); + (testMethodCall.Method.Name != "IsNullOrWhiteSpace"); } } } \ No newline at end of file diff --git a/AgileMapper/Queryables/Converters/ToStringConverter.cs b/AgileMapper/Queryables/Converters/ToStringConverter.cs index 75bb86fa1..b3d50f34e 100644 --- a/AgileMapper/Queryables/Converters/ToStringConverter.cs +++ b/AgileMapper/Queryables/Converters/ToStringConverter.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { using System; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class ToStringConverter { diff --git a/AgileMapper/Queryables/Converters/TryParseAssignmentConverter.cs b/AgileMapper/Queryables/Converters/TryParseAssignmentConverter.cs index 1fa630608..abd92dad1 100644 --- a/AgileMapper/Queryables/Converters/TryParseAssignmentConverter.cs +++ b/AgileMapper/Queryables/Converters/TryParseAssignmentConverter.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Queryables.Converters { - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class TryParseAssignmentConverter { diff --git a/AgileMapper/Queryables/QueryProjectionExpressionFactory.cs b/AgileMapper/Queryables/QueryProjectionExpressionFactory.cs index 6174b4a1f..968e208cd 100644 --- a/AgileMapper/Queryables/QueryProjectionExpressionFactory.cs +++ b/AgileMapper/Queryables/QueryProjectionExpressionFactory.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.Queryables { using System.Collections.Generic; - using System.Linq.Expressions; using Extensions.Internal; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class QueryProjectionExpressionFactory : MappingExpressionFactoryBase { diff --git a/AgileMapper/Queryables/QueryProjectionModifier.cs b/AgileMapper/Queryables/QueryProjectionModifier.cs index 67445a3f7..f98ae986e 100644 --- a/AgileMapper/Queryables/QueryProjectionModifier.cs +++ b/AgileMapper/Queryables/QueryProjectionModifier.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.Queryables { - using System.Linq.Expressions; using Converters; using Members; using ObjectPopulation; using Settings; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class QueryProjectionModifier : ExpressionVisitor, IQueryProjectionModifier { diff --git a/AgileMapper/Queryables/Recursion/MapToDepthRecursiveMemberMappingStrategy.cs b/AgileMapper/Queryables/Recursion/MapToDepthRecursiveMemberMappingStrategy.cs index 3317c3ff3..255a73e63 100644 --- a/AgileMapper/Queryables/Recursion/MapToDepthRecursiveMemberMappingStrategy.cs +++ b/AgileMapper/Queryables/Recursion/MapToDepthRecursiveMemberMappingStrategy.cs @@ -1,9 +1,13 @@ namespace AgileObjects.AgileMapper.Queryables.Recursion { - using System.Linq.Expressions; using Members; using ObjectPopulation; using ObjectPopulation.Recursion; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal struct MapToDepthRecursiveMemberMappingStrategy : IRecursiveMemberMappingStrategy { diff --git a/AgileMapper/Queryables/Settings/DefaultQueryProviderSettings.cs b/AgileMapper/Queryables/Settings/DefaultQueryProviderSettings.cs index de0b9043e..22fe0d7ab 100644 --- a/AgileMapper/Queryables/Settings/DefaultQueryProviderSettings.cs +++ b/AgileMapper/Queryables/Settings/DefaultQueryProviderSettings.cs @@ -2,11 +2,15 @@ { using System; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using Converters; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class DefaultQueryProviderSettings : IQueryProviderSettings { diff --git a/AgileMapper/Queryables/Settings/EntityFramework/Ef5QueryProviderSettings.cs b/AgileMapper/Queryables/Settings/EntityFramework/Ef5QueryProviderSettings.cs index 5291b44fa..59a7c92b5 100644 --- a/AgileMapper/Queryables/Settings/EntityFramework/Ef5QueryProviderSettings.cs +++ b/AgileMapper/Queryables/Settings/EntityFramework/Ef5QueryProviderSettings.cs @@ -2,10 +2,14 @@ { using System; using System.Globalization; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class Ef5QueryProviderSettings : LegacyEfQueryProviderSettings { diff --git a/AgileMapper/Queryables/Settings/EntityFramework/LegacyEfQueryProviderSettings.cs b/AgileMapper/Queryables/Settings/EntityFramework/LegacyEfQueryProviderSettings.cs index 20a1291d0..cf46c5f08 100644 --- a/AgileMapper/Queryables/Settings/EntityFramework/LegacyEfQueryProviderSettings.cs +++ b/AgileMapper/Queryables/Settings/EntityFramework/LegacyEfQueryProviderSettings.cs @@ -3,11 +3,15 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using NetStandardPolyfills; using TypeConversion; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal abstract class LegacyEfQueryProviderSettings : DefaultQueryProviderSettings { diff --git a/AgileMapper/Queryables/Settings/IQueryProviderSettings.cs b/AgileMapper/Queryables/Settings/IQueryProviderSettings.cs index 8b9f7f1e6..83877a00e 100644 --- a/AgileMapper/Queryables/Settings/IQueryProviderSettings.cs +++ b/AgileMapper/Queryables/Settings/IQueryProviderSettings.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.Queryables.Settings { using System; +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif internal interface IQueryProviderSettings { diff --git a/AgileMapper/TypeConversion/ConverterSet.cs b/AgileMapper/TypeConversion/ConverterSet.cs index fbbe95c99..e51acff80 100644 --- a/AgileMapper/TypeConversion/ConverterSet.cs +++ b/AgileMapper/TypeConversion/ConverterSet.cs @@ -3,11 +3,15 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Configuration; using Extensions.Internal; using NetStandardPolyfills; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ConverterSet { @@ -22,7 +26,11 @@ public ConverterSet(UserConfigurationSet userConfigurations) default(ToBoolConverter), new ToEnumConverter(userConfigurations), TryParseConverter.Instance, +#if NET35 + ToGuidConverter.Instance, +#else TryParseConverter.Instance, +#endif ToNumericConverter.Instance, ToNumericConverter.Instance, ToNumericConverter.Instance, diff --git a/AgileMapper/TypeConversion/FallbackNonSimpleTypeValueConverter.cs b/AgileMapper/TypeConversion/FallbackNonSimpleTypeValueConverter.cs index 3c6394cb8..a2cdd4f47 100644 --- a/AgileMapper/TypeConversion/FallbackNonSimpleTypeValueConverter.cs +++ b/AgileMapper/TypeConversion/FallbackNonSimpleTypeValueConverter.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.TypeConversion { using System; - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal struct FallbackNonSimpleTypeValueConverter : IValueConverter { diff --git a/AgileMapper/TypeConversion/IValueConverter.cs b/AgileMapper/TypeConversion/IValueConverter.cs index 1e9a8ba0e..c8d79d45a 100644 --- a/AgileMapper/TypeConversion/IValueConverter.cs +++ b/AgileMapper/TypeConversion/IValueConverter.cs @@ -1,7 +1,11 @@ namespace AgileObjects.AgileMapper.TypeConversion { using System; +#if NET35 + using Microsoft.Scripting.Ast; +#else using System.Linq.Expressions; +#endif /// /// Implementing classes will convert a value type or string to another value type. diff --git a/AgileMapper/TypeConversion/NumericConversions.cs b/AgileMapper/TypeConversion/NumericConversions.cs index 3024674ca..f1f15a584 100644 --- a/AgileMapper/TypeConversion/NumericConversions.cs +++ b/AgileMapper/TypeConversion/NumericConversions.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.TypeConversion { using System; - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class NumericConversions { diff --git a/AgileMapper/TypeConversion/NumericValueIsInRangeComparison.cs b/AgileMapper/TypeConversion/NumericValueIsInRangeComparison.cs index f69a52b70..a9dbda441 100644 --- a/AgileMapper/TypeConversion/NumericValueIsInRangeComparison.cs +++ b/AgileMapper/TypeConversion/NumericValueIsInRangeComparison.cs @@ -1,8 +1,12 @@ namespace AgileObjects.AgileMapper.TypeConversion { using System; - using System.Linq.Expressions; using Extensions.Internal; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal static class NumericValueIsInRangeComparison { diff --git a/AgileMapper/TypeConversion/ToBoolConverter.cs b/AgileMapper/TypeConversion/ToBoolConverter.cs index cd635cd77..406fa4a83 100644 --- a/AgileMapper/TypeConversion/ToBoolConverter.cs +++ b/AgileMapper/TypeConversion/ToBoolConverter.cs @@ -4,9 +4,13 @@ namespace AgileObjects.AgileMapper.TypeConversion using System.Collections.Generic; using System.Globalization; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal struct ToBoolConverter : IValueConverter { diff --git a/AgileMapper/TypeConversion/ToCharacterConverter.cs b/AgileMapper/TypeConversion/ToCharacterConverter.cs index 915398cab..f476235a1 100644 --- a/AgileMapper/TypeConversion/ToCharacterConverter.cs +++ b/AgileMapper/TypeConversion/ToCharacterConverter.cs @@ -2,9 +2,13 @@ { using System; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal struct ToCharacterConverter : IValueConverter { diff --git a/AgileMapper/TypeConversion/ToEnumConverter.cs b/AgileMapper/TypeConversion/ToEnumConverter.cs index 3ec3bfd99..acc74299d 100644 --- a/AgileMapper/TypeConversion/ToEnumConverter.cs +++ b/AgileMapper/TypeConversion/ToEnumConverter.cs @@ -4,10 +4,14 @@ using System.Collections; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using Configuration; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ToEnumConverter : IValueConverter { @@ -490,7 +494,12 @@ private static Expression GetStringValueConversion( nameMatchingConversion); var valueIsNullOrEmpty = Expression.Call( - typeof(string).GetPublicStaticMethod("IsNullOrWhiteSpace"), +#if NET35 + typeof(StringExtensions) +#else + typeof(string) +#endif + .GetPublicStaticMethod("IsNullOrWhiteSpace"), sourceValue); var convertedValueOrDefault = Expression.Condition( diff --git a/AgileMapper/TypeConversion/ToFormattedStringConverter.cs b/AgileMapper/TypeConversion/ToFormattedStringConverter.cs index bb5559fcf..ca817cbf6 100644 --- a/AgileMapper/TypeConversion/ToFormattedStringConverter.cs +++ b/AgileMapper/TypeConversion/ToFormattedStringConverter.cs @@ -1,11 +1,15 @@ namespace AgileObjects.AgileMapper.TypeConversion { using System; - using System.Linq.Expressions; using System.Reflection; using Configuration; using Extensions.Internal; using ReadableExpressions.Extensions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ToFormattedStringConverter : IValueConverter { diff --git a/AgileMapper/TypeConversion/ToGuidConverter.cs b/AgileMapper/TypeConversion/ToGuidConverter.cs new file mode 100644 index 000000000..348ec6aaa --- /dev/null +++ b/AgileMapper/TypeConversion/ToGuidConverter.cs @@ -0,0 +1,47 @@ +#if NET35 +namespace AgileObjects.AgileMapper.TypeConversion +{ + using System; + using System.Reflection; + using Extensions.Internal; + using Microsoft.Scripting.Ast; + using NetStandardPolyfills; + + internal class ToGuidConverter : IValueConverter + { + public static readonly IValueConverter Instance = new ToGuidConverter(); + + private static readonly MethodInfo _parseGuidMethod = typeof(StringExtensions).GetPublicStaticMethod("ToGuid"); + private static readonly MethodInfo _parseGuidNullableMethod = typeof(StringExtensions).GetPublicStaticMethod("ToGuidNullable"); + + public bool CanConvert(Type nonNullableSourceType, Type nonNullableTargetType) + { + return + (nonNullableTargetType == typeof(Guid)) && + ((nonNullableSourceType == typeof(Guid)) || + ToStringConverter.HasNativeStringRepresentation(nonNullableSourceType)); + } + + public Expression GetConversion(Expression sourceValue, Type targetType) + { + if (sourceValue.Type == typeof(Guid?)) + { + return sourceValue.GetValueOrDefaultCall(); + } + + if (sourceValue.Type != typeof(string)) + { + sourceValue = ToStringConverter.GetConversion(sourceValue); + } + + var parseMethod = targetType == typeof(Guid) + ? _parseGuidMethod + : _parseGuidNullableMethod; + + var parseCall = Expression.Call(parseMethod, sourceValue); + + return parseCall; + } + } +} +#endif \ No newline at end of file diff --git a/AgileMapper/TypeConversion/ToNumericConverter.cs b/AgileMapper/TypeConversion/ToNumericConverter.cs index 3374b34a8..e8e46962f 100644 --- a/AgileMapper/TypeConversion/ToNumericConverter.cs +++ b/AgileMapper/TypeConversion/ToNumericConverter.cs @@ -2,9 +2,13 @@ { using System; using System.Linq; - using System.Linq.Expressions; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class ToNumericConverter : TryParseConverter { diff --git a/AgileMapper/TypeConversion/ToStringConverter.cs b/AgileMapper/TypeConversion/ToStringConverter.cs index 930a17c0b..c9a9a67d1 100644 --- a/AgileMapper/TypeConversion/ToStringConverter.cs +++ b/AgileMapper/TypeConversion/ToStringConverter.cs @@ -3,10 +3,14 @@ using System; using System.Globalization; using System.Linq; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal struct ToStringConverter : IValueConverter { diff --git a/AgileMapper/TypeConversion/TryParseConverter.cs b/AgileMapper/TypeConversion/TryParseConverter.cs index 56ac4e6d7..d1895e5d6 100644 --- a/AgileMapper/TypeConversion/TryParseConverter.cs +++ b/AgileMapper/TypeConversion/TryParseConverter.cs @@ -1,10 +1,14 @@ namespace AgileObjects.AgileMapper.TypeConversion { using System; - using System.Linq.Expressions; using System.Reflection; using Extensions.Internal; using NetStandardPolyfills; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class TryParseConverter : IValueConverter { diff --git a/AgileMapper/Validation/EnumMappingMismatchFinder.cs b/AgileMapper/Validation/EnumMappingMismatchFinder.cs index 4614f0658..1e5932d4a 100644 --- a/AgileMapper/Validation/EnumMappingMismatchFinder.cs +++ b/AgileMapper/Validation/EnumMappingMismatchFinder.cs @@ -3,12 +3,16 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members; using NetStandardPolyfills; using ObjectPopulation; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumMappingMismatchFinder : ExpressionVisitor { diff --git a/AgileMapper/Validation/EnumMappingMismatchSet.cs b/AgileMapper/Validation/EnumMappingMismatchSet.cs index ceffa3e84..9abecf359 100644 --- a/AgileMapper/Validation/EnumMappingMismatchSet.cs +++ b/AgileMapper/Validation/EnumMappingMismatchSet.cs @@ -3,11 +3,15 @@ using System; using System.Collections.Generic; using System.Linq; - using System.Linq.Expressions; using DataSources; using Extensions.Internal; using Members; using ReadableExpressions; +#if NET35 + using Microsoft.Scripting.Ast; +#else + using System.Linq.Expressions; +#endif internal class EnumMappingMismatchSet { @@ -73,9 +77,9 @@ public static EnumMappingMismatchSet For( private Expression CreateWarnings() { - var warningsText = string.Join( - Environment.NewLine + Environment.NewLine, - _mappingMismatches.Project(mm => mm.Warning)); + var warningsText = _mappingMismatches + .Project(mm => mm.Warning) + .Join(Environment.NewLine + Environment.NewLine); return (warningsText != string.Empty) ? ReadableExpression.Comment(warningsText) @@ -216,7 +220,7 @@ private static void FilterOutConfiguredPairs( public string TargetMemberPath { get; } public string SourceMemberPaths => - string.Join(" / ", _sourceMembers.Project(sm => sm.GetFriendlySourcePath(_rootMapperData))); + _sourceMembers.Project(sm => sm.GetFriendlySourcePath(_rootMapperData)).Join(" / "); public string Warning => _warning ?? (_warning = CreateWarning());