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,58 @@
2008-01-15 Zoltan Varga <vargaz@gmail.com>
* SafeWaitHandle.cs: Fix some argument names to be consistent with MS.
2007-07-18 Miguel de Icaza <miguel@novell.com>
* SafeWaitHandle.cs: Do not call DangerousGetHandle here as it
throws ObjectDisposedException when the refcount reaches zero.
* SafeFileHandle.cs: Same.
2007-05-12 Jonathan Chambers <joncham@gmail.com>
* SafeWaitHandle.cs: Add internal empty
constructor for pinvoke marshalling.
2007-04-30 Dick Porter <dick@ximian.com>
* CriticalHandleZeroOrMinusOneIsInvalid.cs:
* CriticalHandleMinusOneIsInvalid.cs:
* SafeWaitHandle.cs:
* SafeHandleZeroOrMinusOneIsInvalid.cs:
* SafeHandleMinusOneIsInvalid.cs: Added ReliabilityContract
attributes to complete 2.0 profile
2007-01-13 Miguel de Icaza <miguel@novell.com>
* Add a few more missing helper classes.
2006-12-11 Miguel de Icaza <miguel@novell.com>
* SafeWaitHandle.cs: Add new.
2006-12-10 Miguel de Icaza <miguel@novell.com>
* SafeFileHandle.cs: Implement this one.
2006-12-02 Miguel de Icaza <miguel@novell.com>
* SafeFileHandle.cs: Remove the IsInvalid method, as that is
present in the base class.
2006-01-12 Ben Maurer <bmaurer@andrew.cmu.edu>
* SafeHandleZeroOrMinusOneIsInvalid.cs: Update to RTM api
* SafeFileHandle.cs: Update to RTM api
2005-08-10 Zoltan Varga <vargaz@freemail.hu>
* SafeFileHandle.cs: Make this inherit from SafeHandleZeroOrMinusOneIsInvalid.
* SafeHandleZeroOrMinusOneIsInvalid.cs: New file.
2005-01-31 Sebastien Pouliot <sebastien@ximian.com>
* SafeFileHandle.cs: Class declaration to allow compiling System.IO
and System.IO.IsolatedStorage for the NET_2_0 profile.

View File

@@ -0,0 +1,48 @@
//
// Microsoft.Win32.SafeHandles.CriticalHandleMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
// Miguel de Icaza (miguel@novell.com)
//
// Copyright (C) 2005, 2006 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;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleMinusOneIsInvalid () : base ((IntPtr) (-1)) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1);
}
}
}
}

View File

@@ -0,0 +1,47 @@
//
// Microsoft.Win32.SafeHandles.CriticalHandleZeroOrMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
// Miguel de Icaza (miguel@novell.com)
//
// Copyright (C) 2005, 2006 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;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleZeroOrMinusOneIsInvalid () : base ((IntPtr) (-1)) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1) || handle == IntPtr.Zero;
}
}
}
}

View File

@@ -0,0 +1,57 @@
//
// Microsoft.Win32.SafeHandles.SafeFileHandle
//
// Authors:
// Sebastien Pouliot <sebastien@ximian.com>
// Miguel de Icaza <miguel@novell.com>
//
// Copyright (C) 2005, 2006 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.IO;
namespace Microsoft.Win32.SafeHandles {
public sealed class SafeFileHandle : SafeHandleZeroOrMinusOneIsInvalid {
public SafeFileHandle (IntPtr preexistingHandle, bool ownsHandle) : base (ownsHandle)
{
SetHandle (preexistingHandle);
}
// This is just for marshalling
internal SafeFileHandle () : base (true)
{
}
protected override bool ReleaseHandle ()
{
MonoIOError error;
MonoIO.Close (handle, out error);
return error == MonoIOError.ERROR_SUCCESS;
}
}
}

View File

@@ -0,0 +1,47 @@
//
// Microsoft.Win32.SafeHandles.SafeHandleMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
// Miguel de Icaza (miguel@novell.com)
//
// Copyright (C) 2005, 2006 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;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class SafeHandleMinusOneIsInvalid : SafeHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleMinusOneIsInvalid (bool ownsHandle) : base ((IntPtr) 0, ownsHandle) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1);
}
}
}
}

View File

@@ -0,0 +1,46 @@
//
// Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
//
// Copyright (C) 2005 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;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleZeroOrMinusOneIsInvalid (bool ownsHandle) : base ((IntPtr) 0, ownsHandle) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1) || handle == (IntPtr) 0;
}
}
}
}

View File

@@ -0,0 +1,57 @@
//
// Microsoft.Win32.SafeHandles.SafeRegistryHandle
//
// Author
// Gonzalo Paniagua Javier (gonzalo@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.IO;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid, IDisposable {
public SafeRegistryHandle (IntPtr preexistingHandle, bool ownsHandle) : base (ownsHandle)
{
handle = preexistingHandle;
}
protected override bool ReleaseHandle ()
{
// Need to release an unmanaged pointer *only* in Windows.
if (Path.DirectorySeparatorChar == '\\')
return RegCloseKey (handle) == 0;
return true;
}
[DllImport ("advapi32.dll", CharSet = CharSet.Unicode, EntryPoint="RegCloseKey")]
static extern int RegCloseKey (IntPtr keyHandle);
}
}
#endif

View File

@@ -0,0 +1,51 @@
//
// Microsoft.Win32.SafeHandles.SafeWaitHandle
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
// Miguel de Icaza <miguel@novell.com>
//
// Copyright (C) 2005, 2006 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.IO;
using System.Threading;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public sealed class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
public SafeWaitHandle (IntPtr existingHandle, bool ownsHandle) : base (ownsHandle)
{
SetHandle (existingHandle);
}
protected override bool ReleaseHandle ()
{
NativeEventCalls.CloseEvent_internal (handle);
return true;
}
}
}