diff --git a/build2.proj b/build2.proj new file mode 100644 index 0000000000..49ba90514d --- /dev/null +++ b/build2.proj @@ -0,0 +1,53 @@ + + + + + + + + Debug + + + + + + + + + + + + + + $(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj + + + + + + + + + + $(DotnetPath)dotnet build $(MdsProjectPath) + -p:Configuration=$(Configuration) + -p:TargetOs=Unix + + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) + + + + + + + + + $(DotnetPath)dotnet build $(MdsProjectPath) + -p:Configuration=$(Configuration) + -p:TargetOs=Windows + + $([System.Text.RegularExpressions.Regex]::Replace($(DotnetCommand), "\s{2,}", " ")) + + + + \ No newline at end of file diff --git a/src/Microsoft.Data.SqlClient.sln b/src/Microsoft.Data.SqlClient.sln index 6696a8a31d..8b4f420f19 100644 --- a/src/Microsoft.Data.SqlClient.sln +++ b/src/Microsoft.Data.SqlClient.sln @@ -1,4 +1,4 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 @@ -561,6 +561,12 @@ Global {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|Any CPU.ActiveCfg = Release|Any CPU {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x64.ActiveCfg = Release|Any CPU {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x86.ActiveCfg = Release|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Debug|x64.Build.0 = Debug|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Debug|x86.Build.0 = Debug|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|Any CPU.Build.0 = Release|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x64.Build.0 = Release|Any CPU + {9A8996A8-6484-4AA7-B50F-F861430EDE2F}.Release|x86.Build.0 = Release|Any CPU {4461063D-2F2B-274C-7E6F-F235119D258E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4461063D-2F2B-274C-7E6F-F235119D258E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4461063D-2F2B-274C-7E6F-F235119D258E}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index 73c0cb3c9c..8235f71fb7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -815,11 +815,11 @@ Microsoft\Data\SqlClient\SqlDependencyUtils.cs - - Microsoft\Data\SqlClient\SqlDependencyUtils.AppDomain.cs + + Microsoft\Data\SqlClient\SqlDependencyUtils.AppDomain.netcore.cs - - Microsoft\Data\SqlClient\SqlDependencyUtils.AssemblyLoadContext.cs + + Microsoft\Data\SqlClient\SqlDependencyUtils.AssemblyLoadContext.netcore.cs Microsoft\Data\SqlClient\SqlEnclaveAttestationParameters.Crypto.cs diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 69ddbf01fd..338944ccff 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -1,12 +1,14 @@  - - net462;net8.0;net9.0 + + + Debug;Release; + true - + $(OS) @@ -15,41 +17,74 @@ - - $(DefineConstants),_UNIX - $(DefineConstants),_WINDOWS + + $(DefineConstants);_UNIX + $(DefineConstants);_WINDOWS + + + + + + net8.0;net9.0 + $(TargetFrameworks);net462 + + + + + + $(RepoRoot)artifacts/ + + + + + $(ArtifactPath)$(AssemblyName)/$(Configuration)/$(TargetOs.ToLower())/ + + + + + Condition="'$(TargetOs.ToUpper())' == 'WINDOWS_NT' AND '$(TargetFramework)' != 'net462'" /> + - - + + - + - - - - - + + + + + + + + + + + + diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs index dcd9f4bac9..64f827e261 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs @@ -69,24 +69,27 @@ internal static partial class ADP internal const int MaxBufferAccessTokenExpiry = 600; #region UDT -#if NETFRAMEWORK - private static readonly MethodInfo s_method = typeof(InvalidUdtException).GetMethod("Create", BindingFlags.NonPublic | BindingFlags.Static); -#endif + + #if NETFRAMEWORK + private static readonly MethodInfo s_udtFactory = + typeof(InvalidUdtException).GetMethod("Create", BindingFlags.NonPublic | BindingFlags.Static); + #endif + /// /// Calls "InvalidUdtException.Create" method when an invalid UDT occurs. /// internal static InvalidUdtException CreateInvalidUdtException(Type udtType, string resourceReasonName) { - // @TODO: Can we adopt the netcore version? - InvalidUdtException e = -#if NETFRAMEWORK - (InvalidUdtException)s_method.Invoke(null, new object[] { udtType, resourceReasonName }); - ADP.TraceExceptionAsReturnValue(e); -#else - InvalidUdtException.Create(udtType, resourceReasonName); -#endif + #if NETFRAMEWORK + InvalidUdtException e = (InvalidUdtException)s_udtFactory.Invoke(null, [udtType, resourceReasonName]); + #else + InvalidUdtException e = InvalidUdtException.Create(udtType, resourceReasonName); + #endif + + TraceExceptionAsReturnValue(e); return e; } + #endregion static private void TraceException(string trace, Exception e) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.netcore.cs similarity index 97% rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.netcore.cs index d82a9fc8fa..9e030d7c42 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.netcore.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET + using System; namespace Microsoft.Data.SqlClient @@ -18,3 +20,5 @@ partial void SubscribeToAppDomainUnload() } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.netcore.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AssemblyLoadContext.netcore.cs