Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,50 @@
//
// System.Runtime.CompilerServices.AccessedThroughPropertyAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// (C) Copyright, Ximian Inc.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[AttributeUsage (AttributeTargets.Field)]
[ComVisible(true)]
public sealed class AccessedThroughPropertyAttribute : Attribute
{
string name;
public AccessedThroughPropertyAttribute (string propertyName)
{
name = propertyName;
}
public string PropertyName {
get { return name; }
}
}
}

View File

@ -0,0 +1,44 @@
//
// AsyncStateMachineAttribute.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2012 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
namespace System.Runtime.CompilerServices
{
[AttributeUsage (AttributeTargets.Method, Inherited = false)]
[Serializable]
public sealed class AsyncStateMachineAttribute : StateMachineAttribute
{
public AsyncStateMachineAttribute (Type stateMachineType)
: base (stateMachineType)
{
}
}
}
#endif

View File

@ -0,0 +1,112 @@
//
// AsyncTaskMethodBuilder.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2011 Novell, Inc (http://www.novell.com)
// Copyright (C) 2011 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System.Threading;
using System.Threading.Tasks;
namespace System.Runtime.CompilerServices
{
public struct AsyncTaskMethodBuilder
{
readonly Task<object> task;
IAsyncStateMachine stateMachine;
private AsyncTaskMethodBuilder (Task<object> task)
{
this.task = task;
this.stateMachine = null;
}
public Task Task {
get {
return task;
}
}
public void AwaitOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : INotifyCompletion
where TStateMachine : IAsyncStateMachine
{
var action = new Action (stateMachine.MoveNext);
awaiter.OnCompleted (action);
}
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
where TStateMachine : IAsyncStateMachine
{
var action = new Action (stateMachine.MoveNext);
awaiter.UnsafeOnCompleted (action);
}
public static AsyncTaskMethodBuilder Create ()
{
var task = new Task<object> (TaskActionInvoker.Promise, null, CancellationToken.None, TaskCreationOptions.None, null);
task.SetupScheduler (TaskScheduler.Current);
return new AsyncTaskMethodBuilder (task);
}
public void SetException (Exception exception)
{
if (Task.TrySetException (new AggregateException (exception), exception is OperationCanceledException, true))
return;
throw new InvalidOperationException ("The task has already completed");
}
public void SetStateMachine (IAsyncStateMachine stateMachine)
{
if (stateMachine == null)
throw new ArgumentNullException ("stateMachine");
if (this.stateMachine != null)
throw new InvalidOperationException ("The state machine was previously set");
this.stateMachine = stateMachine;
}
public void SetResult ()
{
if (!task.TrySetResult (null))
throw new InvalidOperationException ("The task has already completed");
}
public void Start<TStateMachine> (ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
{
if (stateMachine == null)
throw new ArgumentNullException ("stateMachine");
stateMachine.MoveNext ();
}
}
}
#endif

View File

@ -0,0 +1,112 @@
//
// AsyncTaskMethodBuilder_T.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2011 Novell, Inc (http://www.novell.com)
// Copyright (C) 2011 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System.Threading;
using System.Threading.Tasks;
namespace System.Runtime.CompilerServices
{
public struct AsyncTaskMethodBuilder<TResult>
{
readonly Task<TResult> task;
IAsyncStateMachine stateMachine;
private AsyncTaskMethodBuilder (Task<TResult> task)
{
this.task = task;
this.stateMachine = null;
}
public Task<TResult> Task {
get {
return task;
}
}
public void AwaitOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : INotifyCompletion
where TStateMachine : IAsyncStateMachine
{
var action = new Action (stateMachine.MoveNext);
awaiter.OnCompleted (action);
}
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
where TStateMachine : IAsyncStateMachine
{
var action = new Action (stateMachine.MoveNext);
awaiter.UnsafeOnCompleted (action);
}
public static AsyncTaskMethodBuilder<TResult> Create ()
{
var task = new Task<TResult> (TaskActionInvoker.Promise, null, CancellationToken.None, TaskCreationOptions.None, null);
task.SetupScheduler (TaskScheduler.Current);
return new AsyncTaskMethodBuilder<TResult> (task);
}
public void SetException (Exception exception)
{
if (Task.TrySetException (new AggregateException (exception), exception is OperationCanceledException, true))
return;
throw new InvalidOperationException ("The task has already completed");
}
public void SetStateMachine (IAsyncStateMachine stateMachine)
{
if (stateMachine == null)
throw new ArgumentNullException ("stateMachine");
if (this.stateMachine != null)
throw new InvalidOperationException ("The state machine was previously set");
this.stateMachine = stateMachine;
}
public void SetResult (TResult result)
{
if (!task.TrySetResult (result))
throw new InvalidOperationException ("The task has already completed");
}
public void Start<TStateMachine> (ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
{
if (stateMachine == null)
throw new ArgumentNullException ("stateMachine");
stateMachine.MoveNext ();
}
}
}
#endif

View File

@ -0,0 +1,111 @@
//
// AsyncVoidMethodBuilder.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2011 Novell, Inc (http://www.novell.com)
// Copyright (C) 2011 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System.Threading;
namespace System.Runtime.CompilerServices
{
public struct AsyncVoidMethodBuilder
{
static readonly SynchronizationContext null_context = new SynchronizationContext ();
readonly SynchronizationContext context;
IAsyncStateMachine stateMachine;
private AsyncVoidMethodBuilder (SynchronizationContext context)
{
this.context = context;
this.stateMachine = null;
}
public void AwaitOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : INotifyCompletion
where TStateMachine : IAsyncStateMachine
{
var action = new Action (stateMachine.MoveNext);
awaiter.OnCompleted (action);
}
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
where TStateMachine : IAsyncStateMachine
{
var action = new Action (stateMachine.MoveNext);
awaiter.UnsafeOnCompleted (action);
}
public static AsyncVoidMethodBuilder Create ()
{
var ctx = SynchronizationContext.Current ?? null_context;
ctx.OperationStarted ();
return new AsyncVoidMethodBuilder (ctx);
}
public void SetException (Exception exception)
{
if (exception == null)
throw new ArgumentNullException ("exception");
try {
context.Post (l => { throw (Exception) l; }, exception);
} finally {
SetResult ();
}
}
public void SetStateMachine (IAsyncStateMachine stateMachine)
{
if (stateMachine == null)
throw new ArgumentNullException ("stateMachine");
if (this.stateMachine != null)
throw new InvalidOperationException ("The state machine was previously set");
this.stateMachine = stateMachine;
}
public void SetResult ()
{
context.OperationCompleted ();
}
public void Start<TStateMachine> (ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
{
if (stateMachine == null)
throw new ArgumentNullException ("stateMachine");
stateMachine.MoveNext ();
}
}
}
#endif

View File

@ -0,0 +1,39 @@
//
// System.Runtime.CompilerServices.CallConvCdecl.cs
//
// Author: Zoltan Varga (vargaz@freemail.hu)
//
// (C) Copyright, Ximian Inc.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[ComVisible(true)]
public class CallConvCdecl {
}
}

View File

@ -0,0 +1,39 @@
//
// System.Runtime.CompilerServices.CallConvFastcall.cs
//
// Author: Zoltan Varga (vargaz@freemail.hu)
//
// (C) Copyright, Ximian Inc.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[ComVisible(true)]
public class CallConvFastcall {
}
}

View File

@ -0,0 +1,39 @@
//
// System.Runtime.CompilerServices.CallConvStdcall.cs
//
// Author: Zoltan Varga (vargaz@freemail.hu)
//
// (C) Copyright, Ximian Inc.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[ComVisible(true)]
public class CallConvStdcall {
}
}

View File

@ -0,0 +1,39 @@
//
// System.Runtime.CompilerServices.CallConvThiscall.cs
//
// Author: Zoltan Varga (vargaz@freemail.hu)
//
// (C) Copyright, Ximian Inc.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[ComVisible(true)]
public class CallConvThiscall {
}
}

View File

@ -0,0 +1,39 @@
//
// CallerFilePathAttribute.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2012 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
namespace System.Runtime.CompilerServices
{
[AttributeUsageAttribute (AttributeTargets.Parameter, Inherited = false)]
public sealed class CallerFilePathAttribute : Attribute
{
}
}
#endif

View File

@ -0,0 +1,39 @@
//
// CallerLineNumberAttribute.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2012 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
namespace System.Runtime.CompilerServices
{
[AttributeUsageAttribute (AttributeTargets.Parameter, Inherited = false)]
public sealed class CallerLineNumberAttribute : Attribute
{
}
}
#endif

View File

@ -0,0 +1,39 @@
//
// CallerMemberNameAttribute.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2012 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
namespace System.Runtime.CompilerServices
{
[AttributeUsageAttribute (AttributeTargets.Parameter, Inherited = false)]
public sealed class CallerMemberNameAttribute : Attribute
{
}
}
#endif

View File

@ -0,0 +1,310 @@
2010-06-04 Jb Evain <jbevain@novell.com>
* ConditionalWeakTable.cs: make sure we use positive indexes.
2010-05-11 Rodrigo Kumpera <rkumpera@novell.com>
* ConditionalWeakTable.cs: Implement simple open addressing
hash table with linear probing. We use a prime sized table
for an easy hashing and a target load capacity of 70%.
On a synthetic benchmark, a load factor of 70% did not cause
significant performance degradation over 60% as would be expected.
2010-05-06 Rodrigo Kumpera <rkumpera@novell.com>
* ConditionalWeakTable.cs: Discard old broken version. New
version user proper runtime support. Currently it performs
linear search over the keys, which is dog slow but it's a
good start.
2010-03-18 Sebastien Pouliot <sebastien@ximian.com>
* ConditionalWeakTable.cs:
* ReferenceAssemblyAttribute.cs:
* TypeForwardedFromAttribute.cs:
Build them into Moonlight too (SL4)
Fri Feb 12 19:03:11 CET 2010 Paolo Molaro <lupus@ximian.com>
* ReferenceAssemblyAttribute.cs: new attribute in 4.0.
Fri Feb 12 18:39:57 CET 2010 Paolo Molaro <lupus@ximian.com>
* RuntimeHelpers.cs: implemented EnsureSufficientExecutionStack ().
2010-01-05 Rodrigo Kumpera <rkumpera@novell.com>
* DateTimeConstantAttribute.cs: Add internal Ticks property.
2009-11-08 Miguel de Icaza <miguel@novell.com>
* Use the ConditionalWeakTable.cs implementation from MEF, it
needs a little bit of work (see the comment on the file, and the
test suite that shows the problem).
This code is MS-PL
2009-10-15 Sebastien Pouliot <sebastien@ximian.com>
* RuntimeHelpers.cs: Add missing validations
2009-09-23 Marek Safar <marek.safar@gmail.com>
* MethodImplOptions.cs: Add NoOptimization.
2009-08-11 Jérémie Laval <jeremie.laval@gmail.com>
* TypeForwardedFromAttribute.cs: Add BOOTSTRAP_NET_4_0.
2009-07-02 Marek Safar <marek.safar@gmail.com>
* ConditionalWeakTable.cs: New file.
2009-06-10 Marek Safar <marek.safar@gmail.com>
* InternalsVisibleToAttribute.cs: Updated to 2.0 SP2.
* TypeForwardedFromAttribute.cs: New file.
2008-04-02 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* IndexerNameAttribute.cs
* MethodImplAttribute.cs: Fix parameter names
2007-08-28 Zoltan Varga <vargaz@gmail.com>
* RuntimeHelpers.cs: Implement RunModuleConstructor ().
2007-01-22 Miguel de Icaza <miguel@novell.com>
* RuntimeHelpers.cs: The constrained methods are safe not throwing
exceptions. The MonoTODO is enough, no need to throw
2006-11-01 Sebastien Pouliot <sebastien@ximian.com>
* RuntimeWrappedException.cs: Add missing GetObjectData method.
2006-08-22 Miguel de Icaza <miguel@novell.com>
* MethodImplOptions.cs, MethodCodeType.cs, LoadHint.cs,
CompilationRelaxations.cs: Add serializable.
2005-12-07 Zoltan Varga <vargaz@gmail.com>
* NewConstraintAttribute.cs: Removed.
2005-11-15 Zoltan Varga <vargaz@gmail.com>
* RuntimeHelpers.cs: Really fix build.
* RuntimeHelper.cs: Fix build.
* RuntimeHelpers.cs: Make this class static in 2.0.
* NewConstraintAttribute.cs: Re-add this as gmcs depends on it.
* RuntimeHelpers.cs: Net 2.0 RTM updates.
* NewConstraintAttribute.cs SuppressMergeCheckAttribute.cs: Remove
obsolete net 2.0 classes.
2005-10-26 Zoltan Varga <vargaz@gmail.com>
* IsCopyConstructed.cs: New file.
* TypeForwardedToAttribute.cs SuppressIldasmAttribute.cs TypeForwardedToAttribute.cs: Add new net 2.0 classes.
* NGenHint.cs NGenAttribute.cs: Remove obsolete net 2.0 classes.
* *.cs: Add/remove net 2.0 attributes.
2005-10-07 Zoltan Varga <vargaz@gmail.com>
* RuntimeCompatibilityAttribute.cs RuntimeWrappedException.cs: New files.
2005-08-09 Zoltan Varga <vargaz@freemail.hu>
* SpecialNameAttribute.cs: New file.
2005-08-06 Gert Driesen <drieseng@users.sourceforge.net>
* DecimalConstantAttribute.cs: Only mark ctor not CLSCompliant on 2.0
profile to match MS.NET.
2005-08-03 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* InternalsVisibleToAttribute.cs: Add BOOTSTRAP_NET_2_0
directive, since we need it to implement friend assemblies
in gmcs.
2005-06-06 Zoltan Varga <vargaz@freemail.hu>
* RuntimeHelpers.cs: Add some missing 2.0 attributes.
2005-02-12 Marek Safar <marek.safar@seznam.cz>
* CompilationRelaxationsAttribute.cs,
* DependencyAttribute.cs,
* FixedBufferAttribute.cs,
* InternalsVisibleToAttribute.cs,
* RequiredAttributeAttribute.cs,
* StringFreezingAttribute.cs: Fix NET_2_0 attributes.
* CustomConstantAttribute.cs,
* IndexerNameAttribute.cs: Fix AttributeUsage flags.
2005-01-04 Sebastien Pouliot <sebastien@ximian.com>
* IsVolatile.cs: Fix errors in corcompare (HEAD versus 1.1 and 2.0).
It seems that the file was replaced for 2.0, which broke 1.1 build and
was then fixed (build-wise) but introduced corcompare errors on both
1.1 and 2.0. The MONO-1-0 branch wasn't affected.
2004-10-15 Zoltan Varga <vargaz@freemail.hu>
* IsVolatile.cs: Remove #ifdef NET_2_0.
2004-10-04 Zoltan Varga <vargaz@freemail.hu>
* NGenAttribute.cs: Add ComVisible (false).
* *.cs: Add some more 2.0 stuff.
* *.cs: Add more 2.0 stuff.
* MethodImplOptions.cs MethodCodeType.cs RuntimeHelpers.cs DecimalConstantAttribute.cs: Add 2.0 stuff.
* CompilationRelaxationsAttribute.cs DecimalConstantAttribute.cs MethodCodeType.cs MethodImplOptions.cs NewConstraintAttribute.cs: Add 2.0 stuff.
* *.cs: Add new 2.0 classes.
2004-06-30 Ben Maurer <bmaurer@ximian.com>
* RuntimeHelpers.cs: OffsetToStringData is now and intrinsic,
so we dont have to optimize it. Thus, it is now just an icall.
2004-06-15 Gert Driesen <drieseng@users.sourceforge.net>
* MethodImplAttribute.cs: changed field name to fix serialization
compatibility with MS.NET
2004-05-19 Gert Driesen <drieseng@users.sourceforge.net>
* CustomConstantAttribute.cs
* DateTimeconstantAttribute.cs
* DecimalConstantAttribute.cs
* IDispatchConstantAttribute.cs
* IUnknownConstantAttribute.cs
* MethodImplAttribute.cs
* RequiredAttributeAttribute.cs: now that Inherited is
false by default on AttributeUsageAttribute (as it
should be) we need to explicitly set Inherited to false
for those attributes where it should be false.
2004-03-30 Martin Baulig <martin@ximian.com>
* NewConstraintAttribute.cs: New file.
2003-11-18 Zoltan Varga <vargaz@freemail.hu>
* RuntimeHelpers.cs (Equals): Track changes to ValueType.
2003-11-15 Zoltan Varga <vargaz@freemail.hu>
* MethodImplOptions.cs MethodCodeType.cs: Add [Flags].
Tue Jul 29 12:15:13 CEST 2003 Paolo Molaro <lupus@ximian.com>
* RuntimeHelpers.cs: pass the handles values o icalls, to avoid
special cases in some call conventions.
2003-06-18 Zoltan Varga <vargaz@freemail.hu>
* RuntimeHelpers.cs: Wrap NET 1.1 methods with #if NET_1_1.
2003-04-27 Zoltan Varga <vargaz@freemail.hu>
* RuntimeHelpers.cs: Remove workaround for bug #41550 since it is fixed
now.
2003-04-19 Zoltan Varga <vargaz@freemail.hu>
* RuntimeHelpers.cs: Enable the last changes again since they no
longer break the corlib_cmp build.
2003-04-18 Zoltan Varga <vargaz@freemail.hu>
* RuntimeHelpers.cs: Back out these changes as they break the windows
build.
2003-04-18 Zoltan Varga <vargaz@freemail.hu>
* RuntimeHelpers.cs: Implement Equals and GetHashCode methods from
NET 1.1.
2002-09-21 Zoltan Varga <vargaz@freemail.hu>
* CallConvCdecl.cs: new file
* CallConvFastcall.cs: new file
* CallConvThiscall.cs: new file
* CallConvStdcall.cs: new file
* RuntimeHelpers.cs: Implemented OffsetToStringData, GetObjectValue and
RunClassConstructor.
2002-08-23 Nick Drochak <ndrochak@gol.com>
* IsVolatile.cs: No _public_ members, but if we don't put a private
ctor, the complier will give us a public one.
2002-08-23 Nick Drochak <ndrochak@gol.com>
* IsVolatile.cs: This class has no members, not even an empty ctor.
2002-07-24 Duncan Mak <duncan@ximian.com>
* AccessedThroughPropertyAttribute.cs:
* CompilationRelaxationsAttribute.cs:
* CompilerGlobalScopeAttribute.cs:
* DateTimeConstantAttribute.cs:
* DecimalConstantAttribute.cs:
* IDispatchConstantAttribute.cs:
* IsVolatile.cs:
* IUnknownConstantAttribute.cs:
* RequiredAttributeAttribute.cs: Visibility changes.
2002-07-23 Duncan Mak <duncan@ximian.com>
* AccessedThroughPropertyAttribute.cs:
* CompilationRelaxationsAttribute.cs:
* CompilerGlobalScopeAttribute.cs:
* CustomConstantAttribute.cs:
* DateTimeConstantAttribute.cs:
* DecimalConstantAttribute.cs:
* DiscardableAttribute.cs:
* IDispatchConstantAttribute.cs:
* IUnknownConstantAttribute.cs:
* RequiredAttributeAttribute.cs: Added all the missing Attributes
* IsVolatile.cs: Added to CVS.
* MethodImplOptions.cs: Added the PreserveSig flag.
2002-04-15 Dan Lewis <dihlewis@yahoo.co.uk>
* MethodImplAttribute.cs: added constructor usage.
Fri Feb 22 15:36:19 CET 2002 Paolo Molaro <lupus@ximian.com>
* RuntimeHelpers.cs: added OffsetToStringData() property.
Mon Nov 5 19:50:11 CET 2001 Paolo Molaro <lupus@ximian.com>
* RuntimeHelpers.cs: make InitializeArray an internalcall.
2001-07-18 Michael Lambert <michaellambert@email.com>
* MethodCodeType.cs, MethodImplOptions.cs: Add.

View File

@ -0,0 +1,39 @@
//
// System.Runtime.CompilerServices.CompilationRelaxations.cs
//
// Author: Zoltan Vargaz (vargaz@gmail.com)
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[Flags]
[ComVisible (true)]
[Serializable]
public enum CompilationRelaxations {
NoStringInterning = 8
}
}

View File

@ -0,0 +1,57 @@
//
// System.Runtime.CompilerServices.CompilationRelaxationsAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// (C) Copyright, Ximian Inc.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Module |
AttributeTargets.Class | AttributeTargets.Method)]
[ComVisible(true)]
[Serializable]
public class CompilationRelaxationsAttribute : Attribute
{
int relax;
public CompilationRelaxationsAttribute (int relaxations)
{
relax = relaxations;
}
public CompilationRelaxationsAttribute (CompilationRelaxations relaxations)
{
relax = (int)relaxations;
}
public int CompilationRelaxations {
get { return relax; }
}
}
}

View File

@ -0,0 +1,40 @@
//
// System.Runtime.CompilerServices.CompilerGeneratedAttribute
//
// Author: Zoltan Varga (vargaz@gmail.com)
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Runtime.CompilerServices {
[AttributeUsage (AttributeTargets.All)]
[Serializable]
public sealed class CompilerGeneratedAttribute : Attribute
{
public CompilerGeneratedAttribute ()
{
}
}
}

View File

@ -0,0 +1,44 @@
//
// System.Runtime.CompilerServices.CompilerGlobalScopeAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// (C) Copyright, Ximian Inc.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[AttributeUsage (AttributeTargets.Class)] [Serializable]
[ComVisible(true)]
public class CompilerGlobalScopeAttribute : Attribute
{
public CompilerGlobalScopeAttribute ()
{
}
}
}

View File

@ -0,0 +1,35 @@
//
// System.Runtime.CompilerServices.CompilerMarshalOverride
//
// Author: Zoltan Varga (vargaz@gmail.com)
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Runtime.CompilerServices {
public static class CompilerMarshalOverride
{
}
}

View File

@ -0,0 +1,224 @@
//
// ConditionalWeakTable.cs
//
// Author:
// Rodrigo Kumpera (rkumpera@novell.com)
//
// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections;
namespace System.Runtime.CompilerServices
{
internal struct Ephemeron
{
internal object key;
internal object value;
}
/*
TODO:
The runtime need to inform the table about how many entries were expired.
Compact the table when there are too many tombstones.
Rehash to a smaller size when there are too few entries.
Change rehash condition check to use non-fp code.
Look into using quatratic probing/double hashing to reduce clustering problems.
Make reads and non-expanding writes (add/remove) lock free.
*/
public sealed class ConditionalWeakTable<TKey, TValue>
where TKey : class
where TValue : class
{
const int INITIAL_SIZE = 13;
const float LOAD_FACTOR = 0.7f;
Ephemeron[] data;
object _lock = new object ();
int size;
public delegate TValue CreateValueCallback (TKey key);
public ConditionalWeakTable ()
{
data = new Ephemeron [INITIAL_SIZE];
GC.register_ephemeron_array (data);
}
/*LOCKING: _lock must be held*/
void Rehash () {
uint newSize = (uint)HashPrimeNumbers.ToPrime ((data.Length << 1) | 1);
//Console.WriteLine ("--- resizing from {0} to {1}", data.Length, newSize);
Ephemeron[] tmp = new Ephemeron [newSize];
GC.register_ephemeron_array (tmp);
size = 0;
for (int i = 0; i < data.Length; ++i) {
object key = data[i].key;
object value = data[i].value;
if (key == null || key == GC.EPHEMERON_TOMBSTONE)
continue;
int len = tmp.Length;
int idx, initial_idx;
int free_slot = -1;
idx = initial_idx = (RuntimeHelpers.GetHashCode (key) & int.MaxValue) % len;
do {
object k = tmp [idx].key;
//keys might be GC'd during Rehash
if (k == null || k == GC.EPHEMERON_TOMBSTONE) {
free_slot = idx;
break;
}
if (++idx == len) //Wrap around
idx = 0;
} while (idx != initial_idx);
tmp [free_slot].key = key;
tmp [free_slot].value = value;
++size;
}
data = tmp;
}
public void Add (TKey key, TValue value)
{
if (key == default (TKey))
throw new ArgumentNullException ("Null key", "key");
lock (_lock) {
if (size >= data.Length * LOAD_FACTOR)
Rehash ();
int len = data.Length;
int idx,initial_idx;
int free_slot = -1;
idx = initial_idx = (RuntimeHelpers.GetHashCode (key) & int.MaxValue) % len;
do {
object k = data [idx].key;
if (k == null) {
if (free_slot == -1)
free_slot = idx;
break;
} else if (k == GC.EPHEMERON_TOMBSTONE && free_slot == -1) { //Add requires us to check for dupes :(
free_slot = idx;
} else if (k == key) {
throw new ArgumentException ("Key already in the list", "key");
}
if (++idx == len) //Wrap around
idx = 0;
} while (idx != initial_idx);
data [free_slot].key = key;
data [free_slot].value = value;
++size;
}
}
public bool Remove (TKey key)
{
if (key == default (TKey))
throw new ArgumentNullException ("Null key", "key");
lock (_lock) {
int len = data.Length;
int idx, initial_idx;
idx = initial_idx = (RuntimeHelpers.GetHashCode (key) & int.MaxValue) % len;
do {
object k = data[idx].key;
if (k == key) {
data [idx].key = GC.EPHEMERON_TOMBSTONE;
data [idx].value = null;
--size;
return true;
}
if (k == null)
break;
if (++idx == len) //Wrap around
idx = 0;
} while (idx != initial_idx);
}
return false;
}
public bool TryGetValue (TKey key, out TValue value)
{
if (key == null)
throw new ArgumentNullException ("Null key", "key");
value = default (TValue);
lock (_lock) {
int len = data.Length;
int idx, initial_idx;
idx = initial_idx = (RuntimeHelpers.GetHashCode (key) & int.MaxValue) % len;
do {
object k = data [idx].key;
if (k == key) {
value = (TValue)data [idx].value;
return true;
}
if (k == null)
break;
if (++idx == len) //Wrap around
idx = 0;
} while (idx != initial_idx);
}
return false;
}
public TValue GetOrCreateValue (TKey key)
{
return GetValue (key, k => Activator.CreateInstance<TValue> ());
}
public TValue GetValue (TKey key, CreateValueCallback createValueCallback)
{
if (createValueCallback == null)
throw new ArgumentNullException ("Null create delegate", "createValueCallback");
TValue res;
lock (_lock) {
if (TryGetValue (key, out res))
return res;
res = createValueCallback (key);
Add (key, res);
}
return res;
}
}
}
#endif

View File

@ -0,0 +1,96 @@
//
// ConfiguredTaskAwaitable.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2011 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.ExceptionServices;
namespace System.Runtime.CompilerServices
{
public struct ConfiguredTaskAwaitable
{
public struct ConfiguredTaskAwaiter : ICriticalNotifyCompletion
{
readonly Task task;
readonly bool continueOnSourceContext;
internal ConfiguredTaskAwaiter (Task task, bool continueOnSourceContext)
{
this.task = task;
this.continueOnSourceContext = continueOnSourceContext;
}
public bool IsCompleted {
get {
return task.IsCompleted;
}
}
public void GetResult ()
{
if (!task.IsCompleted)
task.WaitCore (Timeout.Infinite, CancellationToken.None, true);
if (task.Status != TaskStatus.RanToCompletion)
ExceptionDispatchInfo.Capture (TaskAwaiter.HandleUnexpectedTaskResult (task)).Throw ();
}
public void OnCompleted (Action continuation)
{
if (continuation == null)
throw new ArgumentNullException ("continuation");
TaskAwaiter.HandleOnCompleted (task, continuation, continueOnSourceContext, true);
}
public void UnsafeOnCompleted (Action continuation)
{
if (continuation == null)
throw new ArgumentNullException ("continuation");
TaskAwaiter.HandleOnCompleted (task, continuation, continueOnSourceContext, false);
}
}
readonly ConfiguredTaskAwaiter awaiter;
internal ConfiguredTaskAwaitable (Task task, bool continueOnSourceContext)
{
awaiter = new ConfiguredTaskAwaiter (task, continueOnSourceContext);
}
public ConfiguredTaskAwaiter GetAwaiter()
{
return awaiter;
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More