Skip to content

Commit 6a92909

Browse files
committed
Move from JetBrains to built-in nullable annotations
1 parent 9915d10 commit 6a92909

30 files changed

+349
-452
lines changed

fNbt.Test/PartialReadStream.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
using System;
22
using System.IO;
3-
using JetBrains.Annotations;
43

54
namespace fNbt.Test {
65
class PartialReadStream : Stream {
76
readonly Stream baseStream;
87
readonly int increment;
98

10-
public PartialReadStream([NotNull] Stream baseStream)
9+
public PartialReadStream(Stream baseStream)
1110
: this(baseStream, 1) { }
1211

1312

14-
public PartialReadStream([NotNull] Stream baseStream, int increment) {
13+
public PartialReadStream(Stream baseStream, int increment) {
1514
if (baseStream == null) throw new ArgumentNullException(nameof(baseStream));
1615
this.baseStream = baseStream;
1716
this.increment = increment;

fNbt.Test/fNbt.Test.csproj

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<TargetFramework>net461</TargetFramework>
4-
<OutputType>Library</OutputType>
5-
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6-
<IsTestProject>true</IsTestProject>
7-
<LangVersion>7.3</LangVersion>
8-
</PropertyGroup>
9-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
10-
<OutputPath>..\bin\Debug\</OutputPath>
11-
</PropertyGroup>
12-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
13-
<Optimize>false</Optimize>
14-
<OutputPath>..\bin\Release\</OutputPath>
15-
</PropertyGroup>
16-
<ItemGroup>
17-
<None Update="TestFiles\bigtest.nbt">
18-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
19-
</None>
20-
<None Update="TestFiles\bigtest.nbt.gz">
21-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22-
</None>
23-
<None Update="TestFiles\bigtest.nbt.z">
24-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25-
</None>
26-
<None Update="TestFiles\test.nbt">
27-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28-
</None>
29-
<None Update="TestFiles\test.nbt.gz">
30-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
31-
</None>
32-
<None Update="TestFiles\test.nbt.z">
33-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34-
</None>
35-
</ItemGroup>
36-
<ItemGroup>
37-
<ProjectReference Include="..\fNbt\fNbt.csproj" />
38-
</ItemGroup>
39-
<ItemGroup>
40-
<PackageReference Include="NUnit" Version="3.13.2" />
41-
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
42-
</ItemGroup>
2+
<PropertyGroup>
3+
<TargetFramework>net461</TargetFramework>
4+
<OutputType>Library</OutputType>
5+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6+
<IsTestProject>true</IsTestProject>
7+
<LangVersion>10</LangVersion>
8+
</PropertyGroup>
9+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
10+
<OutputPath>..\bin\Debug\</OutputPath>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
13+
<Optimize>false</Optimize>
14+
<OutputPath>..\bin\Release\</OutputPath>
15+
</PropertyGroup>
16+
<ItemGroup>
17+
<None Update="TestFiles\bigtest.nbt">
18+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
19+
</None>
20+
<None Update="TestFiles\bigtest.nbt.gz">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</None>
23+
<None Update="TestFiles\bigtest.nbt.z">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</None>
26+
<None Update="TestFiles\test.nbt">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</None>
29+
<None Update="TestFiles\test.nbt.gz">
30+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
31+
</None>
32+
<None Update="TestFiles\test.nbt.z">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</None>
35+
</ItemGroup>
36+
<ItemGroup>
37+
<ProjectReference Include="..\fNbt\fNbt.csproj" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<PackageReference Include="NUnit" Version="3.14.0" />
41+
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
42+
</ItemGroup>
4343
</Project>

fNbt/ByteCountingStream.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
using System.Diagnostics;
2-
using System.IO;
3-
using JetBrains.Annotations;
1+
using System.IO;
42

53
namespace fNbt {
64
// Class used to count bytes read-from/written-to non-seekable streams.
7-
internal class ByteCountingStream : Stream {
5+
internal sealed class ByteCountingStream : Stream {
86
readonly Stream baseStream;
97

108
// These are necessary to avoid counting bytes twice if ReadByte/WriteByte call Read/Write internally.
@@ -16,8 +14,8 @@ internal class ByteCountingStream : Stream {
1614
bool writingManyBytes;
1715

1816

19-
public ByteCountingStream([NotNull] Stream stream) {
20-
Debug.Assert(stream != null);
17+
public ByteCountingStream(Stream stream) {
18+
NullableSupport.Assert(stream != null);
2119
baseStream = stream;
2220
}
2321

@@ -94,5 +92,11 @@ public override long Position {
9492

9593
public long BytesRead { get; private set; }
9694
public long BytesWritten { get; private set; }
95+
96+
97+
protected override void Dispose(bool disposing) {
98+
base.Dispose(disposing);
99+
baseStream.Dispose();
100+
}
97101
}
98102
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using System;
2-
using JetBrains.Annotations;
32

43
namespace fNbt {
54
/// <summary> Exception thrown when an operation is attempted on an NbtReader that
65
/// cannot recover from a previous parsing error. </summary>
76
[Serializable]
87
public sealed class InvalidReaderStateException : InvalidOperationException {
9-
internal InvalidReaderStateException([NotNull] string message)
8+
internal InvalidReaderStateException(string message)
109
: base(message) { }
1110
}
1211
}

fNbt/JetBrains.Annotations.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

fNbt/NbtBinaryReader.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22
using System.Diagnostics;
33
using System.IO;
44
using System.Text;
5-
using JetBrains.Annotations;
65

76
namespace fNbt {
87
/// <summary> BinaryReader wrapper that takes care of reading primitives from an NBT stream,
98
/// while taking care of endianness, string encoding, and skipping. </summary>
109
internal sealed class NbtBinaryReader : BinaryReader {
1110
readonly byte[] buffer = new byte[sizeof(double)];
1211

13-
byte[] seekBuffer;
12+
byte[]? seekBuffer;
1413
const int SeekBufferSize = 8 * 1024;
1514
readonly bool swapNeeded;
1615
readonly byte[] stringConversionBuffer = new byte[64];
1716

1817

19-
public NbtBinaryReader([NotNull] Stream input, bool bigEndian)
18+
public NbtBinaryReader(Stream input, bool bigEndian)
2019
: base(input) {
2120
swapNeeded = (BitConverter.IsLittleEndian == bigEndian);
2221
}
@@ -176,7 +175,6 @@ static long Swap(long v) {
176175
}
177176

178177

179-
[CanBeNull]
180-
public TagSelector Selector { get; set; }
178+
public TagSelector? Selector { get; set; }
181179
}
182180
}

fNbt/NbtBinaryWriter.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.IO;
33
using System.Text;
4-
using JetBrains.Annotations;
54

65
namespace fNbt {
76
/// <summary> BinaryWriter wrapper that writes NBT primitives to a stream,
@@ -38,7 +37,7 @@ public Stream BaseStream {
3837
readonly bool swapNeeded;
3938

4039

41-
public NbtBinaryWriter([NotNull] Stream input, bool bigEndian) {
40+
public NbtBinaryWriter(Stream input, bool bigEndian) {
4241
if (input == null) throw new ArgumentNullException(nameof(input));
4342
if (!input.CanWrite) throw new ArgumentException("Given stream must be writable", nameof(input));
4443
stream = input;
@@ -161,7 +160,7 @@ public void Write(double value) {
161160

162161

163162
// Based on BinaryWriter.Write(String)
164-
public void Write([NotNull] string value) {
163+
public void Write(string value) {
165164
if (value == null) {
166165
throw new ArgumentNullException(nameof(value));
167166
}

0 commit comments

Comments
 (0)