From b3f2a45212785328166b61642df01d5c5fd12a1c Mon Sep 17 00:00:00 2001 From: tjoscht Date: Tue, 20 Oct 2020 16:04:25 +0200 Subject: [PATCH 1/7] NuGet Upgrade to protobuf-net v3. Changed Targets to at least net461. TreatWarningsAsErrors deactivated because of many Obsolete annotations. Fixed Problems with v3 like closing writer. All tests have passed successful. --- src/protobuf-net-data/ProtoDataReader.cs | 2 +- src/protobuf-net-data/ProtoDataStream.cs | 2 +- src/protobuf-net-data/ProtoDataWriter.cs | 5 +- .../protobuf-net-data.csproj | 6 +- ...ColumnsReaderTests.TheReadColumnsMethod.cs | 18 +++-- ...olumnsWriterTests.TheWriteColumnsMethod.cs | 8 +-- .../ProtoDataStreamTests.TheReadMethod.cs | 10 +-- ...ProtoDataWriterTests.TheSerializeMethod.cs | 2 +- .../RecordReaderTests.TheReadRecordMethod.cs | 4 +- .../RecordWriterTests.TheWriteRecordMethod.cs | 70 +++++++++---------- .../ResultReaderTests.TheReadResultMethod.cs | 4 +- .../protobuf-net-data.Tests.csproj | 4 +- 12 files changed, 75 insertions(+), 60 deletions(-) diff --git a/src/protobuf-net-data/ProtoDataReader.cs b/src/protobuf-net-data/ProtoDataReader.cs index 8ae62d2..e759220 100644 --- a/src/protobuf-net-data/ProtoDataReader.cs +++ b/src/protobuf-net-data/ProtoDataReader.cs @@ -35,7 +35,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); diff --git a/src/protobuf-net-data/ProtoDataStream.cs b/src/protobuf-net-data/ProtoDataStream.cs index 5fcbbf4..20f00dc 100644 --- a/src/protobuf-net-data/ProtoDataStream.cs +++ b/src/protobuf-net-data/ProtoDataStream.cs @@ -134,7 +134,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); } diff --git a/src/protobuf-net-data/ProtoDataWriter.cs b/src/protobuf-net-data/ProtoDataWriter.cs index 0917bc3..607c60d 100644 --- a/src/protobuf-net-data/ProtoDataWriter.cs +++ b/src/protobuf-net-data/ProtoDataWriter.cs @@ -78,7 +78,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,6 +106,9 @@ public void Serialize(Stream stream, IDataReader reader, ProtoDataWriterOptions resultIndex++; } while (reader.NextResult()); + + // necessary since protobuf-net v3 + writer.Close(); } } } diff --git a/src/protobuf-net-data/protobuf-net-data.csproj b/src/protobuf-net-data/protobuf-net-data.csproj index fd85877..2f38db8 100644 --- a/src/protobuf-net-data/protobuf-net-data.csproj +++ b/src/protobuf-net-data/protobuf-net-data.csproj @@ -6,8 +6,8 @@ embedded true false - net20;net30;net35;net40;net45;netstandard2.0 - true + net461;netstandard2.0 + false 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..3d52fc6 100644 --- a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs +++ b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs @@ -12,19 +12,21 @@ public partial class ColumnsReaderTests { public class TheReadColumnsMethod : ColumnsReaderTests { - [Fact] + [Fact(Skip = "Upgrade to protobuf-net v3 will raise InvalidOperationException : The writer is in an incomplete state during close")] public void ShouldThrowExceptionOnColumnsInvalidFieldHeader() { // 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); ProtoWriter.StartSubItem(0, writer); ProtoWriter.WriteFieldHeader(42, WireType.StartGroup, writer); + + writer.Close(); } stream.Position = 0; @@ -39,7 +41,7 @@ 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 +57,8 @@ public void ShouldThrowExceptionOnColumnNameInvalidFieldHeader() ProtoWriter.EndSubItem(columnToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; @@ -69,7 +73,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); @@ -87,6 +91,8 @@ public void ShouldThrowExceptionOnColumnTypeInvalidFieldHeader() ProtoWriter.EndSubItem(columnToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; @@ -101,7 +107,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); @@ -121,6 +127,8 @@ public void ShouldAcceptTrailingFieldHeaders() ProtoWriter.EndSubItem(columnToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; diff --git a/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs b/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs index 47b1852..1a502d7 100644 --- a/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs +++ b/test/protobuf-net-data.Tests/ColumnsWriterTests.TheWriteColumnsMethod.cs @@ -33,7 +33,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 +61,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 +93,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 +127,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); diff --git a/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs b/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs index 6745233..47c3150 100644 --- a/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs @@ -48,7 +48,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 +68,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 +88,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 +118,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 +150,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); diff --git a/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs b/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs index 9b7ee99..3f4e7cc 100644 --- a/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoDataWriterTests.TheSerializeMethod.cs @@ -54,7 +54,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); diff --git a/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs b/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs index 7de787a..a449c54 100644 --- a/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs +++ b/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs @@ -18,7 +18,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); @@ -47,6 +47,8 @@ public void ShouldAcceptTrailingFieldHeaders() ProtoWriter.EndSubItem(recordToken, writer); ProtoWriter.EndSubItem(resultToken, writer); + + writer.Close(); } stream.Position = 0; diff --git a/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs b/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs index b01597c..8cc6e18 100644 --- a/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs +++ b/test/protobuf-net-data.Tests/RecordWriterTests.TheWriteRecordMethod.cs @@ -20,7 +20,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 +37,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 +55,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 +72,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 +90,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 +107,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 +125,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 +142,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 +160,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 +177,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 +195,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 +212,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 +230,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 +247,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 +265,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 +282,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 +300,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 +317,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 +335,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 +352,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 +370,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 +387,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 +405,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 +422,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 +440,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 +458,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 +478,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 +496,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 +514,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 +534,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 +552,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 +569,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 +587,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 +612,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 +633,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); diff --git a/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs b/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs index 2aaba1a..3facbe6 100644 --- a/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs +++ b/test/protobuf-net-data.Tests/ResultReaderTests.TheReadResultMethod.cs @@ -18,9 +18,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; 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..a990a37 100644 --- a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj +++ b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj @@ -3,8 +3,8 @@ full false - net40;net471;netcoreapp2.0 - true + net461;net471;netcoreapp2.0 + false From 021b586f53a187c75f661d3f36dac3938054bbd5 Mon Sep 17 00:00:00 2001 From: Arjen Post Date: Thu, 17 Feb 2022 20:10:02 +0100 Subject: [PATCH 2/7] warnings fixed --- .gitattributes | 2 + .../DataReaderMock.cs | 2 +- .../Internal/ColumnsWriter.cs | 2 +- .../Internal/RecordWriter.cs | 12 ++--- src/protobuf-net-data/ProtoDataReader.cs | 44 +++++++++---------- ...ColumnsReaderTests.TheReadColumnsMethod.cs | 4 +- ...rotoDataReaderTests.TheNextResultMethod.cs | 2 +- .../RecordReaderTests.TheReadRecordMethod.cs | 6 +-- .../Program.cs | 4 +- 9 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 .gitattributes 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/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/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 e759220..c6e5320 100644 --- a/src/protobuf-net-data/ProtoDataReader.cs +++ b/src/protobuf-net-data/ProtoDataReader.cs @@ -606,41 +606,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() diff --git a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs index 3d52fc6..0df12bb 100644 --- a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs +++ b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs @@ -85,7 +85,7 @@ 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); @@ -119,7 +119,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); 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/RecordReaderTests.TheReadRecordMethod.cs b/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs index a449c54..3e6fc40 100644 --- a/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs +++ b/test/protobuf-net-data.Tests/RecordReaderTests.TheReadRecordMethod.cs @@ -30,7 +30,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,9 +39,9 @@ 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); 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; From a79ebb218f552ef64a7d7065befb13542dcf865d Mon Sep 17 00:00:00 2001 From: Arjen Post Date: Thu, 17 Feb 2022 20:13:25 +0100 Subject: [PATCH 3/7] suppress obsolete warnings using .editorconfig --- .editorconfig | 4 ++++ protobuf-net-data.sln | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f950263 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CS0618: Type or member is obsolete +dotnet_diagnostic.CS0618.severity = none diff --git a/protobuf-net-data.sln b/protobuf-net-data.sln index fc5cadd..94f1927 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 @@ -14,6 +14,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A435088-3AD8-472A-9BD4-81D34147E920}" ProjectSection(SolutionItems) = preProject .appveyor.yml = .appveyor.yml + .editorconfig = .editorconfig .gitignore = .gitignore LICENSE = LICENSE README.md = README.md @@ -27,7 +28,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 From 1d727a4f7c39a7604e4a0148a29e4ff280e294ae Mon Sep 17 00:00:00 2001 From: Arjen Post Date: Thu, 17 Feb 2022 20:36:48 +0100 Subject: [PATCH 4/7] re-enabled warnings as errors --- src/protobuf-net-data/protobuf-net-data.csproj | 6 +++--- test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protobuf-net-data/protobuf-net-data.csproj b/src/protobuf-net-data/protobuf-net-data.csproj index 2f38db8..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 @@ -7,7 +7,7 @@ true false net461;netstandard2.0 - false + true 0.0.0 @@ -30,7 +30,7 @@ - + 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 a990a37..02c775a 100644 --- a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj +++ b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj @@ -4,7 +4,7 @@ full false net461;net471;netcoreapp2.0 - false + true From 3e2c30e0e1045a1b3ad694aa35f4ffdf76e2c022 Mon Sep 17 00:00:00 2001 From: Arjen Post Date: Thu, 17 Feb 2022 20:55:36 +0100 Subject: [PATCH 5/7] use pragma disable instead of .editorconfig for now --- .editorconfig | 4 ---- protobuf-net-data.sln | 1 - src/protobuf-net-data/Internal/ProtoWriterContext.cs | 2 ++ src/protobuf-net-data/ProtoDataReader.cs | 4 +++- src/protobuf-net-data/ProtoDataStream.cs | 4 +++- src/protobuf-net-data/ProtoDataWriter.cs | 4 +++- .../ColumnsReaderTests.TheReadColumnsMethod.cs | 2 ++ .../ColumnsWriterTests.TheWriteColumnsMethod.cs | 2 ++ .../ProtoDataStreamTests.TheReadMethod.cs | 2 ++ .../ProtoDataWriterTests.TheSerializeMethod.cs | 2 ++ .../RecordReaderTests.TheReadRecordMethod.cs | 2 ++ .../RecordWriterTests.TheWriteRecordMethod.cs | 2 ++ .../ResultReaderTests.TheReadResultMethod.cs | 2 ++ 13 files changed, 25 insertions(+), 8 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index f950263..0000000 --- a/.editorconfig +++ /dev/null @@ -1,4 +0,0 @@ -[*.cs] - -# CS0618: Type or member is obsolete -dotnet_diagnostic.CS0618.severity = none diff --git a/protobuf-net-data.sln b/protobuf-net-data.sln index 94f1927..e8524e1 100644 --- a/protobuf-net-data.sln +++ b/protobuf-net-data.sln @@ -14,7 +14,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A435088-3AD8-472A-9BD4-81D34147E920}" ProjectSection(SolutionItems) = preProject .appveyor.yml = .appveyor.yml - .editorconfig = .editorconfig .gitignore = .gitignore LICENSE = LICENSE README.md = README.md 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/ProtoDataReader.cs b/src/protobuf-net-data/ProtoDataReader.cs index c6e5320..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; @@ -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 20f00dc..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; @@ -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 607c60d..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; @@ -112,4 +113,5 @@ public void Serialize(Stream stream, IDataReader reader, ProtoDataWriterOptions } } } -} \ No newline at end of file +} +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs index 0df12bb..3369d6e 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; @@ -139,3 +140,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 1a502d7..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; @@ -153,3 +154,4 @@ private Stream Serialize(IDataReader dataReader, ProtoDataWriterOptions options } } } +#pragma warning restore CS0618 diff --git a/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs b/test/protobuf-net-data.Tests/ProtoDataStreamTests.TheReadMethod.cs index 47c3150..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; @@ -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 3f4e7cc..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; @@ -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 3e6fc40..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; @@ -61,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 8cc6e18..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; @@ -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 3facbe6..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; @@ -33,3 +34,4 @@ public void ShouldThrowExceptionOnInvalidFieldHeader() } } } +#pragma warning restore CS0618 From eea966ba482116bf23f42091da41356e9fbe83e6 Mon Sep 17 00:00:00 2001 From: Arjen Post Date: Fri, 18 Feb 2022 19:16:11 +0100 Subject: [PATCH 6/7] remove unit test which cannot be set up --- ...ColumnsReaderTests.TheReadColumnsMethod.cs | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs index 3369d6e..b9c5c9c 100644 --- a/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs +++ b/test/protobuf-net-data.Tests/ColumnsReaderTests.TheReadColumnsMethod.cs @@ -13,29 +13,6 @@ public partial class ColumnsReaderTests { public class TheReadColumnsMethod : ColumnsReaderTests { - [Fact(Skip = "Upgrade to protobuf-net v3 will raise InvalidOperationException : The writer is in an incomplete state during close")] - public void ShouldThrowExceptionOnColumnsInvalidFieldHeader() - { - // Arrange - var stream = new MemoryStream(); - - using (var writer = ProtoWriter.Create(stream, null, null)) - { - ProtoWriter.WriteFieldHeader(1, WireType.StartGroup, writer); - - ProtoWriter.StartSubItem(0, writer); - - ProtoWriter.WriteFieldHeader(42, WireType.StartGroup, writer); - - writer.Close(); - } - - stream.Position = 0; - - // Assert - Assert.Throws(() => new ProtoDataReader(stream)); - } - [Fact] public void ShouldThrowExceptionOnColumnNameInvalidFieldHeader() { From ff9cdb1471edf3b1d36a04be229fb7d85eacc8a4 Mon Sep 17 00:00:00 2001 From: Arjen Post Date: Fri, 18 Feb 2022 19:16:32 +0100 Subject: [PATCH 7/7] clean up of csproj --- .../protobuf-net-data.Tests.csproj | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) 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 02c775a..4ffd114 100644 --- a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj +++ b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj @@ -11,11 +11,10 @@ - - - - + + + @@ -23,16 +22,6 @@ - - - - - - - - - -