Skip to content

Commit f9136f9

Browse files
committed
Declare and assign variables together
1 parent 62edb70 commit f9136f9

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/UdtSerialization/NativeSerializationTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,13 @@ public void CannotSerializeNonPrimitiveType()
260260
private static void RoundtripType(object inputValue, byte[] expectedValue)
261261
{
262262
using MemoryStream stream = new();
263-
object readPrimitive;
264263
int typeSize = SerializationHelperSql9.SizeInBytes(inputValue.GetType());
265264
int objectSize = SerializationHelperSql9.SizeInBytes(inputValue);
266265
int maxTypeSize = SerializationHelperSql9.GetUdtMaxLength(inputValue.GetType());
267266

268267
SerializationHelperSql9.Serialize(stream, inputValue);
269268
stream.Seek(0, SeekOrigin.Begin);
270-
readPrimitive = SerializationHelperSql9.Deserialize(stream, inputValue.GetType());
269+
object readPrimitive = SerializationHelperSql9.Deserialize(stream, inputValue.GetType());
271270

272271
// For native formatting, the type size, the object size and the maximum object size will always be identical
273272
Assert.Equal(typeSize, objectSize);

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/UdtSerialization/UserDefinedSerializationTest.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,14 @@ private static void RoundtripType<T>(T userObject)
6565
where T : IFormattingProgress
6666
{
6767
using MemoryStream stream = new();
68-
byte[] serializedValue;
69-
T readInstance;
7068
int typeSize = SerializationHelperSql9.SizeInBytes(userObject.GetType());
7169
int objectSize = SerializationHelperSql9.SizeInBytes(userObject);
7270
int maxTypeSize = SerializationHelperSql9.GetUdtMaxLength(userObject.GetType());
7371

7472
SerializationHelperSql9.Serialize(stream, userObject);
75-
serializedValue = stream.ToArray();
7673
stream.Seek(0, SeekOrigin.Begin);
77-
readInstance = (T)SerializationHelperSql9.Deserialize(stream, userObject.GetType());
74+
byte[] serializedValue = stream.ToArray();
75+
T readInstance = (T)SerializationHelperSql9.Deserialize(stream, userObject.GetType());
7876

7977
// If this is a struct, it will have been copied by value and the write to WriteInvoked will have been made
8078
// to another copy of our object

0 commit comments

Comments
 (0)