Skip to content
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 @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

namespace Interop.Windows.Kernel32
{
internal class FileTypes
Expand All @@ -14,5 +12,3 @@ internal class FileTypes
internal const int FILE_TYPE_PIPE = 0x0003;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;

namespace Interop.Windows.Kernel32
Expand Down Expand Up @@ -33,5 +31,3 @@ internal enum IoControlCodeAccess
FILE_WRITE_DATA = 0x02
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

namespace Interop.Windows.Kernel32
{
/// <summary>
Expand Down Expand Up @@ -37,5 +35,3 @@ internal enum IoControlTransferType
METHOD_NEITHER
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Data.Common;
using Microsoft.Win32.SafeHandles;

#if !NETFRAMEWORK
#if !NETFRAMEWORK && _WINDOWS
using Interop.Windows.Handles;
#endif

Expand All @@ -21,7 +19,7 @@ internal static class Kernel32
internal const ushort FILE_DEVICE_FILE_SYSTEM = 0x0009;
internal const uint SEM_FAILCRITICALERRORS = 1;

#if !NETFRAMEWORK
#if _WINDOWS && !NETFRAMEWORK
internal const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
#endif
Expand Down Expand Up @@ -56,7 +54,7 @@ internal static extern bool DeviceIoControl(
out uint cbBytesReturned,
IntPtr overlapped);

#if NET
#if NET && _WINDOWS
[DllImport(DllName, ExactSpelling = true, SetLastError = true)]
public static extern bool FreeLibrary([In] IntPtr hModule);
#endif
Expand All @@ -73,17 +71,13 @@ internal static extern int GetFullPathName(
IntPtr lpFilePartOrNull);
#endif

#if NET
#if NET && _WINDOWS
[DllImport(DllName, CharSet = CharSet.Ansi, BestFitMapping = false)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
#endif

#if NET
[DllImport(DllName, CharSet = CharSet.Ansi, BestFitMapping = false)]
public static extern IntPtr GetProcAddress(SafeLibraryHandle hModule, string lpProcName);
#endif

#if NET
[DllImport(DllName, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeLibraryHandle LoadLibraryExW([In] string lpwLibFileName, [In] IntPtr hFile, [In] uint dwFlags);
#endif
Expand All @@ -92,5 +86,3 @@ internal static extern int GetFullPathName(
internal static extern bool SetThreadErrorMode(uint dwNewMode, out uint lpOldMode);
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

namespace Interop.Windows.NtDll
{
/// <summary>
Expand Down Expand Up @@ -56,5 +54,3 @@ internal enum CreateDisposition : uint
FILE_OVERWRITE_IF = 5
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;

namespace Interop.Windows.NtDll
Expand Down Expand Up @@ -198,5 +196,3 @@ internal enum CreateOptions : uint
// FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;

namespace Interop.Windows.NtDll
Expand Down Expand Up @@ -190,5 +188,3 @@ internal enum DesiredAccess : uint
FILE_GENERIC_EXECUTE = 0x20000000 // GENERIC_EXECUTE
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System.Runtime.InteropServices;

namespace Interop.Windows.NtDll
Expand Down Expand Up @@ -37,5 +35,3 @@ internal struct FileFullEaInformation

}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

namespace Interop.Windows.NtDll
{
/// <summary>
Expand Down Expand Up @@ -41,5 +39,3 @@ internal enum ImpersonationLevel
SecurityDelegation = 3,
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -44,5 +42,3 @@ public struct IoStatus
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;
using System.IO;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -120,5 +118,3 @@ private static extern unsafe int NtCreateFile(
uint EaLength);
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;

namespace Interop.Windows.NtDll
Expand Down Expand Up @@ -54,5 +52,3 @@ internal enum ObjectAttributeFlags : uint
// OBJ_VALID_ATTRIBUTES = 0x000001F2
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System;

namespace Interop.Windows.NtDll
Expand Down Expand Up @@ -60,5 +58,3 @@ public ObjectAttributes(
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System.Runtime.InteropServices;

namespace Interop.Windows.NtDll
Expand Down Expand Up @@ -50,5 +48,3 @@ public SecurityQualityOfService(
public bool IsEffectiveOnly { get; set; }
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

namespace Interop.Windows
{
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382.aspx
Expand All @@ -22,5 +20,3 @@ internal class SystemErrors
internal const int ERROR_MR_MID_NOT_FOUND = 317;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if _WINDOWS

using System.Runtime.InteropServices;

namespace Interop.Windows
Expand Down Expand Up @@ -36,5 +34,3 @@ public UnicodeString(char* buffer, int length)
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.Connection;
using Microsoft.SqlServer.Server;
using Microsoft.Win32;
using IsolationLevel = System.Data.IsolationLevel;
using Microsoft.Data.SqlClient.Internal;

Expand All @@ -30,10 +31,6 @@
using System.Security.Permissions;
#endif

#if _WINDOWS
using Microsoft.Win32;
#endif

namespace Microsoft.Data.Common
{
/// <summary>
Expand Down Expand Up @@ -68,6 +65,22 @@ internal static partial class ADP
/// </summary>
internal const int MaxBufferAccessTokenExpiry = 600;

/// <summary>
/// This member returns true if the current OS platform is Windows.
/// </summary>
/// <remarks>
/// This is a const on .NET Framework, and a property on .NET Core, because of differing API availability and JIT requirements.
/// .NET Framework will perform basic dead branch elimination when a const value is encountered, while .NET Core can trim Windows-specific
/// code when published to non-Windows platforms.
/// .NET Core's trimming is very limited though, so this must be used inline within methods to throw PlatformNotSupportedException,
/// rather than in a throw helper.
/// </remarks>
#if NETFRAMEWORK
public const bool IsWindows = true;
Comment thread
paulmedynski marked this conversation as resolved.
#else
public static bool IsWindows => OperatingSystem.IsWindows();
#endif

#region UDT

#if NETFRAMEWORK
Expand Down Expand Up @@ -435,17 +448,16 @@ internal static ArgumentOutOfRangeException InvalidCommandBehavior(CommandBehavi
return InvalidEnumerationValue(typeof(CommandBehavior), (int)value);
}


#if _UNIX
internal static object LocalMachineRegistryValue(string subkey, string queryvalue)
{
// No registry in non-Windows environments
return null;
}
#endif
#if _WINDOWS
internal static object LocalMachineRegistryValue(string subkey, string queryvalue)
{
#if NET
if (!IsWindows)
{
// No registry in non-Windows environments
return null;
}
#endif

#if NETFRAMEWORK
new RegistryPermission(RegistryPermissionAccess.Read, $@"HKEY_LOCAL_MACHINE\{subkey}").Assert();
#endif
Expand All @@ -471,7 +483,6 @@ internal static object LocalMachineRegistryValue(string subkey, string queryvalu
}
#endif
}
#endif

internal static void ValidateCommandBehavior(CommandBehavior value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ internal static partial class ADP
/// </summary>
internal const int MinimumTimeoutForTnirMs = 500;

// @TODO: Use naming rules
// @TODO: All values but Unix and Windows32NT are used today, for netfx this should always be Win32NT. We can likely hard code this to true for netfx.
internal static readonly bool s_isWindowsNT = Environment.OSVersion.Platform == PlatformID.Win32NT;

#endregion

#region Utility Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ sealed internal class DbConnectionPoolGroup
internal DbConnectionPoolGroup(DbConnectionOptions connectionOptions, DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolGroupOptions)
{
Debug.Assert(connectionOptions != null, "null connection options");
#if NETFRAMEWORK
Debug.Assert(poolGroupOptions == null || ADP.s_isWindowsNT, "should not have pooling options on Win9x");
#endif

_connectionOptions = connectionOptions;
_poolKey = key;
Expand Down Expand Up @@ -143,10 +140,6 @@ internal IDbConnectionPool GetConnectionPool(SqlConnectionFactory connectionFact
IDbConnectionPool pool = null;
if (_poolGroupOptions != null)
{
#if NETFRAMEWORK
Debug.Assert(ADP.s_isWindowsNT, "should not be pooling on Win9x");
#endif

DbConnectionPoolIdentity currentIdentity = DbConnectionPoolIdentity.NoIdentity;

if (_poolGroupOptions.PoolByIdentity)
Expand Down
Loading
Loading