Skip to content

Commit 54ab5ae

Browse files
Feature | Project Microsoft.SqlServer.Server separation phase 1 (MDS consumes MSS using netfx) (#1435)
1 parent 8202268 commit 54ab5ae

39 files changed

+1375
-79
lines changed

build.proj

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<TargetNetCoreVersion Condition="$(TargetGroup) == 'netcoreapp' AND $(TargetNetCoreVersion) == ''">$(TF)</TargetNetCoreVersion>
2525
<TargetNetFxVersion Condition="$(TargetGroup) == 'netfx' AND $(TargetNetFxVersion) == ''">$(TF)</TargetNetFxVersion>
2626
<GenerateNuget Condition="'$(GenerateNuget)' == ''">true</GenerateNuget>
27+
<SqlServerLibProperties>Configuration=$(Configuration);AssemblyVersion=$(SqlServerAssemblyVersion);AssemblyFileVersion=$(SqlServerAssemblyFileVersion);Version=$(SqlServerPackageVersion);</SqlServerLibProperties>
2728
<ProjectProperties>Configuration=$(Configuration);AssemblyFileVersion=$(AssemblyFileVersion);TargetsWindows=$(TargetsWindows);TargetsUnix=$(TargetsUnix);</ProjectProperties>
2829
<TestProjectProperties>BuildProjectReferences=false;$(ProjectProperties);BuildForRelease=false;TargetNetCoreVersion=$(TargetNetCoreVersion);TargetNetFxVersion=$(TargetNetFxVersion)</TestProjectProperties>
2930
<ResultsDirectory Condition="$(ResultsDirectory) == ''">TestResults</ResultsDirectory>
@@ -37,6 +38,7 @@
3738

3839
<!-- Populate all managed projects -->
3940
<ItemGroup>
41+
<SqlServerLib Include="**/Microsoft.SqlServer.Server.csproj" />
4042
<NetFxDriver Include="**/netfx/**/Microsoft.Data.SqlClient*.csproj" Condition="'$(IsEnabledWindows)' == 'true'" />
4143
<NetCoreDriver Include="**/netcore/**/Microsoft.Data.SqlClient*.csproj" />
4244
<AKVProvider Include="**/add-ons/**/AzureKeyVaultProvider/*.csproj" />
@@ -65,13 +67,18 @@
6567
</ItemGroup>
6668

6769
<!-- Top Level Build targets -->
68-
<Target Name="Restore" DependsOnTargets="RestoreNetCore;RestoreNetFx" />
69-
<Target Name="BuildAll" DependsOnTargets="BuildNetFx;BuildNetCore" />
70-
<Target Name="BuildAllConfigurations" DependsOnTargets="Restore;BuildTools;BuildNetFx;BuildNetCoreAllOS;GenerateNugetPackage" />
70+
<Target Name="Restore" DependsOnTargets="RestoreSqlServerLib;RestoreNetCore;RestoreNetFx" />
71+
<Target Name="BuildAll" DependsOnTargets="BuildSqlServerLib;BuildNetFx;BuildNetCore" />
72+
<Target Name="BuildAllConfigurations" DependsOnTargets="Restore;BuildTools;BuildSqlServerLib;BuildNetFx;BuildNetCoreAllOS;GenerateNugetPackage" />
73+
<Target Name="BuildSqlServerPackage" DependsOnTargets="BuildSqlServerLibAnyOS;GenerateSqlServerPackage"/>
7174
<Target Name="BuildTestsNetCore" DependsOnTargets="RestoreTestsNetCore;BuildAKVNetCore;BuildFunctionalTestsNetCore;BuildManualTestsNetCore"/>
72-
<Target Name="BuildTestsNetFx" DependsOnTargets="RestoreTestsNetFx;BuildAKVNetFx;BuildFunctionalTestsNetFx;BuildManualTestsNetFx" Condition="$(IsEnabledWindows) == 'true'"/>
75+
<Target Name="BuildTestsNetFx" DependsOnTargets="BuildSqlServerLib;RestoreTestsNetFx;BuildAKVNetFx;BuildFunctionalTestsNetFx;BuildManualTestsNetFx" Condition="$(IsEnabledWindows) == 'true'"/>
7376
<Target Name="BuildTests" DependsOnTargets="BuildTestsNetCore;BuildTestsNetFx"/>
7477

78+
<Target Name="RestoreSqlServerLib">
79+
<MSBuild Projects="@(SqlServerLib)" Targets="restore" />
80+
</Target>
81+
7582
<Target Name="RestoreNetCore">
7683
<MSBuild Projects="@(NetCoreDriver)" Targets="restore" />
7784
</Target>
@@ -101,6 +108,14 @@
101108
<MSBuild Projects="@(NetFxDriver)" Properties="$(CI);Platform=AnyCPU;$(ProjectProperties)" />
102109
</Target>
103110

111+
<Target Name="BuildSqlServerLibAnyOS" DependsOnTargets="RestoreSqlServerLib">
112+
<MSBuild Projects="@(SqlServerLib)" Properties="$(CI);$(SqlServerLibProperties);Platform=AnyCPU;OSGroup=AnyOS" RemoveProperties="TargetsWindows;TargetsUnix;" />
113+
</Target>
114+
115+
<Target Name="BuildSqlServerLib" DependsOnTargets="RestoreSqlServerLib">
116+
<MSBuild Projects="@(SqlServerLib)" Properties="$(CI);$(SqlServerLibProperties);Platform=AnyCPU;" RemoveProperties="TargetsWindows;TargetsUnix;" />
117+
</Target>
118+
104119
<Target Name="BuildNetCore" DependsOnTargets="RestoreNetCore">
105120
<MSBuild Projects="@(NetCoreDriver)" Properties="$(CI);Platform=AnyCPU;$(ProjectProperties)" />
106121
</Target>

doc/snippets/Microsoft.Data.SqlClient.Server/InvalidUdtException.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,22 @@
1818
]]></format>
1919
</remarks>
2020
</GetObjectData>
21+
<Create>
22+
<param name="udtType">The <see cref="T:System.Type" /> object.</param>
23+
<param name="resourceReason">The <see cref="T:System.String" /> object that represents a string in string resources. The default value is `SqlUdtReason_NoUdtAttribute` which looks up a localized string similar to "no UDT attribute".</param>
24+
<summary>Create a new <see cref="T:Microsoft.Data.SqlClient.Server.InvalidUdtException" /> object.</summary>
25+
<returns>A new <see cref="T:Microsoft.Data.SqlClient.Server.InvalidUdtException" /> object.</returns>
26+
<remarks>
27+
<format type="text/markdown"><![CDATA[
28+
29+
## Remarks
30+
This method Looks up a localized string similar to "&apos;{0}&apos; is an invalid user defined type, reason: {1}.", and fills it in order with `udtType` and `resourceReason` resolved value.
31+
32+
> [!IMPORTANT]
33+
> This function exposes for backward compatibility, and should be used with default value for `resourceReason` parameter.
34+
35+
]]></format>
36+
</remarks>
37+
</Create>
2138
</members>
2239
</docs>

porting-cheat-sheet.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ This guide is meant to cover all namespace changes needed in client applications
44

55
## Namespace Changes needed
66

7+
### Microsoft.Data.SqlClient v5.0 and newer
8+
9+
| Namespace Change | Applicability |
10+
|--|--|
11+
| <s>`using System.Data.SqlClient;`</s><br>`using Microsoft.Data.SqlClient;` | Applicable to all classes, enums and delegates. |
12+
| <s>`using Microsoft.SqlServer.Server;`</s><br>`using Microsoft.Data.SqlClient.Server;` | Applicable Classes: <br>`SqlDataRecord`<br>`SqlMetaData` <br/><br/> <sup>1</sup> _All remaining types continue to be referenced from Microsoft.SqlServer.Server namespace._|
13+
| <s>`using System.Data.SqlTypes;`</s> <br>`using Microsoft.Data.SqlTypes;` | Applicable Classes:<br>`SqlFileStream`|
14+
| <s>`using System.Data.Sql;`</s> <br>`using Microsoft.Data.Sql;`</s> | Applicable Classes:<br>`SqlNotificationRequest`<br> |
15+
| <s>`using System.Data;`</s> <br>`using Microsoft.Data;`</s> | Applicable Classes:<br>`OperationAbortedException`|
16+
17+
<sup>1</sup> Breaking change for User-Defined types and Microsoft.SqlServer.Types support over _Microsoft.Data.SqlClient v3.0.0_.
18+
19+
### Microsoft.Data.SqlClient v4.0 and older
20+
721
| Namespace Change | Applicability |
822
|--|--|
923
| <s>`using System.Data.SqlClient;`</s><br>`using Microsoft.Data.SqlClient;` | Applicable to all classes, enums and delegates. |

src/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<Artifacts>$(RepoRoot)artifacts\$(ReferenceType)\</Artifacts>
4242
<ToolsArtifactsDir Condition="'$(ToolsArtifactsDir)'==''">$(Artifacts)tools\</ToolsArtifactsDir>
4343
<ManagedSourceCode>$(ProjectDir)Microsoft.Data.SqlClient\</ManagedSourceCode>
44+
<SqlServerSourceCode>$(ProjectDir)Microsoft.SqlServer.Server\</SqlServerSourceCode>
4445
<NetCoreSource>$(ManagedSourceCode)netcore\</NetCoreSource>
4546
<NetFxSource>$(ManagedSourceCode)netfx\</NetFxSource>
4647
<NetFxResources>$(ManagedSourceCode)netfx\src\Resources\</NetFxResources>

src/Microsoft.Data.SqlClient.sln

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.29521.150
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.0.31912.275
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient\netfx\src\Microsoft.Data.SqlClient.csproj", "{407890AC-9876-4FEF-A6F1-F36A876BAADE}"
66
EndProject
@@ -200,6 +200,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.Do
200200
EndProject
201201
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.PerformanceTests", "Microsoft.Data.SqlClient\tests\PerformanceTests\Microsoft.Data.SqlClient.PerformanceTests.csproj", "{599A336B-2A5F-473D-8442-1223ED37C93E}"
202202
EndProject
203+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4F3CD363-B1E6-4D6D-9466-97D78A56BE45}"
204+
EndProject
205+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlServer.Server", "Microsoft.SqlServer.Server\Microsoft.SqlServer.Server.csproj", "{A314812A-7820-4565-A2A8-ABBE391C11E4}"
206+
EndProject
203207
Global
204208
GlobalSection(SolutionConfigurationPlatforms) = preSolution
205209
Debug|Any CPU = Debug|Any CPU
@@ -472,6 +476,18 @@ Global
472476
{599A336B-2A5F-473D-8442-1223ED37C93E}.Release|x64.Build.0 = Release|x64
473477
{599A336B-2A5F-473D-8442-1223ED37C93E}.Release|x86.ActiveCfg = Release|x86
474478
{599A336B-2A5F-473D-8442-1223ED37C93E}.Release|x86.Build.0 = Release|x86
479+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
480+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
481+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Debug|x64.ActiveCfg = Debug|Any CPU
482+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Debug|x64.Build.0 = Debug|Any CPU
483+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Debug|x86.ActiveCfg = Debug|Any CPU
484+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Debug|x86.Build.0 = Debug|Any CPU
485+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
486+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Release|Any CPU.Build.0 = Release|Any CPU
487+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Release|x64.ActiveCfg = Release|Any CPU
488+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Release|x64.Build.0 = Release|Any CPU
489+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Release|x86.ActiveCfg = Release|Any CPU
490+
{A314812A-7820-4565-A2A8-ABBE391C11E4}.Release|x86.Build.0 = Release|Any CPU
475491
EndGlobalSection
476492
GlobalSection(SolutionProperties) = preSolution
477493
HideSolutionNode = FALSE
@@ -507,6 +523,7 @@ Global
507523
{B499E477-C9B1-4087-A5CF-5C762D90E433} = {0CC4817A-12F3-4357-912C-09315FAAD008}
508524
{B93A3149-67E8-491E-A1E5-19D65F9D9E98} = {0CC4817A-12F3-4357-912C-09315FAAD008}
509525
{599A336B-2A5F-473D-8442-1223ED37C93E} = {0CC4817A-12F3-4357-912C-09315FAAD008}
526+
{A314812A-7820-4565-A2A8-ABBE391C11E4} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
510527
EndGlobalSection
511528
GlobalSection(ExtensibilityGlobals) = postSolution
512529
SolutionGuid = {01D48116-37A2-4D33-B9EC-94793C702431}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@
180180
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs">
181181
<Link>Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs</Link>
182182
</Compile>
183-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\IBinarySerialize.cs">
184-
<Link>Microsoft\Data\SqlClient\Server\IBinarySerialize.cs</Link>
185-
</Compile>
186183
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\ITypedGetters.cs">
187184
<Link>Microsoft\Data\SqlClient\Server\ITypedGetters.cs</Link>
188185
</Compile>
@@ -210,24 +207,9 @@
210207
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiXetterAccessMap.Common.cs">
211208
<Link>Microsoft\Data\SqlClient\Server\SmiXetterAccess.Common.cs</Link>
212209
</Compile>
213-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlFacetAttribute.cs">
214-
<Link>Microsoft\Data\SqlClient\Server\SqlFacetAttribute.cs</Link>
215-
</Compile>
216-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlFunctionAttribute.cs">
217-
<Link>Microsoft\Data\SqlClient\Server\SqlFunctionAttribute.cs</Link>
218-
</Compile>
219210
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlMetaData.cs">
220211
<Link>Microsoft\Data\SqlClient\Server\SqlMetaData.cs</Link>
221212
</Compile>
222-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlMethodAttribute.cs">
223-
<Link>Microsoft\Data\SqlClient\Server\SqlMethodAttribute.cs</Link>
224-
</Compile>
225-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlUserDefinedTypeAttribute.cs">
226-
<Link>Microsoft\Data\SqlClient\Server\SqlUserDefinedTypeAttribute.cs</Link>
227-
</Compile>
228-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlUserDefinedAggregateAttribute.cs">
229-
<Link>Microsoft\Data\SqlClient\Server\SqlUserDefinedAggregateAttribute.cs</Link>
230-
</Compile>
231213
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlRecordBuffer.cs">
232214
<Link>Microsoft\Data\SqlClient\Server\SqlRecordBuffer.cs</Link>
233215
</Compile>
@@ -456,9 +438,6 @@
456438
<Compile Include="..\..\src\Microsoft\Data\DataException.cs">
457439
<Link>Microsoft\Data\DataException.cs</Link>
458440
</Compile>
459-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\InvalidUdtException.cs">
460-
<Link>Microsoft\Data\SqlClient\Server\InvalidUdtException.cs</Link>
461-
</Compile>
462441
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs">
463442
<Link>Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs</Link>
464443
</Compile>

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,12 +2959,12 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
29592959

29602960
internal byte[] GetBytes(object o)
29612961
{
2962-
Format format = Format.Native;
2962+
Microsoft.SqlServer.Server.Format format = Microsoft.SqlServer.Server.Format.Native;
29632963
int maxSize = 0;
29642964
return GetBytes(o, out format, out maxSize);
29652965
}
29662966

2967-
internal byte[] GetBytes(object o, out Format format, out int maxSize)
2967+
internal byte[] GetBytes(object o, out Microsoft.SqlServer.Server.Format format, out int maxSize)
29682968
{
29692969
SqlUdtInfo attr = AssemblyCache.GetInfoFromType(o.GetType());
29702970
maxSize = attr.MaxByteSize;

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using Microsoft.Data.SqlClient.DataClassification;
2323
using Microsoft.Data.SqlClient.Server;
2424
using Microsoft.Data.SqlTypes;
25+
using Microsoft.SqlServer.Server;
2526

2627
namespace Microsoft.Data.SqlClient
2728
{
@@ -10678,7 +10679,7 @@ private void WriteParameterName(string parameterName, TdsParserStateObject state
1067810679
}
1067910680
}
1068010681

10681-
private static readonly IEnumerable<SqlDataRecord> __tvpEmptyValue = new List<SqlDataRecord>().AsReadOnly();
10682+
private static readonly IEnumerable<Server.SqlDataRecord> __tvpEmptyValue = new List<Server.SqlDataRecord>().AsReadOnly();
1068210683
private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefault, TdsParserStateObject stateObj, bool isAnonymous, bool advancedTraceIsOn)
1068310684
{
1068410685
//

0 commit comments

Comments
 (0)