Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SafeHandle types to have public parameterless constructors and add InitHandle API #47189

Merged
5 commits merged into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ private struct ISymUnmanagedWriter
//--------------------------------------------------------------------------------------
internal sealed class PunkSafeHandle : SafeHandle
{
internal PunkSafeHandle()
public PunkSafeHandle()
: base((IntPtr)0, true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace System
{
internal class SafeTypeNameParserHandle : SafeHandleZeroOrMinusOneIsInvalid
internal sealed class SafeTypeNameParserHandle : SafeHandleZeroOrMinusOneIsInvalid
{
#region QCalls
[DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public static extern uint SizeofResource(IntPtr hModule,
/// native resources for the update handle without updating
/// the target file.
/// </summary>
private class SafeUpdateHandle : SafeHandle
private sealed class SafeUpdateHandle : SafeHandle
{
private SafeUpdateHandle() : base(IntPtr.Zero, true)
public SafeUpdateHandle() : base(IntPtr.Zero, true)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeCFArrayHandle : SafeHandle
{
private SafeCFArrayHandle()
public SafeCFArrayHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeCFDataHandle : SafeHandle
{
internal SafeCFDataHandle()
public SafeCFDataHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeCFDateHandle : SafeHandle
{
internal SafeCFDateHandle()
public SafeCFDateHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeCFDictionaryHandle : SafeHandle
{
private SafeCFDictionaryHandle()
public SafeCFDictionaryHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeCFErrorHandle : SafeHandle
{
internal SafeCFErrorHandle()
public SafeCFErrorHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeCFStringHandle : SafeHandle
{
internal SafeCFStringHandle()
public SafeCFStringHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace System.Security.Cryptography.Apple
{
internal sealed class SafeDigestCtxHandle : SafeHandle
{
internal SafeDigestCtxHandle()
public SafeDigestCtxHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace System.Security.Cryptography.Apple
{
internal sealed class SafeHmacHandle : SafeHandle
{
internal SafeHmacHandle()
public SafeHmacHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace System.Security.Cryptography.Apple
{
internal class SafeKeychainItemHandle : SafeHandle
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved
{
internal SafeKeychainItemHandle()
public SafeKeychainItemHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand All @@ -310,7 +310,7 @@ protected override bool ReleaseHandle()

internal class SafeKeychainHandle : SafeHandle
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved
{
internal SafeKeychainHandle()
public SafeKeychainHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ namespace System.Net
{
internal sealed class SafeSslHandle : SafeHandle
{
internal SafeSslHandle()
public SafeSslHandle()
: base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal static extern unsafe int CryptorFinal(

namespace System.Security.Cryptography
{
internal class SafeAppleCryptorHandle : SafeHandle
internal sealed class SafeAppleCryptorHandle : SafeHandle
{
public SafeAppleCryptorHandle()
: base(IntPtr.Zero, ownsHandle: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal static SafeOcspRequestHandle X509ChainBuildOcspRequest(SafeX509StoreCtx

namespace System.Security.Cryptography.X509Certificates
{
internal class SafeOcspRequestHandle : SafeHandleZeroOrMinusOneIsInvalid
internal sealed class SafeOcspRequestHandle : SafeHandleZeroOrMinusOneIsInvalid
{
public SafeOcspRequestHandle()
: base(true)
Expand All @@ -116,7 +116,7 @@ protected override bool ReleaseHandle()
}
}

internal class SafeOcspResponseHandle : SafeHandleZeroOrMinusOneIsInvalid
internal sealed class SafeOcspResponseHandle : SafeHandleZeroOrMinusOneIsInvalid
{
public SafeOcspResponseHandle()
: base(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ private void Disconnect()
}
}

private SafeSslHandle() : base(IntPtr.Zero, true)
public SafeSslHandle() : base(IntPtr.Zero, true)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeSslContextHandle : SafeHandle
{
private SafeSslContextHandle()
public SafeSslContextHandle()
: base(IntPtr.Zero, true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace Microsoft.Win32.SafeHandles
/// </summary>
internal sealed class SafeSharedX509NameHandle : SafeInteriorHandle
{
private SafeSharedX509NameHandle() :
public SafeSharedX509NameHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand All @@ -61,7 +61,7 @@ private SafeSharedX509NameHandle() :
/// </summary>
internal sealed class SafeSharedX509NameStackHandle : SafeInteriorHandle
{
private SafeSharedX509NameStackHandle() :
public SafeSharedX509NameStackHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeX509StackHandle : SafeHandle
{
private SafeX509StackHandle() :
public SafeX509StackHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down Expand Up @@ -100,7 +100,7 @@ internal sealed class SafeSharedX509StackHandle : SafeInteriorHandle
{
internal static readonly SafeSharedX509StackHandle InvalidHandle = new SafeSharedX509StackHandle();

private SafeSharedX509StackHandle() :
public SafeSharedX509StackHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeX509StoreCtxHandle : SafeHandle
{
private SafeX509StoreCtxHandle() :
public SafeX509StoreCtxHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal sealed class SafeHashHandle : SafeHandleZeroOrMinusOneIsInvalid
{
private SafeProvHandle? _parent;

private SafeHashHandle() : base(true)
public SafeHashHandle() : base(true)
{
SetHandle(IntPtr.Zero);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal sealed class SafeKeyHandle : SafeHandleZeroOrMinusOneIsInvalid
private bool _fPublicOnly;
private SafeProvHandle? _parent;

private SafeKeyHandle() : base(true)
public SafeKeyHandle() : base(true)
{
SetHandle(IntPtr.Zero);
_keySpec = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal sealed class SafeProvHandle : SafeHandleZeroOrMinusOneIsInvalid
private uint _flags;
private bool _fPersistKeyInCsp;

private SafeProvHandle() : base(true)
public SafeProvHandle() : base(true)
{
SetHandle(IntPtr.Zero);
_containerName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal struct Icmp6EchoReply

internal sealed class SafeCloseIcmpHandle : SafeHandleZeroOrMinusOneIsInvalid
{
private SafeCloseIcmpHandle() : base(true)
public SafeCloseIcmpHandle() : base(true)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ internal sealed class SafeFreeCertContext : SafeHandleZeroOrMinusOneIsInvalid
{
#endif

internal SafeFreeCertContext() : base(true) { }
public SafeFreeCertContext() : base(true) { }

// This must be ONLY called from this file.
internal void Set(IntPtr value)
Expand Down Expand Up @@ -1080,7 +1080,7 @@ internal static unsafe int ApplyControlToken(

internal sealed class SafeDeleteSslContext : SafeDeleteContext
{
internal SafeDeleteSslContext() : base() { }
public SafeDeleteSslContext() : base() { }

protected override bool ReleaseHandle()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal sealed class SafeNativeOverlapped : SafeHandle
{
private readonly SafeSocketHandle? _socketHandle;

private SafeNativeOverlapped()
public SafeNativeOverlapped()
: this(IntPtr.Zero)
{
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeAsn1ObjectHandle : SafeHandle
{
private SafeAsn1ObjectHandle() :
public SafeAsn1ObjectHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand All @@ -28,7 +28,7 @@ public override bool IsInvalid

internal sealed class SafeAsn1BitStringHandle : SafeHandle
{
private SafeAsn1BitStringHandle() :
public SafeAsn1BitStringHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand All @@ -48,7 +48,7 @@ public override bool IsInvalid

internal sealed class SafeAsn1OctetStringHandle : SafeHandle
{
private SafeAsn1OctetStringHandle() :
public SafeAsn1OctetStringHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected override bool ReleaseHandle()
return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
}

private SafeGssNameHandle()
public SafeGssNameHandle()
: base(IntPtr.Zero, true)
{
}
Expand All @@ -70,7 +70,7 @@ private SafeGssNameHandle()
/// <summary>
/// Wrapper around a gss_cred_id_t_desc_struct*
/// </summary>
internal class SafeGssCredHandle : SafeHandle
internal sealed class SafeGssCredHandle : SafeHandle
{
private static readonly Lazy<bool> s_IsNtlmInstalled = new Lazy<bool>(InitIsNtlmInstalled);

Expand Down Expand Up @@ -132,7 +132,7 @@ public static SafeGssCredHandle Create(string username, string password, bool is
return retHandle;
}

private SafeGssCredHandle()
public SafeGssCredHandle()
: base(IntPtr.Zero, true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeBCryptAlgorithmHandle : SafeBCryptHandle
{
private SafeBCryptAlgorithmHandle()
public SafeBCryptAlgorithmHandle()
: base()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeBCryptHashHandle : SafeBCryptHandle
{
private SafeBCryptHashHandle()
public SafeBCryptHashHandle()
: base()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeBCryptKeyHandle : SafeBCryptHandle
{
private SafeBCryptKeyHandle()
public SafeBCryptKeyHandle()
: base()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeBignumHandle : SafeHandle
{
private SafeBignumHandle() :
public SafeBignumHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal sealed class SafeBioHandle : SafeHandle
{
private SafeHandle? _parent;

private SafeBioHandle() :
public SafeBioHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.Win32.SafeHandles
/// </summary>
internal sealed partial class SafeCreateHandle : SafeHandle
{
internal SafeCreateHandle() : base(IntPtr.Zero, true) { }
public SafeCreateHandle() : base(IntPtr.Zero, true) { }

internal SafeCreateHandle(IntPtr ptr) : base(IntPtr.Zero, true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeDsaHandle : SafeHandle
{
private SafeDsaHandle() :
public SafeDsaHandle() :
base(IntPtr.Zero, ownsHandle: true)
{
}
Expand Down
Loading