Skip to content

Commit

Permalink
Fix API Spelling: LegacyRowVersionNullBehavior (#1035)
Browse files Browse the repository at this point in the history
Co-authored-by: jJRahnama <[email protected]>
  • Loading branch information
Javad and jJRahnama authored Apr 15, 2021
1 parent 357681c commit 3a325e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3771,7 +3771,7 @@ private bool TryReadColumnInternal(int i, bool readHeaderOnly = false)
{
if (columnMetaData.type == SqlDbType.Timestamp)
{
if (!LocalAppContextSwitches.LegacyRowVersionNullBehaviour)
if (!LocalAppContextSwitches.LegacyRowVersionNullBehavior)
{
_data[i].SetToNullOfType(SqlBuffer.StorageType.SqlBinary);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4283,7 +4283,7 @@ private bool TryReadColumnInternal(int i, bool readHeaderOnly = false)
{
if (columnMetaData.type == SqlDbType.Timestamp)
{
if (!LocalAppContextSwitches.LegacyRowVersionNullBehaviour)
if (!LocalAppContextSwitches.LegacyRowVersionNullBehavior)
{
_data[i].SetToNullOfType(SqlBuffer.StorageType.SqlBinary);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace Microsoft.Data.SqlClient
internal static partial class LocalAppContextSwitches
{
internal const string MakeReadAsyncBlockingString = @"Switch.Microsoft.Data.SqlClient.MakeReadAsyncBlocking";
internal const string LegacyRowVersionNullString = @"Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehaviour";
internal const string LegacyRowVersionNullString = @"Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehavior";

private static bool _makeReadAsyncBlocking;
private static bool? s_legacyRowVersionNullBehaviour;
private static bool? s_LegacyRowVersionNullBehavior;

public static bool MakeReadAsyncBlocking
{
Expand All @@ -29,20 +29,20 @@ public static bool MakeReadAsyncBlocking
/// would return an empty byte array. This switch contols whether to preserve that behaviour on newer versions
/// of Microsoft.Data.SqlClient, if this switch returns false an appropriate null value will be returned
/// </summary>
public static bool LegacyRowVersionNullBehaviour
public static bool LegacyRowVersionNullBehavior
{
get
{
if (s_legacyRowVersionNullBehaviour == null)
if (s_LegacyRowVersionNullBehavior == null)
{
bool value = false;
if (AppContext.TryGetSwitch(LegacyRowVersionNullString, out bool providedValue))
{
value = providedValue;
}
s_legacyRowVersionNullBehaviour = value;
s_LegacyRowVersionNullBehavior = value;
}
return s_legacyRowVersionNullBehaviour.Value;
return s_LegacyRowVersionNullBehavior.Value;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public static void CheckNullRowVersionIsBDNull()
{
lock (s_rowVersionLock)
{
bool? originalValue = SetLegacyRowVersionNullBehaviour(false);
bool? originalValue = SetLegacyRowVersionNullBehavior(false);
try
{
using (SqlConnection con = new SqlConnection(DataTestUtility.TCPConnectionString))
Expand All @@ -318,7 +318,7 @@ public static void CheckNullRowVersionIsBDNull()
}
finally
{
SetLegacyRowVersionNullBehaviour(originalValue);
SetLegacyRowVersionNullBehavior(originalValue);
}
}
}
Expand All @@ -328,7 +328,7 @@ public static void CheckLegacyNullRowVersionIsEmptyArray()
{
lock (s_rowVersionLock)
{
bool? originalValue = SetLegacyRowVersionNullBehaviour(true);
bool? originalValue = SetLegacyRowVersionNullBehavior(true);
try
{
using (SqlConnection con = new SqlConnection(DataTestUtility.TCPConnectionString))
Expand All @@ -351,15 +351,15 @@ public static void CheckLegacyNullRowVersionIsEmptyArray()
}
finally
{
SetLegacyRowVersionNullBehaviour(originalValue);
SetLegacyRowVersionNullBehavior(originalValue);
}
}
}

private static bool? SetLegacyRowVersionNullBehaviour(bool? value)
private static bool? SetLegacyRowVersionNullBehavior(bool? value)
{
Type switchesType = typeof(SqlCommand).Assembly.GetType("Microsoft.Data.SqlClient.LocalAppContextSwitches");
FieldInfo switchField = switchesType.GetField("s_legacyRowVersionNullBehaviour", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
FieldInfo switchField = switchesType.GetField("s_LegacyRowVersionNullBehavior", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
bool? originalValue = (bool?)switchField.GetValue(null);
switchField.SetValue(null, value);
return originalValue;
Expand Down

0 comments on commit 3a325e9

Please sign in to comment.