Skip to content

Commit 92ea063

Browse files
authored
Cleanup | Remove unused UDT serialization code (#3462)
* Remove _isTopLevelUdt and its usage This always holds the constant value of true. Code paths which rely on it being false will never be called. * Remove unused property and fields IsNullable and _padBuffer were only referenced when _isTopLevelUdt was false. _nullInstance was only referenced from IsNullable * Remove _skipNormalize This was always set to false * Remove unused parameter from constructor * Remove needless call to GetFormat * Remove unused fields These fields are assigned to, but never used * Remove unused parameter SqlConnection.GetBytes output a Format parameter which was never used at its call sites * Remove incorrect comment
1 parent 4bbf8c6 commit 92ea063

File tree

8 files changed

+79
-241
lines changed

8 files changed

+79
-241
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,11 +2547,10 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
25472547
}
25482548
}
25492549

2550-
internal byte[] GetBytes(object o, out Format format, out int maxSize)
2550+
internal byte[] GetBytes(object o, out int maxSize)
25512551
{
25522552
SqlUdtInfo attr = GetInfoFromType(o.GetType());
25532553
maxSize = attr.MaxByteSize;
2554-
format = attr.SerializationFormat;
25552554

25562555
if (maxSize < -1 || maxSize >= ushort.MaxValue)
25572556
{

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9943,7 +9943,6 @@ private Task TDSExecuteRPCAddParameter(TdsParserStateObject stateObj, SqlParamet
99439943
{
99449944
int maxSupportedSize = Is2008OrNewer ? int.MaxValue : short.MaxValue;
99459945
byte[] udtVal = null;
9946-
Format format = Format.Native;
99479946

99489947
if (string.IsNullOrEmpty(param.UdtTypeName))
99499948
{
@@ -9977,7 +9976,7 @@ private Task TDSExecuteRPCAddParameter(TdsParserStateObject stateObj, SqlParamet
99779976
}
99789977
else
99799978
{
9980-
udtVal = _connHandler.Connection.GetBytes(value, out format, out maxsize);
9979+
udtVal = _connHandler.Connection.GetBytes(value, out maxsize);
99819980
}
99829981

99839982
Debug.Assert(udtVal != null, "GetBytes returned null instance. Make sure that it always returns non-null value");

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,11 +2456,10 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
24562456
}
24572457
}
24582458

2459-
internal byte[] GetBytes(object o, out Format format, out int maxSize)
2459+
internal byte[] GetBytes(object o, out int maxSize)
24602460
{
24612461
SqlUdtInfo attr = GetInfoFromType(o.GetType());
24622462
maxSize = attr.MaxByteSize;
2463-
format = attr.SerializationFormat;
24642463

24652464
if (maxSize < -1 || maxSize >= ushort.MaxValue)
24662465
{

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10139,7 +10139,6 @@ private Task TDSExecuteRPCAddParameter(TdsParserStateObject stateObj, SqlParamet
1013910139
{
1014010140
int maxSupportedSize = Is2008OrNewer ? int.MaxValue : short.MaxValue;
1014110141
byte[] udtVal = null;
10142-
Format format = Format.Native;
1014310142

1014410143
if (string.IsNullOrEmpty(param.UdtTypeName))
1014510144
{
@@ -10173,7 +10172,7 @@ private Task TDSExecuteRPCAddParameter(TdsParserStateObject stateObj, SqlParamet
1017310172
}
1017410173
else
1017510174
{
10176-
udtVal = _connHandler.Connection.GetBytes(value, out format, out maxsize);
10175+
udtVal = _connHandler.Connection.GetBytes(value, out maxsize);
1017710176
}
1017810177

1017910178
Debug.Assert(udtVal != null, "GetBytes returned null instance. Make sure that it always returns non-null value");

0 commit comments

Comments
 (0)