Skip to content
Open
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 @@ -1707,9 +1707,9 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
case TdsEnums.SQLJSON:
// Could be either string, SqlCachedBuffer, XmlReader or XmlDataFeed
Debug.Assert((value is XmlReader) || (value is SqlCachedBuffer) || (value is string) || (value is SqlString) || (value is XmlDataFeed), "Invalid value type of Xml datatype");
if (value is XmlReader)
if (value is XmlReader xmlReader)
{
value = new XmlDataFeed((XmlReader)value);
value = new XmlDataFeed(xmlReader);
typeChanged = true;
coercedToDataFeed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul
{
throw ADP.ArgumentNull(nameof(destinationType));
}
if ((typeof(InstanceDescriptor) == destinationType) && (value is SqlParameter))
if ((typeof(InstanceDescriptor) == destinationType) && (value is SqlParameter parameter))
{
return ConvertToInstanceDescriptor(value as SqlParameter);
return ConvertToInstanceDescriptor(parameter);
}
return base.ConvertTo(context, culture, value, destinationType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10664,9 +10664,9 @@ private Task TDSExecuteRPCAddParameter(TdsParserStateObject stateObj, SqlParamet

if (isSqlVal)
{
if (value is SqlString)
if (value is SqlString sqlString)
{
s = ((SqlString)value).Value;
s = sqlString.Value;
}
else
{
Expand Down Expand Up @@ -11994,9 +11994,9 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
break;
case TdsEnums.SQLXMLTYPE:
// Value here could be string or XmlReader
if (value is XmlReader)
if (value is XmlReader xmlReader)
{
value = MetaType.GetStringFromXml((XmlReader)value);
value = MetaType.GetStringFromXml(xmlReader);
}
ccb = ((isSqlType) ? ((SqlString)value).Value.Length : ((string)value).Length) * 2;
break;
Expand Down Expand Up @@ -12468,9 +12468,9 @@ private Task WriteUnterminatedSqlValue(object value, MetaType type, int actualLe
WriteInt(actualLength, stateObj); // chunk length
}

if (value is SqlBinary)
if (value is SqlBinary sqlBinary)
{
return stateObj.WriteByteArray(((SqlBinary)value).Value, actualLength, offset, canAccumulate: false);
return stateObj.WriteByteArray(sqlBinary.Value, actualLength, offset, canAccumulate: false);
}
else
{
Expand Down Expand Up @@ -12537,9 +12537,9 @@ private Task WriteUnterminatedSqlValue(object value, MetaType type, int actualLe
{
WriteInt(codePageByteSize, stateObj); // chunk length
}
if (value is SqlChars)
if (value is SqlChars sqlCharsA)
{
string sch = new string(((SqlChars)value).Value);
string sch = new string(sqlCharsA.Value);

Comment on lines +12540 to 12543
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suffix "A" on sqlCharsA isn’t meaningful here and reduces readability. Since the pattern variable is scoped to the if block, consider renaming to sqlChars (or another descriptive name) without the letter suffix.

Copilot uses AI. Check for mistakes.
return WriteEncodingChar(sch, actualLength, offset, _defaultEncoding, stateObj, canAccumulate: false);
}
Expand Down Expand Up @@ -12583,9 +12583,9 @@ private Task WriteUnterminatedSqlValue(object value, MetaType type, int actualLe
actualLength >>= 1;
}

if (value is SqlChars)
if (value is SqlChars sqlCharsB)
{
return WriteCharArray(((SqlChars)value).Value, actualLength, offset, stateObj, canAccumulate: false);
return WriteCharArray(sqlCharsB.Value, actualLength, offset, stateObj, canAccumulate: false);
Comment on lines +12586 to +12588
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlCharsB uses a letter suffix that doesn’t convey meaning. Consider renaming to sqlChars to match usage elsewhere in the codebase and keep the pattern variable names consistent.

Copilot uses AI. Check for mistakes.
}
else
{
Expand Down Expand Up @@ -13633,9 +13633,9 @@ private byte[] SerializeUnencryptedSqlValue(object value, MetaType type, int act
{
byte[] b = new byte[actualLength];

if (value is SqlBinary)
if (value is SqlBinary sqlBinary2)
{
Buffer.BlockCopy(((SqlBinary)value).Value, offset, b, 0, actualLength);
Buffer.BlockCopy(sqlBinary2.Value, offset, b, 0, actualLength);
Comment on lines +13636 to +13638
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlBinary2 uses a numeric suffix that doesn’t add meaning (it’s already scoped to this block). Consider renaming to sqlBinary for clarity and consistency with other pattern variables in this file.

Copilot uses AI. Check for mistakes.
}
else
{
Expand Down Expand Up @@ -13686,9 +13686,9 @@ private byte[] SerializeUnencryptedSqlValue(object value, MetaType type, int act
case TdsEnums.SQLBIGCHAR:
case TdsEnums.SQLBIGVARCHAR:
case TdsEnums.SQLTEXT:
if (value is SqlChars)
if (value is SqlChars sqlCharsC)
{
String sch = new String(((SqlChars)value).Value);
String sch = new String(sqlCharsC.Value);
return SerializeEncodingChar(sch, actualLength, offset, _defaultEncoding);
Comment on lines +13689 to 13692
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlCharsC introduces a letter suffix that isn’t meaningful. Consider renaming to sqlChars (the variable is block-scoped) to improve readability.

Copilot uses AI. Check for mistakes.
}
else
Expand All @@ -13709,9 +13709,9 @@ private byte[] SerializeUnencryptedSqlValue(object value, MetaType type, int act
actualLength >>= 1;
}

if (value is SqlChars)
if (value is SqlChars sqlCharsD)
{
return SerializeCharArray(((SqlChars)value).Value, actualLength, offset);
return SerializeCharArray(sqlCharsD.Value, actualLength, offset);
Comment on lines +13712 to +13714
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlCharsD uses a letter suffix that doesn’t convey intent. Consider renaming to sqlChars to keep pattern variable naming consistent and easier to scan.

Copilot uses AI. Check for mistakes.
}
else
{
Expand Down
Loading