diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs index aea7a5c0..15caa32a 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs @@ -81,6 +81,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage {typeof(DateTimeOffset), (o, id, col) => ReadDateTimeOffset(o, id)}, {typeof(TimeSpan), (o, id, col) => ReadTimeSpan(o, id)}, {typeof(byte[]), (o, id, col) => ReadBytes(o, id)}, + {typeof(Guid), (o, id, col) => ReadGuid(o, id)}, {typeof(SqlString), (o, id, col) => ReadString(o, id)}, {typeof(SqlInt16), (o, id, col) => ReadInt16(o, id)}, @@ -467,14 +468,14 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage /// /// Offset into the file to read the bytes from /// Internal ID of the row that will be stored in the cell - /// A guid type object + /// A system guid type object internal FileStreamReadResult ReadGuid(long offset, long rowId) { return ReadCellHelper(offset, rowId, length => { byte[] output = new byte[length]; Buffer.BlockCopy(buffer, 0, output, 0, length); - return new SqlGuid(output); + return new Guid(output); }, totalLength => totalLength == 1); } diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamWriter.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamWriter.cs index ef554d19..522bdd55 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamWriter.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamWriter.cs @@ -90,6 +90,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage {typeof(DateTimeOffset), val => WriteDateTimeOffset((DateTimeOffset) val) }, {typeof(TimeSpan), val => WriteTimeSpan((TimeSpan) val) }, {typeof(byte[]), val => WriteBytes((byte[]) val)}, + {typeof(Guid), val => WriteGuid((Guid) val)}, {typeof(SqlString), val => WriteNullable((SqlString) val, obj => WriteString((string) obj))}, {typeof(SqlInt16), val => WriteNullable((SqlInt16) val, obj => WriteInt16((short) obj))}, diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/DataStorage/ServiceBufferFileStreamReaderWriterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/DataStorage/ServiceBufferFileStreamReaderWriterTests.cs index b71cf285..2e7beeb1 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/DataStorage/ServiceBufferFileStreamReaderWriterTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/QueryExecution/DataStorage/ServiceBufferFileStreamReaderWriterTests.cs @@ -19,7 +19,7 @@ using Xunit; namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.DataStorage { - public class ReaderWriterPairTest + public class ServiceBufferReaderWriterTests { [Fact] public void ReaderStreamNull() @@ -535,23 +535,25 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.DataStorage (reader, rowId) => reader.ReadBytes(0, rowId)); } - [Fact] - public void GuidTest() + public static IEnumerable GuidTestParameters { - // Setup: - // ... Create some test values - // NOTE: We are doing these here instead of InlineData because Guid type can't be written as constant expressions - Guid[] guids = + get { - Guid.Empty, Guid.NewGuid(), Guid.NewGuid() - }; - foreach (Guid guid in guids) - { - VerifyReadWrite(guid.ToByteArray().Length + 1, new SqlGuid(guid), (writer, val) => writer.WriteGuid(guid), - (reader, rowId) => reader.ReadGuid(0, rowId)); + yield return new object[] {Guid.Empty}; + yield return new object[] {Guid.NewGuid()}; + yield return new object[] {Guid.NewGuid()}; } } + [Theory] + [MemberData(nameof(GuidTestParameters))] + public void GuidTest(Guid testValue) + { + VerifyReadWrite(testValue.ToByteArray().Length + 1, testValue, + (writer, val) => writer.WriteGuid(testValue), + (reader, rowId) => reader.ReadGuid(0, rowId)); + } + [Fact] public void MoneyTest() {