Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,266 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
namespace System {
/// <summary>
/// Encapsulates a method that takes nine parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);
/// <summary>
/// Encapsulates a method that takes ten parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);
/// <summary>
/// Encapsulates a method that takes eleven parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);
/// <summary>
/// Encapsulates a method that takes twelve parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12);
/// <summary>
/// Encapsulates a method that takes thirteen parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13);
/// <summary>
/// Encapsulates a method that takes fourteen parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T14">The type of the fourteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg14">The fourteenth parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14);
/// <summary>
/// Encapsulates a method that takes fifteen parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T14">The type of the fourteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T15">The type of the fifteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg14">The fourteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg15">The fifteenth parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
/// <summary>
/// Encapsulates a method that takes sixteen parameters and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T14">The type of the fourteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T15">The type of the fifteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T16">The type of the sixteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg14">The fourteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg15">The fifteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg16">The sixteenth parameter of the method that this delegate encapsulates.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, in T16>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
}

View File

@@ -0,0 +1,124 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;
namespace System.Dynamic.Utils {
/// <summary>
/// Provides a dictionary-like object used for caches which holds onto a maximum
/// number of elements specified at construction time.
/// </summary>
internal class CacheDict<TKey, TValue> {
// cache size is always ^2.
// items are placed at [hash ^ mask]
// new item will displace previous one at the same location.
protected readonly int mask;
protected readonly Entry[] entries;
// class, to ensure atomic updates.
internal class Entry
{
internal readonly int hash;
internal readonly TKey key;
internal readonly TValue value;
internal Entry(int hash, TKey key, TValue value)
{
this.hash = hash;
this.key = key;
this.value = value;
}
}
/// <summary>
/// Creates a dictionary-like object used for caches.
/// </summary>
/// <param name="maxSize">The maximum number of elements to store will be this number aligned to next ^2.</param>
internal CacheDict(int size) {
var alignedSize = AlignSize(size);
this.mask = alignedSize - 1;
this.entries = new Entry[alignedSize];
}
private static int AlignSize(int size)
{
Debug.Assert(size > 0);
size--;
size |= size >> 1;
size |= size >> 2;
size |= size >> 4;
size |= size >> 8;
size |= size >> 16;
return size + 1;
}
/// <summary>
/// Tries to get the value associated with 'key', returning true if it's found and
/// false if it's not present.
/// </summary>
internal bool TryGetValue(TKey key, out TValue value) {
int hash = key.GetHashCode();
int idx = hash & mask;
var entry = Volatile.Read(ref this.entries[idx]);
if (entry != null && entry.hash == hash && entry.key.Equals(key))
{
value = entry.value;
return true;
}
value = default(TValue);
return false;
}
/// <summary>
/// Adds a new element to the cache, possibly replacing some
/// element that is already present.
/// </summary>
internal void Add(TKey key, TValue value) {
var hash = key.GetHashCode();
var idx = hash & mask;
var entry = Volatile.Read(ref this.entries[idx]);
if (entry == null || entry.hash != hash || !entry.key.Equals(key))
{
Volatile.Write(ref entries[idx], new Entry(hash, key, value));
}
}
/// <summary>
/// Returns the value associated with the given key, or throws KeyNotFoundException
/// if the key is not present.
/// </summary>
internal TValue this[TKey key] {
get {
TValue res;
if (TryGetValue(key, out res)) {
return res;
}
throw new KeyNotFoundException();
}
set {
Add(key, value);
}
}
}
}

View File

@@ -0,0 +1,208 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
#if CLR2
using Microsoft.Scripting.Utils;
using Microsoft.Scripting.Ast;
#else
using System.Diagnostics.Contracts;
using System.Linq.Expressions;
#endif
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace System.Dynamic.Utils {
internal static class CollectionExtensions {
/// <summary>
/// Wraps the provided enumerable into a ReadOnlyCollection{T}
///
/// Copies all of the data into a new array, so the data can't be
/// changed after creation. The exception is if the enumerable is
/// already a ReadOnlyCollection{T}, in which case we just return it.
/// </summary>
#if !CLR2
[Pure]
#endif
internal static ReadOnlyCollection<T> ToReadOnly<T>(this IEnumerable<T> enumerable) {
if (enumerable == null) {
return EmptyReadOnlyCollection<T>.Instance;
}
#if SILVERLIGHT
if (Expression.SilverlightQuirks) {
// Allow any ReadOnlyCollection to be stored directly
// (even though this is not safe)
var r = enumerable as ReadOnlyCollection<T>;
if (r != null) {
return r;
}
}
#endif
var troc = enumerable as TrueReadOnlyCollection<T>;
if (troc != null) {
return troc;
}
var builder = enumerable as ReadOnlyCollectionBuilder<T>;
if (builder != null) {
return builder.ToReadOnlyCollection();
}
var collection = enumerable as ICollection<T>;
if (collection != null) {
int count = collection.Count;
if (count == 0) {
return EmptyReadOnlyCollection<T>.Instance;
}
T[] clone = new T[count];
collection.CopyTo(clone, 0);
return new TrueReadOnlyCollection<T>(clone);
}
// ToArray trims the excess space and speeds up access
return new TrueReadOnlyCollection<T>(new List<T>(enumerable).ToArray());
}
// We could probably improve the hashing here
internal static int ListHashCode<T>(this IEnumerable<T> list) {
var cmp = EqualityComparer<T>.Default;
int h = 6551;
foreach (T t in list) {
h ^= (h << 5) ^ cmp.GetHashCode(t);
}
return h;
}
#if !CLR2
[Pure]
#endif
internal static bool ListEquals<T>(this ICollection<T> first, ICollection<T> second) {
if (first.Count != second.Count) {
return false;
}
var cmp = EqualityComparer<T>.Default;
var f = first.GetEnumerator();
var s = second.GetEnumerator();
while (f.MoveNext()) {
s.MoveNext();
if (!cmp.Equals(f.Current, s.Current)) {
return false;
}
}
return true;
}
internal static IEnumerable<U> Select<T, U>(this IEnumerable<T> enumerable, Func<T, U> select) {
foreach (T t in enumerable) {
yield return select(t);
}
}
// Name needs to be different so it doesn't conflict with Enumerable.Select
internal static U[] Map<T, U>(this ICollection<T> collection, Func<T, U> select) {
int count = collection.Count;
U[] result = new U[count];
count = 0;
foreach (T t in collection) {
result[count++] = select(t);
}
return result;
}
internal static IEnumerable<T> Where<T>(this IEnumerable<T> enumerable, Func<T, bool> where) {
foreach (T t in enumerable) {
if (where(t)) {
yield return t;
}
}
}
internal static bool Any<T>(this IEnumerable<T> source, Func<T, bool> predicate) {
foreach (T element in source) {
if (predicate(element)) {
return true;
}
}
return false;
}
internal static bool All<T>(this IEnumerable<T> source, Func<T, bool> predicate) {
foreach (T element in source) {
if (!predicate(element)) {
return false;
}
}
return true;
}
internal static T[] RemoveFirst<T>(this T[] array) {
T[] result = new T[array.Length - 1];
Array.Copy(array, 1, result, 0, result.Length);
return result;
}
internal static T[] RemoveLast<T>(this T[] array) {
T[] result = new T[array.Length - 1];
Array.Copy(array, 0, result, 0, result.Length);
return result;
}
internal static T[] AddFirst<T>(this IList<T> list, T item) {
T[] res = new T[list.Count + 1];
res[0] = item;
list.CopyTo(res, 1);
return res;
}
internal static T[] AddLast<T>(this IList<T> list, T item) {
T[] res = new T[list.Count + 1];
list.CopyTo(res, 0);
res[list.Count] = item;
return res;
}
internal static T First<T>(this IEnumerable<T> source) {
var list = source as IList<T>;
if (list != null) {
return list[0];
}
using (var e = source.GetEnumerator()) {
if (e.MoveNext()) return e.Current;
}
throw new InvalidOperationException();
}
internal static T Last<T>(this IList<T> list) {
return list[list.Count - 1];
}
internal static T[] Copy<T>(this T[] array) {
T[] copy = new T[array.Length];
Array.Copy(array, copy, array.Length);
return copy;
}
}
internal static class EmptyReadOnlyCollection<T> {
internal static ReadOnlyCollection<T> Instance = new TrueReadOnlyCollection<T>(new T[0]);
}
}

View File

@@ -0,0 +1,97 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
#if CLR2
using Microsoft.Scripting.Ast;
#else
using System.Linq.Expressions;
#endif
#if SILVERLIGHT
using System.Core;
#endif
using System.Collections.Generic;
using System.Diagnostics;
namespace System.Dynamic.Utils {
// Will be replaced with CLRv4 managed contracts
internal static class ContractUtils {
internal static Exception Unreachable {
get {
Debug.Assert(false, "Unreachable");
return new InvalidOperationException("Code supposed to be unreachable");
}
}
internal static void Requires(bool precondition) {
if (!precondition) {
throw new ArgumentException(Strings.MethodPreconditionViolated);
}
}
internal static void Requires(bool precondition, string paramName) {
Debug.Assert(!string.IsNullOrEmpty(paramName));
if (!precondition) {
throw new ArgumentException(Strings.InvalidArgumentValue, paramName);
}
}
internal static void RequiresNotNull(object value, string paramName) {
Debug.Assert(!string.IsNullOrEmpty(paramName));
if (value == null) {
throw new ArgumentNullException(paramName);
}
}
internal static void RequiresNotEmpty<T>(ICollection<T> collection, string paramName) {
RequiresNotNull(collection, paramName);
if (collection.Count == 0) {
throw new ArgumentException(Strings.NonEmptyCollectionRequired, paramName);
}
}
/// <summary>
/// Requires the range [offset, offset + count] to be a subset of [0, array.Count].
/// </summary>
/// <exception cref="ArgumentNullException">Array is <c>null</c>.</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count are out of range.</exception>
internal static void RequiresArrayRange<T>(IList<T> array, int offset, int count, string offsetName, string countName) {
Debug.Assert(!string.IsNullOrEmpty(offsetName));
Debug.Assert(!string.IsNullOrEmpty(countName));
Debug.Assert(array != null);
if (count < 0) throw new ArgumentOutOfRangeException(countName);
if (offset < 0 || array.Count - offset < count) throw new ArgumentOutOfRangeException(offsetName);
}
/// <summary>
/// Requires the array and all its items to be non-null.
/// </summary>
internal static void RequiresNotNullItems<T>(IList<T> array, string arrayName) {
Debug.Assert(arrayName != null);
RequiresNotNull(array, arrayName);
for (int i = 0; i < array.Count; i++) {
if (array[i] == null) {
throw new ArgumentNullException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}[{1}]", arrayName, i));
}
}
}
}
}

View File

@@ -0,0 +1,25 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// moved to mscorlib.dll in Full 4.5. In SL5, we can't because it ships first
// so we defer that for SL6. For now, we keep the current location (in SL5)
// For Windows Phone 8 move it to mscorlib
#if SILVERLIGHT && !FEATURE_NETCORE
using System;
namespace System.Runtime.CompilerServices
{
/// <summary>
/// Indicates that a method is an extension method, or that a class or assembly contains extension methods.
/// </summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
public sealed class ExtensionAttribute : Attribute { }
}
#else
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.ExtensionAttribute))]
#endif

View File

@@ -0,0 +1,282 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
namespace System {
/// <summary>
/// Encapsulates a method that has nine parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);
/// <summary>
/// Encapsulates a method that has ten parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);
/// <summary>
/// Encapsulates a method that has eleven parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);
/// <summary>
/// Encapsulates a method that has twelve parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12);
/// <summary>
/// Encapsulates a method that has thirteen parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13);
/// <summary>
/// Encapsulates a method that has fourteen parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T14">The type of the fourteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg14">The fourteenth parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14);
/// <summary>
/// Encapsulates a method that has fifteen parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T14">The type of the fourteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T15">The type of the fifteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg14">The fourteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg15">The fifteenth parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
/// <summary>
/// Encapsulates a method that has sixteen parameters and returns a value of the type specified by the TResult parameter.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T5">The type of the fifth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T6">The type of the sixth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T7">The type of the seventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T8">The type of the eighth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T9">The type of the ninth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T10">The type of the tenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T11">The type of the eleventh parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T12">The type of the twelfth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T13">The type of the thirteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T14">The type of the fourteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T15">The type of the fifteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T16">The type of the sixteenth parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <param name="arg3">The third parameter of the method that this delegate encapsulates.</param>
/// <param name="arg4">The fourth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg5">The fifth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg6">The sixth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg7">The seventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg8">The eighth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg9">The ninth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg10">The tenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg11">The eleventh parameter of the method that this delegate encapsulates.</param>
/// <param name="arg12">The twelfth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg13">The thirteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg14">The fourteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg15">The fifteenth parameter of the method that this delegate encapsulates.</param>
/// <param name="arg16">The sixteenth parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes")]
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, in T16, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
}

View File

@@ -0,0 +1,53 @@

/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
#if CLR2
using Microsoft.Scripting.Ast;
using Microsoft.Scripting.Utils;
#else
using System.Linq.Expressions;
#endif
using System.Collections.Generic;
namespace System.Dynamic.Utils {
// Miscellaneous helpers that don't belong anywhere else
internal static class Helpers {
internal static T CommonNode<T>(T first, T second, Func<T, T> parent) where T : class {
var cmp = EqualityComparer<T>.Default;
if (cmp.Equals(first, second)) {
return first;
}
var set = new Set<T>(cmp);
for (T t = first; t != null; t = parent(t)) {
set.Add(t);
}
for (T t = second; t != null; t = parent(t)) {
if (set.Contains(t)) {
return t;
}
}
return null;
}
internal static void IncrementCount<T>(T key, Dictionary<T, int> dict) {
int count;
dict.TryGetValue(key, out count);
dict[key] = count + 1;
}
}
}

View File

@@ -0,0 +1,33 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
namespace System.Runtime.CompilerServices {
/// <summary>
/// An interface to represent values of runtime variables.
/// </summary>
public interface IRuntimeVariables {
/// <summary>
/// Count of the variables.
/// </summary>
int Count { get; }
/// <summary>
/// An indexer to get/set the values of the runtime variables.
/// </summary>
/// <param name="index">An index of the runtime variable.</param>
/// <returns>The value of the runtime variable.</returns>
object this[int index] { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace System.Dynamic.Utils {
internal sealed class ReferenceEqualityComparer<T> : IEqualityComparer<T> {
internal static readonly ReferenceEqualityComparer<T> Instance = new ReferenceEqualityComparer<T>();
private ReferenceEqualityComparer() { }
public bool Equals(T x, T y) {
return object.ReferenceEquals(x, y);
}
public int GetHashCode(T obj) {
return RuntimeHelpers.GetHashCode(obj);
}
}
}

View File

@@ -0,0 +1,63 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
namespace System.Runtime.CompilerServices {
/// <summary>
/// Holds a reference to a value.
/// </summary>
/// <typeparam name="T">The type of the value that the <see cref = "StrongBox{T}"></see> references.</typeparam>
public class StrongBox<T> : IStrongBox {
/// <summary>
/// Gets the strongly typed value associated with the <see cref = "StrongBox{T}"></see>
/// <remarks>This is explicitly exposed as a field instead of a property to enable loading the address of the field.</remarks>
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
public T Value;
/// <summary>
/// Initializes a new StrongBox which can receive a value when used in a reference call.
/// </summary>
public StrongBox() {
}
/// <summary>
/// Initializes a new <see cref = "StrongBox{T}"></see> with the specified value.
/// </summary>
/// <param name="value">A value that the <see cref = "StrongBox{T}"></see> will reference.</param>
public StrongBox(T value) {
Value = value;
}
object IStrongBox.Value {
get {
return Value;
}
set {
Value = (T)value;
}
}
}
/// <summary>
/// Defines a property for accessing the value that an object references.
/// </summary>
public interface IStrongBox {
/// <summary>
/// Gets or sets the value the object references.
/// </summary>
object Value { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Dynamic.Utils;
namespace System.Runtime.CompilerServices {
sealed class TrueReadOnlyCollection<T> : ReadOnlyCollection<T> {
/// <summary>
/// Creates instnace of TrueReadOnlyCollection, wrapping passed in array.
/// !!! DOES NOT COPY THE ARRAY !!!
/// </summary>
internal TrueReadOnlyCollection(T[] list)
: base(list) {
}
}
}

View File

@@ -0,0 +1,113 @@
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
namespace System.Dynamic.Utils {
// Extensions on System.Type and friends
internal static class TypeExtensions {
/// <summary>
/// Creates a closed delegate for the given (dynamic)method.
/// </summary>
internal static Delegate CreateDelegate(this MethodInfo methodInfo, Type delegateType, object target) {
Debug.Assert(methodInfo != null && delegateType != null);
var dm = methodInfo as DynamicMethod;
if (dm != null) {
return dm.CreateDelegate(delegateType, target);
} else {
return Delegate.CreateDelegate(delegateType, target, methodInfo);
}
}
internal static Type GetReturnType(this MethodBase mi) {
return (mi.IsConstructor) ? mi.DeclaringType : ((MethodInfo)mi).ReturnType;
}
private static readonly CacheDict<MethodBase, ParameterInfo[]> _ParamInfoCache = new CacheDict<MethodBase, ParameterInfo[]>(75);
internal static ParameterInfo[] GetParametersCached(this MethodBase method) {
ParameterInfo[] pis;
var pic = _ParamInfoCache;
if (!pic.TryGetValue(method, out pis)) {
pis = method.GetParameters();
Type t = method.DeclaringType;
if (t != null && TypeUtils.CanCache(t)) {
pic[method] = pis;
}
}
return pis;
}
// Expression trees/compiler just use IsByRef, why do we need this?
// (see LambdaCompiler.EmitArguments for usage in the compiler)
internal static bool IsByRefParameter(this ParameterInfo pi) {
// not using IsIn/IsOut properties as they are not available in Silverlight:
if (pi.ParameterType.IsByRef) return true;
return (pi.Attributes & (ParameterAttributes.Out)) == ParameterAttributes.Out;
}
// Returns the matching method if the parameter types are reference
// assignable from the provided type arguments, otherwise null.
internal static MethodInfo GetMethodValidated(
this Type type,
string name,
BindingFlags bindingAttr,
Binder binder,
Type[] types,
ParameterModifier[] modifiers) {
var method = type.GetMethod(name, bindingAttr, binder, types, modifiers);
return method.MatchesArgumentTypes(types) ? method : null;
}
/// <summary>
/// Returns true if the method's parameter types are reference assignable from
/// the argument types, otherwise false.
///
/// An example that can make the method return false is that
/// typeof(double).GetMethod("op_Equality", ..., new[] { typeof(double), typeof(int) })
/// returns a method with two double parameters, which doesn't match the provided
/// argument types.
/// </summary>
/// <returns></returns>
private static bool MatchesArgumentTypes(this MethodInfo mi, Type[] argTypes) {
if (mi == null || argTypes == null) {
return false;
}
var ps = mi.GetParameters();
if (ps.Length != argTypes.Length) {
return false;
}
for (int i = 0; i < ps.Length; i++) {
if (!TypeUtils.AreReferenceAssignable(ps[i].ParameterType, argTypes[i])) {
return false;
}
}
return true;
}
}
}