diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..032c1bd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto + diff --git a/benchmark/protobuf-net-data.Benchmarks/DataReaderMock.cs b/benchmark/protobuf-net-data.Benchmarks/DataReaderMock.cs index 94fb263..8a5e39c 100644 --- a/benchmark/protobuf-net-data.Benchmarks/DataReaderMock.cs +++ b/benchmark/protobuf-net-data.Benchmarks/DataReaderMock.cs @@ -172,7 +172,7 @@ public bool NextResult() public bool Read() { - return ++this.rowIndex < rowCount; + return ++this.rowIndex < this.rowCount; } private object GetDefault(Type type) diff --git a/protobuf-net-data.sln b/protobuf-net-data.sln index fc5cadd..e8524e1 100644 --- a/protobuf-net-data.sln +++ b/protobuf-net-data.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27428.2005 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31919.166 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "protobuf-net-data", "src\protobuf-net-data\protobuf-net-data.csproj", "{4F6074E7-D9B1-491D-841B-53A752EC1625}" EndProject @@ -27,7 +27,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "protobuf-net-data.Benchmark EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{255B1CD0-4B1F-4601-9176-F36EE56CEF4D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "protobuf-net-data.TestDataGenerator", "tools\protobuf-net-data.TestDataGenerator\protobuf-net-data.TestDataGenerator.csproj", "{4310BE9C-AACD-4071-8675-709E9929138B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "protobuf-net-data.TestDataGenerator", "tools\protobuf-net-data.TestDataGenerator\protobuf-net-data.TestDataGenerator.csproj", "{4310BE9C-AACD-4071-8675-709E9929138B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/protobuf-net-data/Internal/ColumnsWriter.cs b/src/protobuf-net-data/Internal/ColumnsWriter.cs index 390e2e1..5297540 100644 --- a/src/protobuf-net-data/Internal/ColumnsWriter.cs +++ b/src/protobuf-net-data/Internal/ColumnsWriter.cs @@ -31,7 +31,7 @@ private static void WriteColumnName(ProtoWriterContext context, ProtoDataColumn private static void WriteColumnType(ProtoWriterContext context, ProtoDataColumn column) { - ProtoWriter.WriteFieldHeader(ColumnTypeFieldHeader, WireType.Variant, context.Writer); + ProtoWriter.WriteFieldHeader(ColumnTypeFieldHeader, WireType.Varint, context.Writer); ProtoWriter.WriteInt32((int)column.ProtoDataType, context.Writer); } } diff --git a/src/protobuf-net-data/Internal/ProtoWriterContext.cs b/src/protobuf-net-data/Internal/ProtoWriterContext.cs index 57274cb..7d9fc46 100644 --- a/src/protobuf-net-data/Internal/ProtoWriterContext.cs +++ b/src/protobuf-net-data/Internal/ProtoWriterContext.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System.Collections.Generic; namespace ProtoBuf.Data.Internal @@ -31,3 +32,4 @@ public void EndSubItem() } } } +#pragma warning restore CS0618 diff --git a/src/protobuf-net-data/Internal/RecordWriter.cs b/src/protobuf-net-data/Internal/RecordWriter.cs index 75e313d..d6c0f49 100644 --- a/src/protobuf-net-data/Internal/RecordWriter.cs +++ b/src/protobuf-net-data/Internal/RecordWriter.cs @@ -36,7 +36,7 @@ public static void WriteRecord(ProtoWriterContext context, int recordIndex, IDat break; case ProtoDataType.Short: - ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Variant, context.Writer); + ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Varint, context.Writer); ProtoWriter.WriteInt16(record.GetInt16(columnIndex), context.Writer); break; @@ -46,7 +46,7 @@ public static void WriteRecord(ProtoWriterContext context, int recordIndex, IDat break; case ProtoDataType.Int: - ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Variant, context.Writer); + ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Varint, context.Writer); ProtoWriter.WriteInt32(record.GetInt32(columnIndex), context.Writer); break; @@ -61,17 +61,17 @@ public static void WriteRecord(ProtoWriterContext context, int recordIndex, IDat break; case ProtoDataType.Bool: - ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Variant, context.Writer); + ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Varint, context.Writer); ProtoWriter.WriteBoolean(record.GetBoolean(columnIndex), context.Writer); break; case ProtoDataType.Byte: - ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Variant, context.Writer); + ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Varint, context.Writer); ProtoWriter.WriteByte(record.GetByte(columnIndex), context.Writer); break; case ProtoDataType.Char: - ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Variant, context.Writer); + ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Varint, context.Writer); ProtoWriter.WriteInt16((short)record.GetChar(columnIndex), context.Writer); break; @@ -86,7 +86,7 @@ public static void WriteRecord(ProtoWriterContext context, int recordIndex, IDat break; case ProtoDataType.Long: - ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Variant, context.Writer); + ProtoWriter.WriteFieldHeader(fieldNumber, WireType.Varint, context.Writer); ProtoWriter.WriteInt64(record.GetInt64(columnIndex), context.Writer); break; diff --git a/src/protobuf-net-data/ProtoDataReader.cs b/src/protobuf-net-data/ProtoDataReader.cs index 8ae62d2..4133e36 100644 --- a/src/protobuf-net-data/ProtoDataReader.cs +++ b/src/protobuf-net-data/ProtoDataReader.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -35,7 +36,7 @@ public ProtoDataReader(Stream stream) } this.stream = stream; - this.reader = new ProtoReader(stream, null, null); + this.reader = ProtoReader.Create(stream, null, null); this.context = new ProtoReaderContext(this.reader); ResultReader.ReadResult(this.context); @@ -606,41 +607,41 @@ private void Dispose(bool disposing) { // via case sensitive search, first match with lowest ordinal matches var ordinal = this.GetColumnOrdinalByName(name, CompareOptions.None); - if (ordinal.HasValue) - { - return ordinal; + if (ordinal.HasValue) + { + return ordinal; } // via case insensitive search, first match with lowest ordinal matches - ordinal = this.GetColumnOrdinalByName(name, CompareOptions.IgnoreCase); - if (ordinal.HasValue) - { - return ordinal; - } - - // do the slow search now (kana, width insensitive comparison) - var compareOptions = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; + ordinal = this.GetColumnOrdinalByName(name, CompareOptions.IgnoreCase); + if (ordinal.HasValue) + { + return ordinal; + } + + // do the slow search now (kana, width insensitive comparison) + var compareOptions = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; ordinal = this.GetColumnOrdinalByName(name, compareOptions); - if (ordinal.HasValue) - { - return ordinal; - } - + if (ordinal.HasValue) + { + return ordinal; + } + return null; } - private int? GetColumnOrdinalByName(string name, CompareOptions compareOptions) - { - var compareInfo = CultureInfo.InvariantCulture.CompareInfo; + private int? GetColumnOrdinalByName(string name, CompareOptions compareOptions) + { + var compareInfo = CultureInfo.InvariantCulture.CompareInfo; for (var ordinal = 0; ordinal < this.context.Columns.Count; ordinal++) { if (compareInfo.Compare(name, this.context.Columns[ordinal].Name, compareOptions) == 0) { return ordinal; } - } - - return null; + } + + return null; } private DataTable BuildSchemaTable() @@ -775,4 +776,5 @@ private void ThrowIfNoData() } } } -} \ No newline at end of file +} +#pragma warning restore CS0618 diff --git a/src/protobuf-net-data/ProtoDataStream.cs b/src/protobuf-net-data/ProtoDataStream.cs index 5fcbbf4..ca43097 100644 --- a/src/protobuf-net-data/ProtoDataStream.cs +++ b/src/protobuf-net-data/ProtoDataStream.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -134,7 +135,7 @@ public ProtoDataStream( this.resultIndex = 0; this.bufferStream = new CircularStream(bufferSize); - this.writer = new ProtoWriter(this.bufferStream, null, null); + this.writer = ProtoWriter.Create(this.bufferStream, null, null); this.context = new ProtoWriterContext(this.writer, this.options); } @@ -368,4 +369,5 @@ private void FillBuffer(int requestedLength) } } } -} \ No newline at end of file +} +#pragma warning restore CS0618 diff --git a/src/protobuf-net-data/ProtoDataWriter.cs b/src/protobuf-net-data/ProtoDataWriter.cs index 0917bc3..0ec74bc 100644 --- a/src/protobuf-net-data/ProtoDataWriter.cs +++ b/src/protobuf-net-data/ProtoDataWriter.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System.Data; using System.IO; using ProtoBuf.Data.Internal; @@ -78,7 +79,7 @@ public void Serialize(Stream stream, IDataReader reader, ProtoDataWriterOptions var resultIndex = 0; - using (var writer = new ProtoWriter(stream, null, null)) + using (var writer = ProtoWriter.Create(stream, null, null)) { var context = new ProtoWriterContext(writer, options); @@ -106,7 +107,11 @@ public void Serialize(Stream stream, IDataReader reader, ProtoDataWriterOptions resultIndex++; } while (reader.NextResult()); + + // necessary since protobuf-net v3 + writer.Close(); } } } -} \ No newline at end of file +} +#pragma warning restore CS0618 diff --git a/src/protobuf-net-data/protobuf-net-data.csproj b/src/protobuf-net-data/protobuf-net-data.csproj index fd85877..b7ddd3c 100644 --- a/src/protobuf-net-data/protobuf-net-data.csproj +++ b/src/protobuf-net-data/protobuf-net-data.csproj @@ -1,4 +1,4 @@ - + true @@ -6,7 +6,7 @@ embedded true false - net20;net30;net35;net40;net45;netstandard2.0 + net461;netstandard2.0 true 0.0.0 @@ -30,7 +30,7 @@ - + diff --git a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs index 82afca4..b9c5c9c 100644 --- a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs +++ b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -12,34 +13,13 @@ public partial class ColumnsReaderTests { public class TheReadColumnsMethod : ColumnsReaderTests { - [Fact] - public void ShouldThrowExceptionOnColumnsInvalidFieldHeader() - { - // Arrange - var stream = new MemoryStream(); - - using (var writer = new ProtoWriter(stream, null, null)) - { - ProtoWriter.WriteFieldHeader(1, WireType.StartGroup, writer); - - ProtoWriter.StartSubItem(0, writer); - - ProtoWriter.WriteFieldHeader(42, WireType.StartGroup, writer); - } - - stream.Position = 0; - - // Assert - Assert.Throws(() => new ProtoDataReader(stream)); - } - [Fact] public void ShouldThrowExceptionOnColumnNameInvalidFieldHeader() { // Arrange var stream = new MemoryStream(); - using (var writer = new ProtoWriter(stream, null, null)) + using (var writer = ProtoWriter.Create(stream, null, null)) { ProtoWriter.WriteFieldHeader(1, WireType.StartGroup, writer); @@ -55,6 +35,8 @@ public void ShouldThrowExceptionOnColumnNameInvalidFieldHeader() ProtoWriter.EndSubItem(columnToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; @@ -69,7 +51,7 @@ public void ShouldThrowExceptionOnColumnTypeInvalidFieldHeader() // Arrange var stream = new MemoryStream(); - using (var writer = new ProtoWriter(stream, null, null)) + using (var writer = ProtoWriter.Create(stream, null, null)) { ProtoWriter.WriteFieldHeader(1, WireType.StartGroup, writer); @@ -81,12 +63,14 @@ public void ShouldThrowExceptionOnColumnTypeInvalidFieldHeader() ProtoWriter.WriteFieldHeader(1, WireType.String, writer); ProtoWriter.WriteString("foo", writer); - ProtoWriter.WriteFieldHeader(42, WireType.Variant, writer); + ProtoWriter.WriteFieldHeader(42, WireType.Varint, writer); ProtoWriter.WriteInt32((int)1, writer); ProtoWriter.EndSubItem(columnToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; @@ -101,7 +85,7 @@ public void ShouldAcceptTrailingFieldHeaders() // Arrange var stream = new MemoryStream(); - using (var writer = new ProtoWriter(stream, null, null)) + using (var writer = ProtoWriter.Create(stream, null, null)) { ProtoWriter.WriteFieldHeader(1, WireType.StartGroup, writer); @@ -113,7 +97,7 @@ public void ShouldAcceptTrailingFieldHeaders() ProtoWriter.WriteFieldHeader(1, WireType.String, writer); ProtoWriter.WriteString("foo", writer); - ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); + ProtoWriter.WriteFieldHeader(2, WireType.Varint, writer); ProtoWriter.WriteInt32((int)1, writer); ProtoWriter.WriteFieldHeader(42, WireType.String, writer); ProtoWriter.WriteString("bar", writer); @@ -121,6 +105,8 @@ public void ShouldAcceptTrailingFieldHeaders() ProtoWriter.EndSubItem(columnToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; @@ -131,3 +117,4 @@ public void ShouldAcceptTrailingFieldHeaders() } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs b/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs index 47b1852..9640261 100644 --- a/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs +++ b/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -33,7 +34,7 @@ public void ShouldSerializeColumnName() var dataReader = dataTable.CreateDataReader(); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -61,7 +62,7 @@ public void ShouldSerializeExpressionColumn() var options = new ProtoDataWriterOptions() { IncludeComputedColumns = true }; // Act - var reader = new ProtoReader(this.Serialize(dataReader, options), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader, options), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -93,7 +94,7 @@ public void ShouldNotSerializeExpressionColumn() var options = new ProtoDataWriterOptions() { IncludeComputedColumns = false }; // Act - var reader = new ProtoReader(this.Serialize(dataReader, options), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader, options), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -127,7 +128,7 @@ public void ShouldNotSerializeExpressionColumnOnMono() var options = new ProtoDataWriterOptions() { IncludeComputedColumns = false }; // Act - var reader = new ProtoReader(this.Serialize(dataReader, options), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader, options), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -153,3 +154,4 @@ private Stream Serialize(IDataReader dataReader, ProtoDataWriterOptions options } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/ProtoDataReaderTests.TheNextResultMethod.cs b/test/protobuf-net-data.Tests/ProtoDataReaderTests.TheNextResultMethod.cs index 7a64e3b..f37dd5a 100644 --- a/test/protobuf-net-data.Tests/ProtoDataReaderTests.TheNextResultMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoDataReaderTests.TheNextResultMethod.cs @@ -124,7 +124,7 @@ public void ShouldExtendBuffers() dataSet.Tables.Add(new DataTable()); dataSet.Tables[0].Columns.Add("foo", typeof(string)); - dataSet.Tables[1].Columns.Add("bar", typeof(string)); + dataSet.Tables[1].Columns.Add("bar", typeof(string)); dataSet.Tables[1].Columns.Add("baz", typeof(string)); dataSet.Tables[0].Rows.Add("qux"); diff --git a/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs b/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs index 6745233..0328b7f 100644 --- a/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -48,7 +49,7 @@ public void ShouldSerializeUsingMultipleIterations() // Assert outputStream.Position = 0; - var reader = new ProtoReader(outputStream, null, null); + var reader = ProtoReader.Create(outputStream, null, null); Assert.Equal(ResultFieldHeader, reader.ReadFieldHeader()); } @@ -68,7 +69,7 @@ public void ShouldSerializeColumns() var stream = new ProtoDataStream(dataReader); // Act - var reader = new ProtoReader(this.CopyStream(stream), null, null); + var reader = ProtoReader.Create(this.CopyStream(stream), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -88,7 +89,7 @@ public void ShouldSerializeField() var stream = new ProtoDataStream(dataReader); // Act - var reader = new ProtoReader(this.CopyStream(stream), null, null); + var reader = ProtoReader.Create(this.CopyStream(stream), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -118,7 +119,7 @@ public void ShouldSerializeMultipleResults() var stream = new ProtoDataStream(dataReader); // Act - var reader = new ProtoReader(this.CopyStream(stream), null, null); + var reader = ProtoReader.Create(this.CopyStream(stream), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -150,7 +151,7 @@ public void ShouldSerializeSuccessiveResultColumns() var stream = new ProtoDataStream(dataReader); // Act - var reader = new ProtoReader(this.CopyStream(stream), null, null); + var reader = ProtoReader.Create(this.CopyStream(stream), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -194,3 +195,4 @@ private Stream CopyStream(Stream inputStream) } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs b/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs index 9b7ee99..3b54c90 100644 --- a/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -54,7 +55,7 @@ public void ShouldSerializeMultipleResults() var dataReader = dataSet.CreateDataReader(); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -88,3 +89,4 @@ private IDataReader CreateDataReader(TDataType value) } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs b/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs index 7de787a..9aaa13f 100644 --- a/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs +++ b/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -18,7 +19,7 @@ public void ShouldAcceptTrailingFieldHeaders() // Arrange var stream = new MemoryStream(); - using (var writer = new ProtoWriter(stream, null, null)) + using (var writer = ProtoWriter.Create(stream, null, null)) { ProtoWriter.WriteFieldHeader(1, WireType.StartGroup, writer); @@ -30,7 +31,7 @@ public void ShouldAcceptTrailingFieldHeaders() ProtoWriter.WriteFieldHeader(1, WireType.String, writer); ProtoWriter.WriteString("foo", writer); - ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); + ProtoWriter.WriteFieldHeader(2, WireType.Varint, writer); ProtoWriter.WriteInt32((int)3, writer); ProtoWriter.EndSubItem(columnToken, writer); @@ -39,14 +40,16 @@ public void ShouldAcceptTrailingFieldHeaders() var recordToken = ProtoWriter.StartSubItem(1, writer); - ProtoWriter.WriteFieldHeader(1, WireType.Variant, writer); + ProtoWriter.WriteFieldHeader(1, WireType.Varint, writer); ProtoWriter.WriteInt32((int)1, writer); - ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); + ProtoWriter.WriteFieldHeader(2, WireType.Varint, writer); ProtoWriter.WriteInt32((int)1, writer); ProtoWriter.EndSubItem(recordToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; @@ -59,3 +62,4 @@ public void ShouldAcceptTrailingFieldHeaders() } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs b/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs index b01597c..1545949 100644 --- a/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs +++ b/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -20,7 +21,7 @@ public void ShouldSerializeStringValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -37,7 +38,7 @@ public void ShouldSerializeStringColumnType() var dataReader = this.CreateDataReader("foo"); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -55,7 +56,7 @@ public void ShouldSerializeDateTimeValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -72,7 +73,7 @@ public void ShouldSerializeDateTimeColumnType() var dataReader = this.CreateDataReader(new DateTime(1969, 10, 29, 22, 30, 0)); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -90,7 +91,7 @@ public void ShouldSerializeInt32Value() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -107,7 +108,7 @@ public void ShouldSerializeInt32ColumnType() var dataReader = this.CreateDataReader(42); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -125,7 +126,7 @@ public void ShouldSerializeInt64Value() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -142,7 +143,7 @@ public void ShouldSerializeInt64ColumnType() var dataReader = this.CreateDataReader(42L); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -160,7 +161,7 @@ public void ShouldSerializeInt16Value() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -177,7 +178,7 @@ public void ShouldSerializeInt16ColumnType() var dataReader = this.CreateDataReader((short)42); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -195,7 +196,7 @@ public void ShouldSerializeBooleanValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -212,7 +213,7 @@ public void ShouldSerializeBooleanColumnType() var dataReader = this.CreateDataReader(true); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -230,7 +231,7 @@ public void ShouldSerializeByteValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -247,7 +248,7 @@ public void ShouldSerializeByteColumnType() var dataReader = this.CreateDataReader((byte)42); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -265,7 +266,7 @@ public void ShouldSerializeFloatValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -282,7 +283,7 @@ public void ShouldSerializeFloatColumnType() var dataReader = this.CreateDataReader(42f); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -300,7 +301,7 @@ public void ShouldSerializeDoubleValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -317,7 +318,7 @@ public void ShouldSerializeDoubleColumnType() var dataReader = this.CreateDataReader(42d); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -335,7 +336,7 @@ public void ShouldSerializeGuidValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -352,7 +353,7 @@ public void ShouldSerializeGuidColumnType() var dataReader = this.CreateDataReader(Guid.NewGuid()); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -370,7 +371,7 @@ public void ShouldSerializeCharValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -387,7 +388,7 @@ public void ShouldSerializeCharColumnType() var dataReader = this.CreateDataReader(';'); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -405,7 +406,7 @@ public void ShouldSerializeDecimalValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -422,7 +423,7 @@ public void ShouldSerializeDecimalColumnType() var dataReader = this.CreateDataReader(42m); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -440,7 +441,7 @@ public void ShouldSerializeByteArrayValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -458,7 +459,7 @@ public void ShouldSerializeEmptyByteArrayAsNull() var options = new ProtoDataWriterOptions() { SerializeEmptyArraysAsNull = true }; // Act - var reader = new ProtoReader(this.Serialize(dataReader, options), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader, options), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -478,7 +479,7 @@ public void ShouldSerializeByteArrayColumnType() var dataReader = this.CreateDataReader(new[] { (byte)42, (byte)42 }); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -496,7 +497,7 @@ public void ShouldSerializeCharArrayValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -514,7 +515,7 @@ public void ShouldSerializeEmptyCharArrayAsNull() var options = new ProtoDataWriterOptions() { SerializeEmptyArraysAsNull = true }; // Act - var reader = new ProtoReader(this.Serialize(dataReader, options), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader, options), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -534,7 +535,7 @@ public void ShouldSerializeCharArrayColumnType() var dataReader = this.CreateDataReader(new[] { 'f', 'o', 'o' }); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -552,7 +553,7 @@ public void ShouldSerializeTimeSpanValue() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -569,7 +570,7 @@ public void ShouldSerializeTimeSpanColumnType() var dataReader = this.CreateDataReader(TimeSpan.FromTicks(1)); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -587,7 +588,7 @@ public void ShouldNotSerializeIfValueIsNull() var dataReader = this.CreateDataReader(value); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -612,7 +613,7 @@ public void ShouldNotSerializeIfValueIsDBNull() var dataReader = dataTable.CreateDataReader(); // Act - var reader = new ProtoReader(this.Serialize(dataReader), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -633,7 +634,7 @@ public void ShouldNotSerializeIfValueIsEmptyArray() var options = new ProtoDataWriterOptions() { SerializeEmptyArraysAsNull = true }; // Act - var reader = new ProtoReader(this.Serialize(dataReader, options), null, null); + var reader = ProtoReader.Create(this.Serialize(dataReader, options), null, null); // Assert var readerContext = new ProtoReaderContext(reader); @@ -669,3 +670,4 @@ private Stream Serialize(IDataReader dataReader, ProtoDataWriterOptions options } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs b/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs index 2aaba1a..f55e4b8 100644 --- a/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs +++ b/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs @@ -1,5 +1,6 @@ // Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. +#pragma warning disable CS0618 using System; using System.Collections.Generic; using System.Data; @@ -18,9 +19,11 @@ public void ShouldThrowExceptionOnInvalidFieldHeader() // Arrange var stream = new MemoryStream(); - using (var writer = new ProtoWriter(stream, null, null)) + using (var writer = ProtoWriter.Create(stream, null, null)) { ProtoWriter.WriteFieldHeader(42, WireType.StartGroup, writer); + + writer.Close(); } stream.Position = 0; @@ -31,3 +34,4 @@ public void ShouldThrowExceptionOnInvalidFieldHeader() } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj index 8c1a12d..4ffd114 100644 --- a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj +++ b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj @@ -3,7 +3,7 @@ full false - net40;net471;netcoreapp2.0 + net461;net471;netcoreapp2.0 true @@ -11,11 +11,10 @@ - - - - + + + @@ -23,16 +22,6 @@ - - - - - - - - - - diff --git a/tools/protobuf-net-data.TestDataGenerator/Program.cs b/tools/protobuf-net-data.TestDataGenerator/Program.cs index 1a1aa92..ef41522 100644 --- a/tools/protobuf-net-data.TestDataGenerator/Program.cs +++ b/tools/protobuf-net-data.TestDataGenerator/Program.cs @@ -1,4 +1,6 @@ -using System; +// Copyright (c) Richard Dingwall, Arjen Post. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; using System.Data; using System.Diagnostics;