Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJose Perez Rodriguez <joperezr@microsoft.com>2016-10-07 22:00:10 +0300
committerJose Perez Rodriguez <joperezr@microsoft.com>2016-10-11 01:38:26 +0300
commit42f2369a42c8bda746d0b35a4259800715c3a331 (patch)
tree3f1727d0e4f01c590a5f8380572e481f3846b049 /src
parent95e602185f1215ab36d613c82a0fb27edcf22339 (diff)
Adding Delegate missing members
Diffstat (limited to 'src')
-rw-r--r--src/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj2
-rw-r--r--src/System.Runtime/System.Runtime.sln34
-rw-r--r--src/System.Runtime/ref/System.Runtime.cs31
-rw-r--r--src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt25
-rw-r--r--src/System.Runtime/tests/System.Runtime.Tests.csproj13
-rw-r--r--src/System.Runtime/tests/System/DelegateTests.netstandard1.7.cs942
6 files changed, 1038 insertions, 9 deletions
diff --git a/src/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj
index 1962d468ea..4b882e432a 100644
--- a/src/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj
+++ b/src/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj
@@ -64,6 +64,8 @@
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
+ <!-- ToDo: Remove this P2P reference once package update is pushed. -->
+ <ProjectReference Include="..\..\System.Runtime\pkg\System.Runtime.pkgproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project> \ No newline at end of file
diff --git a/src/System.Runtime/System.Runtime.sln b/src/System.Runtime/System.Runtime.sln
index 2185ea3482..20e2be9a3a 100644
--- a/src/System.Runtime/System.Runtime.sln
+++ b/src/System.Runtime/System.Runtime.sln
@@ -51,16 +51,16 @@ Global
Windows_Release|x86 = Windows_Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|Any CPU.ActiveCfg = netstandard1.7_Debug|Any CPU
- {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|Any CPU.Build.0 = netstandard1.7_Debug|Any CPU
+ {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|ARM.ActiveCfg = netstandard1.5_Debug|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|ARM.Build.0 = netstandard1.5_Debug|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|x64.ActiveCfg = netstandard1.5_Debug|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|x64.Build.0 = netstandard1.5_Debug|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|x86.ActiveCfg = netstandard1.5_Debug|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Debug|x86.Build.0 = netstandard1.5_Debug|Any CPU
- {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Release|Any CPU.ActiveCfg = netstandard1.7_Release|Any CPU
- {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Release|Any CPU.Build.0 = netstandard1.7_Release|Any CPU
+ {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Release|Any CPU.Build.0 = Release|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Release|ARM.ActiveCfg = netstandard1.5_Release|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Release|ARM.Build.0 = netstandard1.5_Release|Any CPU
{7F5F5134-00FE-4DE8-B20C-3DA8BA2EBA68}.Release|x64.ActiveCfg = netstandard1.5_Release|Any CPU
@@ -185,10 +185,36 @@ Global
{56B9D0A9-44D3-488E-8B42-C14A6E30CAB2}.Windows_Release|x86.Build.0 = Release|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|Any CPU.ActiveCfg = Windows_Debug|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|ARM.ActiveCfg = Windows_uap101aot_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|ARM.Build.0 = Windows_uap101aot_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|x64.ActiveCfg = Windows_uap101aot_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|x64.Build.0 = Windows_uap101aot_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|x86.ActiveCfg = Windows_uap101aot_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Debug|x86.Build.0 = Windows_uap101aot_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|Any CPU.ActiveCfg = Windows_uap101aot_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|Any CPU.Build.0 = Windows_uap101aot_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|ARM.ActiveCfg = Windows_uap101aot_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|ARM.Build.0 = Windows_uap101aot_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|x64.ActiveCfg = Windows_uap101aot_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|x64.Build.0 = Windows_uap101aot_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|x86.ActiveCfg = Windows_uap101aot_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Release|x86.Build.0 = Windows_uap101aot_Release|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|Any CPU.ActiveCfg = Unix_Debug|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|Any CPU.Build.0 = Unix_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|ARM.ActiveCfg = Unix_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|ARM.Build.0 = Unix_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|x64.ActiveCfg = Unix_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|x64.Build.0 = Unix_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|x86.ActiveCfg = Unix_Debug|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|x86.Build.0 = Unix_Debug|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|Any CPU.ActiveCfg = Unix_Release|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|Any CPU.Build.0 = Unix_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|ARM.ActiveCfg = Unix_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|ARM.Build.0 = Unix_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|x64.ActiveCfg = Unix_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|x64.Build.0 = Unix_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|x86.ActiveCfg = Unix_Release|Any CPU
+ {4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|x86.Build.0 = Unix_Release|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_Debug|Any CPU.ActiveCfg = Windows_Debug|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_Debug|ARM.ActiveCfg = Windows_Debug|Any CPU
diff --git a/src/System.Runtime/ref/System.Runtime.cs b/src/System.Runtime/ref/System.Runtime.cs
index c0f6003eff..84de6d5f28 100644
--- a/src/System.Runtime/ref/System.Runtime.cs
+++ b/src/System.Runtime/ref/System.Runtime.cs
@@ -929,21 +929,39 @@ namespace System
public static bool TryParse(string s, out decimal result) { result = default(decimal); return default(bool); }
public static bool TryParse(string s, System.Globalization.NumberStyles style, System.IFormatProvider provider, out decimal result) { result = default(decimal); return default(bool); }
}
- public abstract partial class Delegate: System.Runtime.Serialization.ISerializable
+ public abstract partial class Delegate: System.ICloneable, System.Runtime.Serialization.ISerializable
{
+ protected Delegate(object target, string method) { }
+ protected Delegate(System.Type target, string method) { }
+ public System.Reflection.MethodInfo Method { get { throw null; } }
internal Delegate() { }
public object Target { get { return default(object); } }
+ public virtual object Clone() { throw null; }
public static System.Delegate Combine(System.Delegate a, System.Delegate b) { return default(System.Delegate); }
public static System.Delegate Combine(params System.Delegate[] delegates) { return default(System.Delegate); }
+ protected virtual System.Delegate CombineImpl(System.Delegate d) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, object firstArgument, System.Reflection.MethodInfo method) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, object firstArgument, System.Reflection.MethodInfo method, bool throwOnBindFailure) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, object target, string method) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, object target, string method, bool ignoreCase) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, System.Reflection.MethodInfo method) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, System.Reflection.MethodInfo method, bool throwOnBindFailure) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, System.Type target, string method) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, System.Type target, string method, bool ignoreCase) { throw null; }
+ public static System.Delegate CreateDelegate(System.Type type, System.Type target, string method, bool ignoreCase, bool throwOnBindFailure) { throw null; }
public object DynamicInvoke(params object[] args) { return default(object); }
+ protected virtual object DynamicInvokeImpl(object[] args) { throw null; }
public override bool Equals(object obj) { return default(bool); }
public override int GetHashCode() { return default(int); }
public virtual System.Delegate[] GetInvocationList() { return default(System.Delegate[]); }
+ protected virtual System.Reflection.MethodInfo GetMethodImpl() { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public static bool operator ==(System.Delegate d1, System.Delegate d2) { return default(bool); }
public static bool operator !=(System.Delegate d1, System.Delegate d2) { return default(bool); }
public static System.Delegate Remove(System.Delegate source, System.Delegate value) { return default(System.Delegate); }
public static System.Delegate RemoveAll(System.Delegate source, System.Delegate value) { return default(System.Delegate); }
+ protected virtual System.Delegate RemoveImpl(System.Delegate d) { throw null; }
}
public partial class DivideByZeroException : System.ArithmeticException
{
@@ -1560,12 +1578,23 @@ namespace System
public abstract partial class MulticastDelegate : System.Delegate
{
internal MulticastDelegate() { }
+ protected MulticastDelegate(object target, string method) : base(default(object), default(string)) { }
+ protected MulticastDelegate(System.Type target, string method) : base(default(object), default(string)) { }
+ protected sealed override System.Delegate CombineImpl(System.Delegate follow) { throw null; }
public sealed override bool Equals(object obj) { return default(bool); }
public sealed override int GetHashCode() { return default(int); }
public sealed override System.Delegate[] GetInvocationList() { return default(System.Delegate[]); }
+ protected override System.Reflection.MethodInfo GetMethodImpl() { throw null; }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public static bool operator ==(System.MulticastDelegate d1, System.MulticastDelegate d2) { return default(bool); }
public static bool operator !=(System.MulticastDelegate d1, System.MulticastDelegate d2) { return default(bool); }
+ protected sealed override System.Delegate RemoveImpl(System.Delegate value) { throw null; }
+ }
+ public sealed partial class MulticastNotSupportedException : System.SystemException
+ {
+ public MulticastNotSupportedException() { }
+ public MulticastNotSupportedException(string message) { }
+ public MulticastNotSupportedException(string message, System.Exception inner) { }
}
[AttributeUsage(AttributeTargets.Field, Inherited = false)]
public sealed class NonSerializedAttribute : Attribute
diff --git a/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt b/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt
index d444a7b94e..b807832620 100644
--- a/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt
+++ b/src/System.Runtime/src/ApiCompatBaseline.uap101aot.txt
@@ -456,3 +456,28 @@ TypesMustExist : Type 'System.Runtime.CompilerServices.FixedAddressValueTypeAttr
TypesMustExist : Type 'System.Runtime.MemoryFailPoint' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Runtime.ConstrainedExecution.ReliabilityContractAttribute' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs' does not exist in the implementation but it does exist in the contract.
+CannotSealType : Type 'System.Delegate' is sealed in the implementation but not sealed in the contract.
+MembersMustExist : Member 'System.Delegate..ctor(System.Object, System.String)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate..ctor(System.Type, System.String)' does not exist in the implementation but it does exist in the contract.
+CannotMakeMemberNonVirtual : Member 'System.Delegate.Clone()' is non-virtual in the implementation but is virtual in the contract.
+MembersMustExist : Member 'System.Delegate.CombineImpl(System.Delegate)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Object, System.Reflection.MethodInfo)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Object, System.Reflection.MethodInfo, System.Boolean)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Object, System.String)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Object, System.String, System.Boolean)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Object, System.String, System.Boolean, System.Boolean)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Reflection.MethodInfo)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Reflection.MethodInfo, System.Boolean)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Type, System.String)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Type, System.String, System.Boolean)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.CreateDelegate(System.Type, System.Type, System.String, System.Boolean, System.Boolean)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.Delegate.DynamicInvokeImpl(System.Object[])' does not exist in the implementation but it does exist in the contract.
+CannotMakeMemberNonVirtual : Member 'System.Delegate.Equals(System.Object)' is non-virtual in the implementation but is virtual in the contract.
+CannotMakeMemberNonVirtual : Member 'System.Delegate.GetHashCode()' is non-virtual in the implementation but is virtual in the contract.
+CannotMakeMemberNonVirtual : Member 'System.Delegate.GetInvocationList()' is non-virtual in the implementation but is virtual in the contract.
+CannotMakeMemberNonVirtual : Member 'System.Delegate.GetMethodImpl()' is non-virtual in the implementation but is virtual in the contract.
+MembersMustExist : Member 'System.Delegate.RemoveImpl(System.Delegate)' does not exist in the implementation but it does exist in the contract.
+CannotSealType : Type 'System.MulticastDelegate' is sealed in the implementation but not sealed in the contract.
+MembersMustExist : Member 'System.MulticastDelegate..ctor(System.Object, System.String)' does not exist in the implementation but it does exist in the contract.
+MembersMustExist : Member 'System.MulticastDelegate..ctor(System.Type, System.String)' does not exist in the implementation but it does exist in the contract.
+TypesMustExist : Type 'System.MulticastNotSupportedException' does not exist in the implementation but it does exist in the contract. \ No newline at end of file
diff --git a/src/System.Runtime/tests/System.Runtime.Tests.csproj b/src/System.Runtime/tests/System.Runtime.Tests.csproj
index e5d64cd8f6..c41cd3bfbc 100644
--- a/src/System.Runtime/tests/System.Runtime.Tests.csproj
+++ b/src/System.Runtime/tests/System.Runtime.Tests.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -13,14 +13,18 @@
<NugetTargetMoniker Condition="'$(TargetGroup)' == ''">.NETStandard,Version=v1.7</NugetTargetMoniker>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.7_Debug|AnyCPU' ">
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.7_Release|AnyCPU' ">
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.5_Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.5_Release|AnyCPU' ">
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netcoreapp1.1_Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netcoreapp1.1_Release|AnyCPU' ">
+ </PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)\System\EnumTypes.cs">
<Link>Common\System\EnumTypes.cs</Link>
@@ -111,6 +115,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == ''">
<Compile Include="ArrayTests.netstandard1.7.cs" />
+ <Compile Include="System\DelegateTests.netstandard1.7.cs" />
<Compile Include="System\AttributeTests.netstandard1.7.cs" />
<Compile Include="CompareToTests.cs" />
<Compile Include="DecimalTests.netstandard1.7.cs" />
@@ -189,4 +194,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/System.Runtime/tests/System/DelegateTests.netstandard1.7.cs b/src/System.Runtime/tests/System/DelegateTests.netstandard1.7.cs
new file mode 100644
index 0000000000..037efdc7e3
--- /dev/null
+++ b/src/System.Runtime/tests/System/DelegateTests.netstandard1.7.cs
@@ -0,0 +1,942 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// See the LICENSE file in the project root for more information.
+
+// DelegateTest.cs - NUnit Test Cases for the System.Delegate class
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+using Xunit;
+
+namespace System.Tests
+{
+ public static class CreateDelegateTests
+ {
+ #region Tests
+ [Fact]
+ public static void CreateDelegate1_Method_Static()
+ {
+ C c = new C();
+ MethodInfo mi = typeof(C).GetMethod("S");
+ Delegate dg = Delegate.CreateDelegate(typeof(D), mi);
+ Assert.Same(mi, dg.Method);
+ Assert.Null(dg.Target);
+ D d = (D)dg;
+ d(c);
+ }
+
+ [Fact]
+ public static void CreateDelegate1_Method_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(D), (MethodInfo)null);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("method", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate1_Type_Null()
+ {
+ MethodInfo mi = typeof(C).GetMethod("S");
+ try
+ {
+ Delegate.CreateDelegate((Type)null, mi);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("type", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2()
+ {
+ E e;
+
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(), "Execute");
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(), "Execute");
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(), "DoExecute");
+ Assert.NotNull(e);
+ Assert.Equal(102, e(new C()));
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Method_ArgumentsMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "StartExecute");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Method_CaseMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(), "ExecutE");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Method_DoesNotExist()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "DoesNotExist");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Method_Null()
+ {
+ C c = new C();
+ try
+ {
+ Delegate.CreateDelegate(typeof(D), c, (string)null);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("method", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Method_ReturnTypeMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "DoExecute");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Method_Static()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(), "Run");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Target_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(D), null, "N");
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("target", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate2_Type_Null()
+ {
+ C c = new C();
+ try
+ {
+ Delegate.CreateDelegate((Type)null, c, "N");
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("type", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3()
+ {
+ E e;
+
+ // matching static method
+ e = (E)Delegate.CreateDelegate(typeof(E), typeof(B), "Run");
+ Assert.NotNull(e);
+ Assert.Equal(5, e(new C()));
+
+ // matching static method
+ e = (E)Delegate.CreateDelegate(typeof(E), typeof(C), "Run");
+ Assert.NotNull(e);
+ Assert.Equal(5, e(new C()));
+
+ // matching static method
+ e = (E)Delegate.CreateDelegate(typeof(E), typeof(C), "DoRun");
+ Assert.NotNull(e);
+ Assert.Equal(107, e(new C()));
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Method_ArgumentsMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), typeof(B),
+ "StartRun");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Method_CaseMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), typeof(B), "RuN");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Method_DoesNotExist()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), typeof(B),
+ "DoesNotExist");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Method_Instance()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), typeof(B), "Execute");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Method_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(D), typeof(C), (string)null);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("method", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Method_ReturnTypeMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), typeof(B),
+ "DoRun");
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Target_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(D), (Type)null, "S");
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("target", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate3_Type_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate((Type)null, typeof(C), "S");
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("type", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4()
+ {
+ E e;
+
+ B b = new B();
+
+ // instance method, exact case, ignore case
+ e = (E)Delegate.CreateDelegate(typeof(E), b, "Execute", true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // instance method, exact case, do not ignore case
+ e = (E)Delegate.CreateDelegate(typeof(E), b, "Execute", false);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // instance method, case mismatch, ignore case
+ e = (E)Delegate.CreateDelegate(typeof(E), b, "ExecutE", true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ C c = new C();
+
+ // instance method, exact case, ignore case
+ e = (E)Delegate.CreateDelegate(typeof(E), c, "Execute", true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // instance method, exact case, ignore case
+ e = (E)Delegate.CreateDelegate(typeof(E), c, "DoExecute", true);
+ Assert.NotNull(e);
+ Assert.Equal(102, e(new C()));
+
+ // instance method, exact case, do not ignore case
+ e = (E)Delegate.CreateDelegate(typeof(E), c, "Execute", false);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // instance method, case mismatch, ignore case
+ e = (E)Delegate.CreateDelegate(typeof(E), c, "ExecutE", true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Method_ArgumentsMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "StartExecute", false);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Method_CaseMismatch()
+ {
+ // instance method, case mismatch, do not igore case
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "ExecutE", false);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Method_DoesNotExist()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "DoesNotExist", false);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Method_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(D), new C(),
+ (string)null, true);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("method", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Method_ReturnTypeMismatch()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "DoExecute", false);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Method_Static()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(), "Run", true);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Target_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(D), null, "N", true);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("target", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate4_Type_Null()
+ {
+ C c = new C();
+ try
+ {
+ Delegate.CreateDelegate((Type)null, c, "N", true);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("type", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate9()
+ {
+ E e;
+
+ // do not ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "Execute", false, false);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // do not ignore case, throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "Execute", false, true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "Execute", true, false);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // ignore case, throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "Execute", true, true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // do not ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "Execute", false, false);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // do not ignore case, throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "Execute", false, true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "Execute", true, false);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // ignore case, throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "Execute", true, true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // do not ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "DoExecute", false, false);
+ Assert.NotNull(e);
+ Assert.Equal(102, e(new C()));
+
+ // do not ignore case, throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "DoExecute", false, true);
+ Assert.NotNull(e);
+ Assert.Equal(102, e(new C()));
+
+ // ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "DoExecute", true, false);
+ Assert.NotNull(e);
+ Assert.Equal(102, e(new C()));
+
+ // ignore case, throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new C(),
+ "DoExecute", true, true);
+ Assert.NotNull(e);
+ Assert.Equal(102, e(new C()));
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Method_ArgumentsMismatch()
+ {
+ // throw bind failure
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "StartExecute", false, true);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+
+ // do not throw on bind failure
+ E e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "StartExecute", false, false);
+ Assert.Null(e);
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Method_CaseMismatch()
+ {
+ E e;
+
+ // do not ignore case, throw bind failure
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "ExecutE", false, true);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+
+ // do not ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "ExecutE", false, false);
+ Assert.Null(e);
+
+ // ignore case, throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "ExecutE", true, true);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+
+ // ignore case, do not throw bind failure
+ e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "ExecutE", true, false);
+ Assert.NotNull(e);
+ Assert.Equal(4, e(new C()));
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Method_DoesNotExist()
+ {
+ // throw bind failure
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "DoesNotExist", false, true);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+
+ // do not throw on bind failure
+ E e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "DoesNotExist", false, false);
+ Assert.Null(e);
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Method_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ (string)null, false, false);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("method", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Method_ReturnTypeMismatch()
+ {
+ // throw bind failure
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "DoExecute", false, true);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+
+ // do not throw on bind failure
+ E e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "DoExecute", false, false);
+ Assert.Null(e);
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Method_Static()
+ {
+ // throw bind failure
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), new B(),
+ "Run", true, true);
+ }
+ catch (ArgumentException ex)
+ {
+ // Error binding to target method
+ Assert.Equal(typeof(ArgumentException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.Null(ex.ParamName);
+ }
+
+ // do not throw on bind failure
+ E e = (E)Delegate.CreateDelegate(typeof(E), new B(),
+ "Run", true, false);
+ Assert.Null(e);
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Target_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate(typeof(E), (object)null,
+ "Execute", true, false);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("target", ex.ParamName);
+ }
+ }
+
+ [Fact]
+ public static void CreateDelegate9_Type_Null()
+ {
+ try
+ {
+ Delegate.CreateDelegate((Type)null, new B(),
+ "Execute", true, false);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.Equal(typeof(ArgumentNullException), ex.GetType());
+ Assert.Null(ex.InnerException);
+ Assert.NotNull(ex.Message);
+ Assert.NotNull(ex.ParamName);
+ Assert.Equal("type", ex.ParamName);
+ }
+ }
+
+ #endregion Tests
+
+ #region Test Setup
+
+ public class B
+ {
+
+ public virtual string retarg3(string s)
+ {
+ return s;
+ }
+
+ static int Run(C x)
+ {
+ return 5;
+ }
+
+ public static void DoRun(C x)
+ {
+ }
+
+ public static int StartRun(C x, B b)
+ {
+ return 6;
+ }
+
+ int Execute(C c)
+ {
+ return 4;
+ }
+
+ public static void DoExecute(C c)
+ {
+ }
+
+ public int StartExecute(C c, B b)
+ {
+ return 3;
+ }
+ }
+
+ public class C : B, Iface
+ {
+ public string retarg(string s)
+ {
+ return s;
+ }
+
+ public string retarg2(Iface iface, string s)
+ {
+ return s + "2";
+ }
+
+ public override string retarg3(string s)
+ {
+ return s + "2";
+ }
+
+ static void Run(C x)
+ {
+ }
+
+ public new static int DoRun(C x)
+ {
+ return 107;
+ }
+
+ void Execute(C c)
+ {
+ }
+
+ public new int DoExecute(C c)
+ {
+ return 102;
+ }
+
+ public static void M()
+ {
+ }
+
+ public static void N(C c)
+ {
+ }
+
+ public static void S(C c)
+ {
+ }
+
+ private void PrivateInstance()
+ {
+ }
+ }
+
+ public interface Iface
+ {
+ string retarg(string s);
+ }
+
+ public delegate void D(C c);
+ public delegate int E(C c);
+ #endregion Test Setup
+ }
+} \ No newline at end of file