Skip to content

Commit 2e2de79

Browse files
author
Ben Russell
committed
Add OS constants to test common project, wrap app context switches that are platform specific in
Fix case-sensitivity issues in netfx project
1 parent d8a4c47 commit 2e2de79

File tree

4 files changed

+69
-33
lines changed

4 files changed

+69
-33
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@
489489
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalAppContextSwitches.cs">
490490
<Link>Microsoft\Data\SqlClient\LocalAppContextSwitches.cs</Link>
491491
</Compile>
492-
<Compile Include="$(CommonSourceROot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs">
493-
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs</Link>
492+
<Compile Include="$(CommonSourceROot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.windows.cs">
493+
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.windows.cs</Link>
494494
</Compile>
495495
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbConfigurationSection.netfx.cs">
496496
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbConfigurationSection.netfx.cs</Link>
@@ -726,11 +726,11 @@
726726
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCertificateStoreProvider.cs">
727727
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCertificateStoreProvider.cs</Link>
728728
</Compile>
729-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs">
730-
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs</Link>
729+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.windows.cs">
730+
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.windows.cs</Link>
731731
</Compile>
732-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.Windows.cs">
733-
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.Windows.cs</Link>
732+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.windows.cs">
733+
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.windows.cs</Link>
734734
</Compile>
735735
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionEnclaveProvider.cs">
736736
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionEnclaveProvider.cs</Link>
@@ -939,20 +939,20 @@
939939
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParser.cs">
940940
<Link>Microsoft\Data\SqlClient\TdsParser.cs</Link>
941941
</Compile>
942-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs">
943-
<Link>Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs</Link>
942+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserSafeHandles.windows.cs">
943+
<Link>Microsoft\Data\SqlClient\TdsParserSafeHandles.windows.cs</Link>
944944
</Compile>
945945
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserStateObject.cs">
946946
<Link>Microsoft\Data\SqlClient\TdsParserStateObject.cs</Link>
947947
</Compile>
948948
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserStateObject.Multiplexer.cs">
949949
<Link>Microsoft\Data\SqlClient\TdsParserStateObject.Multiplexer.cs</Link>
950950
</Compile>
951-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserStateObjectFactory.Windows.cs">
952-
<Link>Microsoft\Data\SqlClient\TdsParserStateObjectFactory.Windows.cs</Link>
951+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserStateObjectFactory.windows.cs">
952+
<Link>Microsoft\Data\SqlClient\TdsParserStateObjectFactory.windows.cs</Link>
953953
</Compile>
954-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserStateObjectNative.Windows.cs">
955-
<Link>Microsoft\Data\SqlClient\TdsParserStateObjectNative.Windows.cs</Link>
954+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserStateObjectNative.windows.cs">
955+
<Link>Microsoft\Data\SqlClient\TdsParserStateObjectNative.windows.cs</Link>
956956
</Compile>
957957
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\TdsParserStaticMethods.cs">
958958
<Link>Microsoft\Data\SqlClient\TdsParserStaticMethods.cs</Link>
@@ -990,8 +990,8 @@
990990
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlDbTypeExtensions.cs">
991991
<Link>Microsoft\Data\SqlDbTypeExtensions.cs</Link>
992992
</Compile>
993-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs">
994-
<Link>Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs</Link>
993+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlFileStream.windows.cs">
994+
<Link>Microsoft\Data\SqlTypes\SqlFileStream.windows.cs</Link>
995995
</Compile>
996996
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlJson.cs">
997997
<Link>Microsoft\Data\SqlTypes\SqlJson.cs</Link>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<!-- If a target OS was not specified, use the current OS as the target OS. -->
1111
<TargetOs Condition="'$(TargetOs)' == ''">$(OS)</TargetOs>
1212

13-
1413
<!-- Uncomment the following line to override the OS you are developing for -->
1514
<!--<TargetOs>Unix</TargetOs>-->
1615
<!--<TargetOs>Windows_NT</TargetOs>-->

src/Microsoft.Data.SqlClient/tests/Common/Common.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<AssemblyName>Common</AssemblyName>
54
<TargetGroup Condition="$(TargetFramework.StartsWith('net4'))">netfx</TargetGroup>
@@ -11,6 +10,12 @@
1110
<IsTestProject>true</IsTestProject>
1211
</PropertyGroup>
1312

13+
<!-- OS Constants ==================================================== -->
14+
<PropertyGroup>
15+
<DefineConstants Condition="'$(OSGroup.ToUpper())'=='UNIX'">$(DefineConstants),_UNIX</DefineConstants>
16+
<DefineConstants Condition="'$(OSGroup.ToUpper())'=='WINDOWS_NT'">$(DefineConstants),_WINDOWS</DefineConstants>
17+
</PropertyGroup>
18+
1419
<!-- .NET Framework Packages -->
1520
<ItemGroup>
1621
<!-- For compilation targeting .NET Framework using .NET SDKs. -->

src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ public sealed class LocalAppContextSwitchesHelper : IDisposable
3333
private readonly PropertyInfo _truncateScaledDecimalProperty;
3434
private readonly PropertyInfo _ignoreServerProvidedFailoverPartner;
3535
private readonly PropertyInfo _enableUserAgent;
36-
#if NET
36+
37+
#if NET
3738
private readonly PropertyInfo _globalizationInvariantModeProperty;
39+
#endif
40+
41+
#if NET && _WINDOWS
3842
private readonly PropertyInfo _useManagedNetworkingProperty;
39-
#else
43+
#endif
44+
45+
#if NETFRAMEWORK
4046
private readonly PropertyInfo _disableTnirByDefaultProperty;
4147
#endif
4248

@@ -63,12 +69,18 @@ public sealed class LocalAppContextSwitchesHelper : IDisposable
6369
private readonly Tristate _ignoreServerProvidedFailoverPartnerOriginal;
6470
private readonly FieldInfo _enableUserAgentField;
6571
private readonly Tristate _enableUserAgentOriginal;
66-
#if NET
72+
73+
#if NET
6774
private readonly FieldInfo _globalizationInvariantModeField;
6875
private readonly Tristate _globalizationInvariantModeOriginal;
76+
#endif
77+
78+
#if NET && _WINDOWS
6979
private readonly FieldInfo _useManagedNetworkingField;
7080
private readonly Tristate _useManagedNetworkingOriginal;
71-
#else
81+
#endif
82+
83+
#if NETFRAMEWORK
7284
private readonly FieldInfo _disableTnirByDefaultField;
7385
private readonly Tristate _disableTnirByDefaultOriginal;
7486
#endif
@@ -169,15 +181,19 @@ void InitProperty(string name, out PropertyInfo property)
169181
"EnableUserAgent",
170182
out _enableUserAgent);
171183

172-
#if NET
184+
#if NET
173185
InitProperty(
174186
"GlobalizationInvariantMode",
175187
out _globalizationInvariantModeProperty);
176-
188+
#endif
189+
190+
#if NET && _WINDOWS
177191
InitProperty(
178192
"UseManagedNetworking",
179193
out _useManagedNetworkingProperty);
180-
#else
194+
#endif
195+
196+
#if NETFRAMEWORK
181197
InitProperty(
182198
"DisableTnirByDefault",
183199
out _disableTnirByDefaultProperty);
@@ -253,17 +269,21 @@ void InitField(string name, out FieldInfo field, out Tristate value)
253269
out _enableUserAgentField,
254270
out _enableUserAgentOriginal);
255271

256-
#if NET
272+
#if NET
257273
InitField(
258274
"s_globalizationInvariantMode",
259275
out _globalizationInvariantModeField,
260276
out _globalizationInvariantModeOriginal);
261-
277+
#endif
278+
279+
#if NET && _WINDOWS
262280
InitField(
263281
"s_useManagedNetworking",
264282
out _useManagedNetworkingField,
265283
out _useManagedNetworkingOriginal);
266-
#else
284+
#endif
285+
286+
#if NETFRAMEWORK
267287
InitField(
268288
"s_disableTnirByDefault",
269289
out _disableTnirByDefaultField,
@@ -339,15 +359,19 @@ void RestoreField(FieldInfo field, Tristate value)
339359
_enableUserAgentField,
340360
_enableUserAgentOriginal);
341361

342-
#if NET
362+
#if NET
343363
RestoreField(
344364
_globalizationInvariantModeField,
345365
_globalizationInvariantModeOriginal);
346-
366+
#endif
367+
368+
#if NET && _WINDOWS
347369
RestoreField(
348370
_useManagedNetworkingField,
349371
_useManagedNetworkingOriginal);
350-
#else
372+
#endif
373+
374+
#if NETFRAMEWORK
351375
RestoreField(
352376
_disableTnirByDefaultField,
353377
_disableTnirByDefaultOriginal);
@@ -450,23 +474,27 @@ public bool EnableUserAgent
450474
get => (bool)_enableUserAgent.GetValue(null);
451475
}
452476

453-
#if NET
477+
#if NET
454478
/// <summary>
455479
/// Access the LocalAppContextSwitches.GlobalizationInvariantMode property.
456480
/// </summary>
457481
public bool GlobalizationInvariantMode
458482
{
459483
get => (bool)_globalizationInvariantModeProperty.GetValue(null);
460484
}
485+
#endif
461486

487+
#if NET && _WINDOWS
462488
/// <summary>
463489
/// Access the LocalAppContextSwitches.UseManagedNetworking property.
464490
/// </summary>
465491
public bool UseManagedNetworking
466492
{
467493
get => (bool)_useManagedNetworkingProperty.GetValue(null);
468494
}
469-
#else
495+
#endif
496+
497+
#if NETFRAMEWORK
470498
/// <summary>
471499
/// Access the LocalAppContextSwitches.DisableTnirByDefault property.
472500
/// </summary>
@@ -580,7 +608,7 @@ public Tristate EnableUserAgentField
580608
set => SetValue(_enableUserAgentField, value);
581609
}
582610

583-
#if NET
611+
#if NET
584612
/// <summary>
585613
/// Get or set the LocalAppContextSwitches.GlobalizationInvariantMode switch value.
586614
/// </summary>
@@ -589,7 +617,9 @@ public Tristate GlobalizationInvariantModeField
589617
get => GetValue(_globalizationInvariantModeField);
590618
set => SetValue(_globalizationInvariantModeField, value);
591619
}
620+
#endif
592621

622+
#if NET && _WINDOWS
593623
/// <summary>
594624
/// Get or set the LocalAppContextSwitches.UseManagedNetworking switch value.
595625
/// </summary>
@@ -598,7 +628,9 @@ public Tristate UseManagedNetworkingField
598628
get => GetValue(_useManagedNetworkingField);
599629
set => SetValue(_useManagedNetworkingField, value);
600630
}
601-
#else
631+
#endif
632+
633+
#if NETFRAMEWORK
602634
/// <summary>
603635
/// Get or set the LocalAppContextSwitches.DisableTnirByDefault switch
604636
/// value.

0 commit comments

Comments
 (0)