diff --git a/.appveyor.yml b/.appveyor.yml
new file mode 100644
index 0000000..c740c0d
--- /dev/null
+++ b/.appveyor.yml
@@ -0,0 +1,45 @@
+image: Visual Studio 2017
+
+configuration: Debug
+
+build: off
+
+build_script:
+ - cmd: set PATH=%PATH%;C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\
+ - cmd: fsi --exec ./build.fsx
+
+test: off
+
+artifacts:
+ - path: '**\bin\*\*.nupkg'
+
+skip_branch_with_pr: true
+
+deploy:
+ - provider: NuGet
+ server: https://www.myget.org/F/dynamitey-ci/api/v2/package
+ api_key:
+ secure: yKbBrG0QiTfXUvND1/cMMNHxH1Bgal5g7c0pWGwqvjCtKGTtWkpvE2KlZb6E2ZgB
+ skip_symbols: false
+ symbol_server: https://www.myget.org/F/dynamitey-ci/symbols/api/v2/package
+
+for:
+ - branches:
+ except:
+ - /v.*/
+ environment:
+ vsuffix: alpha$(APPVEYOR_BUILD_NUMBER)
+ is_prerelease: true
+ - branches:
+ only:
+ - /v.*-beta/
+ environment:
+ vsuffix: beta$(APPVEYOR_BUILD_NUMBER)
+ is_prerelease: true
+ - branches:
+ only:
+ - /v[\d,.]*/
+ configuration: Release
+ environment:
+ vsuffix: $(APPVEYOR_BUILD_NUMBER)
+ is_prerelease: false
\ No newline at end of file
diff --git a/.ci/codebetterci.proj b/.ci/codebetterci.proj
deleted file mode 100644
index 8e26ada..0000000
--- a/.ci/codebetterci.proj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- Dynamitey
-
-
-
- Configuration=Release;UseOldPcl=true;
-
-
- Configuration=Release;OutputPath=bin\Release.net40\;IntermediateOutputPath=obj\Release.net40\;UseNet40=true;
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.ci/nunit.sh b/.ci/nunit.sh
deleted file mode 100755
index 44e428c..0000000
--- a/.ci/nunit.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh -x
-
-mono --runtime=v4.0 .nuget/NuGet.exe install NUnit.Runners -Version 2.6.1 -o packages
-
-runTest(){
- mono --runtime=v4.0 packages/NUnit.Runners.2.6.1/tools/nunit-console.exe -noxml -nodots -labels -stoponerror $@
- if [ $? -ne 0 ]
- then
- exit 1
- fi
-}
-
-runTest $1 -exclude=Performance
-
-exit $?
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 5805f4c..761345c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,150 +1,158 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-f
-# User-specific files
-*.suo
-*.user
-*.sln.docstates
-
-# Build results
-
-[Dd]ebug/
-[Rr]elease/
-x64/
-build/
-[Bb]in/
-[Oo]bj/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-*_i.c
-*_p.c
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.log
-*.scc
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opensdf
-*.sdf
-*.cachefile
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-*.ncrunch*
-.*crunch*.local.xml
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.Publish.xml
-*.pubxml
-
-# NuGet Packages Directory
-## TODO: If you have NuGet Package Restore enabled, uncomment the next line
-packages/
-
-# Windows Azure Build Output
-csx
-*.build.csdef
-
-# Windows Store app package directory
-AppPackages/
-
-# Others
-sql/
-*.Cache
-ClientBin/
-[Ss]tyle[Cc]op.*
-~$*
-*~
-*.dbmdl
-*.[Pp]ublish.xml
-*.pfx
-*.publishsettings
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file to a newer
-# Visual Studio version. Backup files are not needed, because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-App_Data/*.mdf
-App_Data/*.ldf
-
-# =========================
-# Windows detritus
-# =========================
-
-# Windows image file caches
-Thumbs.db
-ehthumbs.db
-
-# Folder config file
-Desktop.ini
-
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-
-# Mac crap
-.DS_Store
-
-/dist/*.nupkg
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+f
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+
+[Dd]ebug/
+[Rr]elease/
+x64/
+build/
+[Bb]in/
+[Oo]bj/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.log
+*.scc
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+*.ncrunch*
+.*crunch*.local.xml
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.Publish.xml
+*.pubxml
+
+# NuGet Packages Directory
+## TODO: If you have NuGet Package Restore enabled, uncomment the next line
+packages/
+
+# Windows Azure Build Output
+csx
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+sql/
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.[Pp]ublish.xml
+*.pfx
+*.publishsettings
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+App_Data/*.mdf
+App_Data/*.ldf
+
+# =========================
+# Windows detritus
+# =========================
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Mac crap
+.DS_Store
+
+/dist/*.nupkg
+
+*.userprefs
+
+.fake/*
+.nuget/NuGet.exe
+
+.idea/*
+.vs/*
diff --git a/.nuget/Microsoft.Build.dll b/.nuget/Microsoft.Build.dll
deleted file mode 100644
index 43728a4..0000000
Binary files a/.nuget/Microsoft.Build.dll and /dev/null differ
diff --git a/.nuget/Microsoft.Build.readme b/.nuget/Microsoft.Build.readme
deleted file mode 100644
index 6bd0a5b..0000000
--- a/.nuget/Microsoft.Build.readme
+++ /dev/null
@@ -1 +0,0 @@
-This Microsoft.Build.dll comes v3.X of the Mono Project. Mit licensed Copyright (C) 2012 Xamarin Inc.
diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config
deleted file mode 100644
index 67f8ea0..0000000
--- a/.nuget/NuGet.Config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe
deleted file mode 100644
index cb3ed03..0000000
Binary files a/.nuget/NuGet.exe and /dev/null differ
diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets
deleted file mode 100644
index 90dee61..0000000
--- a/.nuget/NuGet.targets
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
- $(MSBuildProjectDirectory)\..\
-
-
- false
-
-
- false
-
-
- true
-
-
- false
-
-
-
-
-
-
-
-
-
-
- $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
- $([System.IO.Path]::Combine($(ProjectDir), "packages.config"))
-
-
-
-
- $(SolutionDir).nuget
- packages.config
-
-
-
-
- $(NuGetToolsPath)\NuGet.exe
- @(PackageSource)
-
- "$(NuGetExePath)"
- mono --runtime=v4.0.30319 $(NuGetExePath)
-
- $(TargetDir.Trim('\\'))
-
- -RequireConsent
- -NonInteractive
-
-
- $(SolutionDir)
- $(SolutionDir)
- $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDirParsed)"
- $(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
-
-
-
- RestorePackages;
- $(BuildDependsOn);
-
-
-
-
- $(BuildDependsOn);
- BuildPackage;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 4d70afb..6e2d71c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,17 +1,26 @@
# Travis-CI Build for dynamitey
# see travis-ci.org for details
-language: objective-c
+language: csharp
+matrix:
+ include:
+ - os: linux
+ dist: trusty
+ sudo: required
+ - os: osx
+ osx_image: "xcode8.3"
+
+solution: Dynamitey.sln
+
+mono: latest
+dotnet: 2.0.0
+
+install:
+ - msbuild /ver
-env:
- global:
- - EnableNuGetPackageRestore=true
- matrix:
- - MONO_VER="3.2.4"
-before_install:
- # Make sure mono is installed,
- - wget "http://download.mono-project.com/archive/${MONO_VER}/macos-10-x86/MonoFramework-MDK-${MONO_VER}.macos10.xamarin.x86.pkg"
- - sudo installer -pkg "MonoFramework-MDK-${MONO_VER}.macos10.xamarin.x86.pkg" -target /
script:
- - xbuild
- - .ci/nunit.sh Tests/bin/Debug/Tests.dll
+ - ./build.fsx
+
+branches:
+ only:
+ - master
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..c71ce74
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,14 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "0.1.0",
+ "command": "./build.fsx",
+ "args": ["Test"],
+ "windows":{
+ "command": "C:\\Program Files (x86)\\Microsoft SDKs\\F#\\4.1\\Framework\\v4.0\\fsi",
+ "args": ["--exec", "./build.fsx", "Test"]
+ },
+ "isShellCommand": true,
+ "showOutput": "always",
+ "problemMatcher":"$msCompile"
+}
\ No newline at end of file
diff --git a/Dynamitey.sln b/Dynamitey.sln
index b5425b2..d54a794 100644
--- a/Dynamitey.sln
+++ b/Dynamitey.sln
@@ -1,20 +1,15 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dynamitey", "Dynamitey\Dynamitey.csproj", "{CE699AB8-4122-4369-BAA6-76244A0734E4}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CB47488D-6ECE-4697-90C2-3BDA8488F00C}"
- ProjectSection(SolutionItems) = preProject
- .nuget\NuGet.Config = .nuget\NuGet.Config
- .nuget\NuGet.exe = .nuget\NuGet.exe
- .nuget\NuGet.targets = .nuget\NuGet.targets
- EndProjectSection
-EndProject
+# Visual Studio 15
+VisualStudioVersion = 15.0.26228.9
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{691EBA79-CAA4-4670-BC8B-4537F990ADBF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{C33F07DB-7ACB-4081-92C2-BB739CB605C0}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SupportLibrary1", "SupportLibrary1\SupportLibrary1.csproj", "{348152A9-6A9C-4115-B60A-9E08CA72451D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SupportLibrary", "SupportLibrary\SupportLibrary.csproj", "{18E19833-D47E-4A7F-AE64-31E28FEF8728}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dynamitey", "Dynamitey\Dynamitey.csproj", "{8902AFBA-4ACA-4880-B606-ADEC6BB21A1B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -22,24 +17,24 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CE699AB8-4122-4369-BAA6-76244A0734E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CE699AB8-4122-4369-BAA6-76244A0734E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CE699AB8-4122-4369-BAA6-76244A0734E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CE699AB8-4122-4369-BAA6-76244A0734E4}.Release|Any CPU.Build.0 = Release|Any CPU
{C33F07DB-7ACB-4081-92C2-BB739CB605C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C33F07DB-7ACB-4081-92C2-BB739CB605C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C33F07DB-7ACB-4081-92C2-BB739CB605C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C33F07DB-7ACB-4081-92C2-BB739CB605C0}.Release|Any CPU.Build.0 = Release|Any CPU
- {348152A9-6A9C-4115-B60A-9E08CA72451D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {348152A9-6A9C-4115-B60A-9E08CA72451D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {348152A9-6A9C-4115-B60A-9E08CA72451D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {348152A9-6A9C-4115-B60A-9E08CA72451D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {18E19833-D47E-4A7F-AE64-31E28FEF8728}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {18E19833-D47E-4A7F-AE64-31E28FEF8728}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {18E19833-D47E-4A7F-AE64-31E28FEF8728}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {18E19833-D47E-4A7F-AE64-31E28FEF8728}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8902AFBA-4ACA-4880-B606-ADEC6BB21A1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8902AFBA-4ACA-4880-B606-ADEC6BB21A1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8902AFBA-4ACA-4880-B606-ADEC6BB21A1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8902AFBA-4ACA-4880-B606-ADEC6BB21A1B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C33F07DB-7ACB-4081-92C2-BB739CB605C0} = {691EBA79-CAA4-4670-BC8B-4537F990ADBF}
- {348152A9-6A9C-4115-B60A-9E08CA72451D} = {691EBA79-CAA4-4670-BC8B-4537F990ADBF}
+ {18E19833-D47E-4A7F-AE64-31E28FEF8728} = {691EBA79-CAA4-4670-BC8B-4537F990ADBF}
EndGlobalSection
EndGlobal
diff --git a/Dynamitey/Builder.cs b/Dynamitey/Builder.cs
index f59f92b..515228d 100644
--- a/Dynamitey/Builder.cs
+++ b/Dynamitey/Builder.cs
@@ -29,7 +29,7 @@ public static class Builder
/// New Builder
///
///
- public static IImpromptuBuilder New()
+ public static IBuilder New()
{
return new Builder();
}
@@ -41,7 +41,7 @@ public static IImpromptuBuilder New()
///
/// The type of the object prototype.
///
- public static IImpromptuBuilder New() where TObjectPrototype : new()
+ public static IBuilder New() where TObjectPrototype : new()
{
return new Builder();
}
diff --git a/Dynamitey/CacheableInvocation.cs b/Dynamitey/CacheableInvocation.cs
index 806727a..dd124fa 100644
--- a/Dynamitey/CacheableInvocation.cs
+++ b/Dynamitey/CacheableInvocation.cs
@@ -4,6 +4,8 @@
using System.Runtime.CompilerServices;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp.RuntimeBinder;
+using System.Reflection;
+using Dynamitey.Internal.Compat;
namespace Dynamitey
{
@@ -261,7 +263,7 @@ public override object Invoke(object target, params object[] args)
{
case InvocationKind.Constructor:
var tTarget = (Type) target;
- return InvokeHelper.InvokeConstructorCallSite(tTarget, tTarget.IsValueType, args, _argNames,
+ return InvokeHelper.InvokeConstructorCallSite(tTarget, tTarget.GetTypeInfo().IsValueType, args, _argNames,
ref _callSite);
case InvocationKind.Convert:
return InvokeHelper.InvokeConvertCallSite(target, _convertExplicit, _convertType, _context,
diff --git a/Dynamitey/Dynamic.cs b/Dynamitey/Dynamic.cs
index 6c9601a..b607ebd 100644
--- a/Dynamitey/Dynamic.cs
+++ b/Dynamitey/Dynamic.cs
@@ -15,29 +15,37 @@
using System.Collections.Generic;
using System.Dynamic;
+using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
+using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Threading;
using Dynamitey.Internal;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp.RuntimeBinder;
using System.Text.RegularExpressions;
+using Dynamitey.Internal.Compat;
namespace Dynamitey
{
using System;
-
+
///
/// Main API
///
public static class Dynamic
{
-
+ ///
+ /// Clears the dynamic binding caches.
+ ///
+ public static void ClearCaches()
+ {
+ InvokeHelper.ClearAllCaches();
+ }
private static readonly Type ComObjectType;
@@ -47,7 +55,7 @@ static Dynamic()
{
try
{
- ComObjectType = typeof(object).Assembly.GetType("System.__ComObject");
+ ComObjectType = typeof(object).GetTypeInfo().Assembly.GetType("System.__ComObject");
ComBinder = new DynamicObjects.LateType(
"System.Dynamic.ComBinder, System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
}
@@ -130,7 +138,7 @@ public static CallSite CreateCallSite(CallSiteBinder binder, String_OR_Inv
///
public static dynamic Linq(object enumerable)
{
- if(enumerable.GetType().GetInterfaces().Where(it=>it.IsGenericType)
+ if(enumerable.GetType().GetTypeInfo().GetInterfaces().Where(it=>it.GetTypeInfo().IsGenericType)
.All(it => it.GetGenericTypeDefinition() != typeof(IEnumerable<>)))
{
var tEnum = enumerable as System.Collections.IEnumerable;
@@ -253,6 +261,10 @@ public static dynamic InvokeBinaryOperator(dynamic leftArg, ExpressionType op, d
return leftArg | rightArg;
case ExpressionType.And:
return leftArg & rightArg;
+ case ExpressionType.OrElse:
+ return leftArg || rightArg;
+ case ExpressionType.AndAlso:
+ return leftArg && rightArg;
default:
throw new ArgumentException("Unsupported Operator", "op");
}
@@ -529,7 +541,7 @@ public static dynamic Curry(object target, int? totalArgCount = null)
///
public static dynamic Curry(Delegate target)
{
- return new Curry(target, target.Method.GetParameters().Length);
+ return new Curry(target, target.GetMethodInfo().GetParameters().Length);
}
@@ -693,11 +705,12 @@ public static dynamic InvokeConvert(object target, Type type, bool @explicit =fa
///
public static dynamic CoerceToDelegate(object invokeableObject, Type delegateType)
{
- if (!typeof(Delegate).IsAssignableFrom(delegateType.BaseType))
+ var delegateTypeInfo = delegateType.GetTypeInfo();
+ if (!typeof(Delegate).GetTypeInfo().IsAssignableFrom(delegateTypeInfo.BaseType))
{
return null;
}
- var tDelMethodInfo = delegateType.GetMethod("Invoke");
+ var tDelMethodInfo = delegateTypeInfo.GetMethod("Invoke");
var tReturnType = tDelMethodInfo.ReturnType;
var tAction = tReturnType == typeof(void);
var tParams = tDelMethodInfo.GetParameters();
@@ -707,7 +720,7 @@ public static dynamic CoerceToDelegate(object invokeableObject, Type delegateTyp
: InvokeHelper.WrapFunc(tReturnType, invokeableObject, tLength);
- if (!InvokeHelper.IsActionOrFunc(delegateType) || tParams.Any(it => it.ParameterType.IsValueType))
+ if (!InvokeHelper.IsActionOrFunc(delegateType) || tParams.Any(it => it.ParameterType.GetTypeInfo().IsValueType))
//Conditions that aren't contravariant;
{
Delegate tGetResult;
@@ -800,7 +813,8 @@ internal static readonly Type TypeConverterAttributeSL
///
public static dynamic CoerceConvert(object target, Type type)
{
- if (target != null && !type.IsInstanceOfType(target) && !IsDBNull(target))
+ var typeInfo = type.GetTypeInfo();
+ if (target != null && !typeInfo.IsInstanceOfType(target) && !IsDBNull(target))
{
var delegateConversion = CoerceToDelegate(target, type);
@@ -809,7 +823,7 @@ public static dynamic CoerceConvert(object target, Type type)
return delegateConversion;
- if (type.IsInterface && Impromptu.IsAvailable)
+ if (typeInfo.IsInterface && Impromptu.IsAvailable)
{
@@ -841,20 +855,20 @@ public static dynamic CoerceConvert(object target, Type type)
catch (RuntimeBinderException)
{
Type tReducedType = type;
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
+ if (typeInfo.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
{
- tReducedType = type.GetGenericArguments().First();
+ tReducedType = typeInfo.GetGenericArguments().First();
}
- if (typeof (Enum).IsAssignableFrom(tReducedType) && target is string)
+ if (typeof (Enum).GetTypeInfo().IsAssignableFrom(tReducedType) && target is string)
{
target = Enum.Parse(tReducedType, target as String, true);
}
- else if (target is IConvertible && typeof (IConvertible).IsAssignableFrom(tReducedType))
+ else if (target is IConvertible && typeof (IConvertible).GetTypeInfo().IsAssignableFrom(tReducedType))
{
- target = Convert.ChangeType(target, tReducedType, Thread.CurrentThread.CurrentCulture);
+ target = Convert.ChangeType(target, tReducedType, Net40.GetDefaultThreadCurrentCulture());
}
else
@@ -869,7 +883,7 @@ public static dynamic CoerceConvert(object target, Type type)
else if (TypeConverterAttributeSL != null)
{
var tAttributes =
- tReducedType.GetCustomAttributes(TypeConverterAttributeSL, false);
+ tReducedType.GetTypeInfo().GetCustomAttributes(TypeConverterAttributeSL, false);
dynamic attribute = tAttributes.FirstOrDefault();
if (attribute != null)
{
@@ -893,11 +907,11 @@ public static dynamic CoerceConvert(object target, Type type)
}
}
}
- else if (((target == null) || IsDBNull(target )) && type.IsValueType)
+ else if (((target == null) || IsDBNull(target )) && typeInfo.IsValueType)
{
target = Dynamic.InvokeConstructor(type);
}
- else if (!type.IsInstanceOfType(target) && IsDBNull(target))
+ else if (!typeInfo.IsInstanceOfType(target) && IsDBNull(target))
{
return null;
}
@@ -913,7 +927,7 @@ public static dynamic CoerceConvert(object target, Type type)
public static dynamic InvokeConstructor(Type type, params object[] args)
{
string[] tArgNames;
- bool tValue = type.IsValueType;
+ bool tValue = type.GetTypeInfo().IsValueType;
if (tValue && args.Length == 0) //dynamic invocation doesn't see constructors of value types
{
return Activator.CreateInstance(type);
@@ -935,7 +949,7 @@ public static dynamic InvokeConstructor(Type type, params object[] args)
///
public static object FastDynamicInvoke(this Delegate del, params object[] args)
{
- if(del.Method.ReturnType == typeof(void)){
+ if(del.GetMethodInfo().ReturnType == typeof(void)){
InvokeHelper.FastDynamicInvokeAction(del, args);
return null;
@@ -974,7 +988,7 @@ public static IEnumerable GetMemberNames(object target, bool dynamicOnly
var tList = new List();
if (!dynamicOnly)
{
- tList.AddRange(target.GetType().GetProperties().Select(it => it.Name));
+ tList.AddRange(target.GetType().GetTypeInfo().GetProperties().Select(it => it.Name));
}
var tTarget = target as IDynamicMetaObjectProvider;
@@ -984,7 +998,7 @@ public static IEnumerable GetMemberNames(object target, bool dynamicOnly
}else
{
- if (ComObjectType != null && ComObjectType.IsInstanceOfType(target) && ComBinder.IsAvailable)
+ if (ComObjectType != null && ComObjectType.GetTypeInfo().IsInstanceOfType(target) && ComBinder.IsAvailable)
{
tList.AddRange(ComBinder.GetDynamicDataMemberNames(target));
}
diff --git a/Dynamitey/DynamicObjects/BaseDictionary.cs b/Dynamitey/DynamicObjects/BaseDictionary.cs
index 2b8cc1c..1615d86 100644
--- a/Dynamitey/DynamicObjects/BaseDictionary.cs
+++ b/Dynamitey/DynamicObjects/BaseDictionary.cs
@@ -19,7 +19,6 @@
using System.Dynamic;
using System.Linq;
using System.Reflection;
-using System.Runtime.Serialization;
using System.Threading;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp.RuntimeBinder;
diff --git a/Dynamitey/DynamicObjects/BaseForwarder.cs b/Dynamitey/DynamicObjects/BaseForwarder.cs
index 30f7194..eacabbd 100644
--- a/Dynamitey/DynamicObjects/BaseForwarder.cs
+++ b/Dynamitey/DynamicObjects/BaseForwarder.cs
@@ -18,7 +18,6 @@
using System.Dynamic;
using System.Linq;
using System.Reflection;
-using System.Runtime.Serialization;
using System.Text;
using Dynamitey.Internal.Optimization;
using Microsoft.CSharp;
@@ -239,9 +238,53 @@ public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, o
object[] tArgs = Util.NameArgsIfNecessary(binder.CallInfo, args);
+
+ Type[] types = null;
+
+ try
+ {
+ //.net core
+ // Try and pull generic arguments from binder
+ IList typeList = Dynamic.InvokeGet(binder,
+ "TypeArguments");
+ if (typeList != null)
+ {
+ types = typeList.ToArray();
+ }
+
+ }
+ catch (RuntimeBinderException)
+ {
+ types = null;
+ }
+
+ if (types == null)
+ {
+ try
+ {
+ //.net 4.0
+ // Try and pull generic arguments from binder
+ IList typeList = Dynamic.InvokeGet(binder,
+ "Microsoft.CSharp.RuntimeBinder.ICSharpInvokeOrInvokeMemberBinder.TypeArguments");
+ if (typeList != null)
+ {
+
+ types = typeList.ToArray();
+
+ }
+
+ }
+ catch (RuntimeBinderException)
+ {
+ types = null;
+ }
+ }
+
+ var name = InvokeMemberName.Create;
+ var fullName = name(binder.Name, types);
try
{
- result = Dynamic.InvokeMember(CallTarget, binder.Name, tArgs);
+ result = Dynamic.InvokeMember(CallTarget, fullName, tArgs);
}
catch (RuntimeBinderException)
@@ -249,7 +292,7 @@ public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, o
result = null;
try
{
- Dynamic.InvokeMemberAction(CallTarget, binder.Name, tArgs);
+ Dynamic.InvokeMemberAction(CallTarget, fullName, tArgs);
}
catch (RuntimeBinderException)
{
diff --git a/Dynamitey/DynamicObjects/BaseObject.cs b/Dynamitey/DynamicObjects/BaseObject.cs
index 38ed0bf..3babf47 100644
--- a/Dynamitey/DynamicObjects/BaseObject.cs
+++ b/Dynamitey/DynamicObjects/BaseObject.cs
@@ -18,9 +18,9 @@
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
-using System.Runtime.Serialization;
-
using System.Reflection;
+using Dynamitey.Internal.Compat;
+
namespace Dynamitey.DynamicObjects
{
@@ -37,13 +37,15 @@ public interface IEquivalentType
///
FauxType EquivalentType { get; set; }
}
+
+
///
/// Dynamic Object that knows about the Impromtu Interface return types;
/// Override Typical Dynamic Object methods, and use TypeForName to get the return type of an interface member.
///
- public abstract class BaseObject : DynamicObject, IEquivalentType, IServiceProvider
+ public abstract class BaseObject : DynamicObject, IEquivalentType
{
///
@@ -73,16 +75,26 @@ public bool TryTypeForName(string binderName, out Type type)
.Where(it => it is PropertyInfo || it is MethodInfo || it is EventInfo)
.Select(it =>
{
- var prop =it as PropertyInfo;
- if (prop != null)
- return prop.PropertyType;
- var mem = it as MethodInfo;
- if (mem != null)
- return mem.ReturnType;
- var eve = it as EventInfo;
- if (eve != null)
- return eve.EventHandlerType;
- return typeof (object);
+
+ switch (it)
+ {
+ case PropertyInfo p:
+ return p.PropertyType;
+ case MethodInfo m:
+ return m.ReturnType;
+ case EventInfo e:
+ return e.EventHandlerType;
+#if NET40 || PROFILE158
+ case Type t:
+ return t;
+#else
+ case TypeInfo t:
+ return t.UnderlyingSystemType;
+#endif
+ default:
+ return typeof (object);
+ }
+
}).ToList();
;
@@ -90,7 +102,7 @@ public bool TryTypeForName(string binderName, out Type type)
return false;
foreach (var currenttype in types)
{
- if (type == null || type == currenttype)
+ if (type == null || type.Name == currenttype.Name)
type = currenttype;
else
type = typeof (object);
@@ -100,23 +112,5 @@ public bool TryTypeForName(string binderName, out Type type)
FauxType IEquivalentType.EquivalentType { get; set; }
-
- object IServiceProvider.GetService(Type serviceType)
- {
- var aggreTypes =AggreType.MakeTypeAppendable(this);
-
- if (!aggreTypes.ContainsType(serviceType))
- {
- aggreTypes.AddType(serviceType);
-
- if (serviceType.IsInterface && Dynamic.Impromptu.IsAvailable)
- {
- return Dynamic.Impromptu.DynamicActLike(this, aggreTypes.GetInterfaceTypes());
- }
-
- }
-
- return this;
- }
}
}
diff --git a/Dynamitey/DynamicObjects/Builder.cs b/Dynamitey/DynamicObjects/Builder.cs
index 10ed42d..a2e6db0 100644
--- a/Dynamitey/DynamicObjects/Builder.cs
+++ b/Dynamitey/DynamicObjects/Builder.cs
@@ -17,10 +17,10 @@
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
-using System.Runtime.Serialization;
using System.Text;
using System.Reflection;
using Dynamitey.Internal.Optimization;
+using Dynamitey.Internal.Compat;
namespace Dynamitey.DynamicObjects
{
@@ -28,7 +28,7 @@ namespace Dynamitey.DynamicObjects
///
/// Interface for simplistic builder options
///
- public interface IImpromptuBuilder
+ public interface IBuilder
{
///
@@ -121,7 +121,7 @@ public interface IImpromptuBuilder
///
/// The type of the object proto type.
- public class Builder: BaseObject, IImpromptuBuilder
+ public class Builder: BaseObject, IBuilder
{
///
/// Build factory storage
@@ -134,8 +134,8 @@ public class Builder: BaseObject, IImpromptuBuilder
///
public Builder(){
_buildType = new Dictionary();
- Setup = new SetupTrampoline(this);
- Object = new BuilderTrampoline(this);
+ Setup = new SetupTrampoline(this);
+ Object = new BuilderTrampoline(this);
}
///
@@ -260,7 +260,7 @@ public dynamic Array(params dynamic[] contents)
/// Creates a Prototype object.
///
/// The object.
- public dynamic Object { get; private set; }
+ public dynamic Object { get; }
///
/// Sets up object builder
@@ -292,7 +292,7 @@ public dynamic ObjectSetup(Func