Skip to content

Commit f201f83

Browse files
committed
Updated to JSON.NET from 9.0.1 to 12.0.3
1 parent f319468 commit f201f83

File tree

210 files changed

+19254
-7964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+19254
-7964
lines changed

build/common.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2121
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2222
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
23+
<Nullable>annotations</Nullable>
2324

2425
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
2526
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>

src/Exceptionless/Exceptionless.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\..\build\common.props" />
33

44
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
@@ -7,7 +7,7 @@
77
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
88
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
99
</PropertyGroup>
10-
10+
1111
<PropertyGroup Label="Package">
1212
<PackageId>Exceptionless</PackageId>
1313
<AssemblyName>Exceptionless</AssemblyName>
@@ -30,7 +30,7 @@
3030
</ItemGroup>
3131

3232
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'" Label="Build">
33-
<DefineConstants>$(DefineConstants);NO_SQL_CLIENT;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
33+
<DefineConstants>$(DefineConstants);NETSTANDARD;NETSTANDARD2_0;HAVE_ADO_NET;HAVE_APP_DOMAIN;HAVE_ASYNC;HAVE_BIG_INTEGER;HAVE_BINARY_FORMATTER;HAVE_BINARY_SERIALIZATION;HAVE_BINARY_EXCEPTION_SERIALIZATION;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_CHAR_TO_STRING_WITH_CULTURE;HAVE_COM_ATTRIBUTES;HAVE_COMPONENT_MODEL;HAVE_CONCURRENT_COLLECTIONS;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_DYNAMIC;HAVE_EMPTY_TYPES;HAVE_ENTITY_FRAMEWORK;HAVE_EXPRESSIONS;HAVE_FAST_REVERSE;HAVE_FSHARP_TYPES;HAVE_FULL_REFLECTION;HAVE_GUID_TRY_PARSE;HAVE_HASH_SET;HAVE_ICLONEABLE;HAVE_ICONVERTIBLE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_INOTIFY_COLLECTION_CHANGED;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_ISET;HAVE_LINQ;HAVE_MEMORY_BARRIER;HAVE_METHOD_IMPL_ATTRIBUTE;HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_READ_ONLY_COLLECTIONS;HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STREAM_READER_WRITER_CLOSE;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_TRACE_WRITER;HAVE_TYPE_DESCRIPTOR;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_XML_DOCUMENT;HAVE_XML_DOCUMENT_TYPE;HAVE_CONCURRENT_DICTIONARY;</DefineConstants>
3434
</PropertyGroup>
3535

3636
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'" Label="Package References">
@@ -44,7 +44,7 @@
4444
</ItemGroup>
4545

4646
<PropertyGroup Condition="'$(TargetFramework)' == 'net452'" Label="Build">
47-
<DefineConstants>$(DefineConstants);NET45</DefineConstants>
47+
<DefineConstants>$(DefineConstants);NET45;HAVE_ADO_NET;HAVE_APP_DOMAIN;HAVE_ASYNC;HAVE_BIG_INTEGER;HAVE_BINARY_FORMATTER;HAVE_BINARY_SERIALIZATION;HAVE_BINARY_EXCEPTION_SERIALIZATION;HAVE_CAS;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_CHAR_TO_STRING_WITH_CULTURE;HAVE_COM_ATTRIBUTES;HAVE_COMPONENT_MODEL;HAVE_CONCURRENT_COLLECTIONS;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_DYNAMIC;HAVE_EMPTY_TYPES;HAVE_ENTITY_FRAMEWORK;HAVE_EXPRESSIONS;HAVE_FAST_REVERSE;HAVE_FSHARP_TYPES;HAVE_FULL_REFLECTION;HAVE_GUID_TRY_PARSE;HAVE_HASH_SET;HAVE_ICLONEABLE;HAVE_ICONVERTIBLE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_INOTIFY_COLLECTION_CHANGED;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_ISET;HAVE_LINQ;HAVE_MEMORY_BARRIER;HAVE_METHOD_IMPL_ATTRIBUTE;HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_READ_ONLY_COLLECTIONS;HAVE_REFLECTION_EMIT;HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STREAM_READER_WRITER_CLOSE;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_TRACE_WRITER;HAVE_TYPE_DESCRIPTOR;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_XML_DOCUMENT;HAVE_XML_DOCUMENT_TYPE;HAVE_CONCURRENT_DICTIONARY;</DefineConstants>
4848
</PropertyGroup>
4949

5050
<ItemGroup Condition="'$(TargetFramework)' == 'net452'" Label="Framework References">

src/Exceptionless/Newtonsoft.Json/Bson/BsonBinaryType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
using System;
2727

28+
#nullable disable
29+
2830
namespace Exceptionless.Json.Bson
2931
{
3032
internal enum BsonBinaryType : byte

src/Exceptionless/Newtonsoft.Json/Bson/BsonBinaryWriter.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
using System.Text;
3030
using Exceptionless.Json.Utilities;
3131

32+
#nullable disable
33+
3234
namespace Exceptionless.Json.Bson
3335
{
3436
internal class BsonBinaryWriter
@@ -54,7 +56,7 @@ public void Flush()
5456

5557
public void Close()
5658
{
57-
#if !(DOTNET || PORTABLE40 || PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5)
59+
#if HAVE_STREAM_READER_WRITER_CLOSE
5860
_writer.Close();
5961
#else
6062
_writer.Dispose();
@@ -124,10 +126,7 @@ private void WriteTokenInternal(BsonToken t)
124126
}
125127
break;
126128
case BsonType.Boolean:
127-
{
128-
BsonValue value = (BsonValue)t;
129-
_writer.Write((bool)value.Value);
130-
}
129+
_writer.Write(t == BsonBoolean.True);
131130
break;
132131
case BsonType.Null:
133132
case BsonType.Undefined:
@@ -138,9 +137,8 @@ private void WriteTokenInternal(BsonToken t)
138137

139138
long ticks = 0;
140139

141-
if (value.Value is DateTime)
140+
if (value.Value is DateTime dateTime)
142141
{
143-
DateTime dateTime = (DateTime)value.Value;
144142
if (DateTimeKindHandling == DateTimeKind.Utc)
145143
{
146144
dateTime = dateTime.ToUniversalTime();
@@ -152,7 +150,7 @@ private void WriteTokenInternal(BsonToken t)
152150

153151
ticks = DateTimeUtils.ConvertDateTimeToJavaScriptTicks(dateTime, false);
154152
}
155-
#if !NET20
153+
#if HAVE_DATE_TIME_OFFSET
156154
else
157155
{
158156
DateTimeOffset dateTimeOffset = (DateTimeOffset)value.Value;
@@ -210,12 +208,13 @@ public void WriteUtf8Bytes(string s, int byteCount)
210208
{
211209
if (s != null)
212210
{
213-
if (_largeByteBuffer == null)
214-
{
215-
_largeByteBuffer = new byte[256];
216-
}
217211
if (byteCount <= 256)
218212
{
213+
if (_largeByteBuffer == null)
214+
{
215+
_largeByteBuffer = new byte[256];
216+
}
217+
219218
Encoding.GetBytes(s, 0, s.Length, _largeByteBuffer, 0);
220219
_writer.Write(_largeByteBuffer, 0, byteCount);
221220
}

src/Exceptionless/Newtonsoft.Json/Bson/BsonObjectId.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,21 @@
2626
using System;
2727
using Exceptionless.Json.Utilities;
2828

29+
#nullable disable
30+
2931
namespace Exceptionless.Json.Bson
3032
{
3133
/// <summary>
3234
/// Represents a BSON Oid (object id).
3335
/// </summary>
36+
[Obsolete("BSON reading and writing has been moved to its own package. See https://www.nuget.org/packages/Exceptionless.Json.Bson for more details.")]
3437
internal class BsonObjectId
3538
{
3639
/// <summary>
3740
/// Gets or sets the value of the Oid.
3841
/// </summary>
3942
/// <value>The value of the Oid.</value>
40-
public byte[] Value { get; private set; }
43+
public byte[] Value { get; }
4144

4245
/// <summary>
4346
/// Initializes a new instance of the <see cref="BsonObjectId"/> class.

src/Exceptionless/Newtonsoft.Json/Bson/BsonReader.cs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232
using Exceptionless.Json.Utilities;
3333
using Exceptionless.Json.Linq;
3434

35+
#nullable disable
36+
3537
namespace Exceptionless.Json.Bson
3638
{
3739
/// <summary>
38-
/// Represents a reader that provides fast, non-cached, forward-only access to serialized JSON data.
40+
/// Represents a reader that provides fast, non-cached, forward-only access to serialized BSON data.
3941
/// </summary>
42+
[Obsolete("BSON reading and writing has been moved to its own package. See https://www.nuget.org/packages/Exceptionless.Json.Bson for more details.")]
4043
internal class BsonReader : JsonReader
4144
{
4245
private const int MaxCharBytesSize = 128;
@@ -85,16 +88,16 @@ public ContainerContext(BsonType type)
8588
}
8689

8790
/// <summary>
88-
/// Gets or sets a value indicating whether binary data reading should compatible with incorrect Json.NET 3.5 written binary.
91+
/// Gets or sets a value indicating whether binary data reading should be compatible with incorrect Json.NET 3.5 written binary.
8992
/// </summary>
9093
/// <value>
9194
/// <c>true</c> if binary data reading will be compatible with incorrect Json.NET 3.5 written binary; otherwise, <c>false</c>.
9295
/// </value>
9396
[Obsolete("JsonNet35BinaryCompatibility will be removed in a future version of Json.NET.")]
9497
public bool JsonNet35BinaryCompatibility
9598
{
96-
get { return _jsonNet35BinaryCompatibility; }
97-
set { _jsonNet35BinaryCompatibility = value; }
99+
get => _jsonNet35BinaryCompatibility;
100+
set => _jsonNet35BinaryCompatibility = value;
98101
}
99102

100103
/// <summary>
@@ -105,8 +108,8 @@ public bool JsonNet35BinaryCompatibility
105108
/// </value>
106109
public bool ReadRootValueAsArray
107110
{
108-
get { return _readRootValueAsArray; }
109-
set { _readRootValueAsArray = value; }
111+
get => _readRootValueAsArray;
112+
set => _readRootValueAsArray = value;
110113
}
111114

112115
/// <summary>
@@ -115,14 +118,14 @@ public bool ReadRootValueAsArray
115118
/// <value>The <see cref="DateTimeKind" /> used when reading <see cref="DateTime"/> values from BSON.</value>
116119
public DateTimeKind DateTimeKindHandling
117120
{
118-
get { return _dateTimeKindHandling; }
119-
set { _dateTimeKindHandling = value; }
121+
get => _dateTimeKindHandling;
122+
set => _dateTimeKindHandling = value;
120123
}
121124

122125
/// <summary>
123126
/// Initializes a new instance of the <see cref="BsonReader"/> class.
124127
/// </summary>
125-
/// <param name="stream">The stream.</param>
128+
/// <param name="stream">The <see cref="Stream"/> containing the BSON data to read.</param>
126129
public BsonReader(Stream stream)
127130
: this(stream, false, DateTimeKind.Local)
128131
{
@@ -131,7 +134,7 @@ public BsonReader(Stream stream)
131134
/// <summary>
132135
/// Initializes a new instance of the <see cref="BsonReader"/> class.
133136
/// </summary>
134-
/// <param name="reader">The reader.</param>
137+
/// <param name="reader">The <see cref="BinaryReader"/> containing the BSON data to read.</param>
135138
public BsonReader(BinaryReader reader)
136139
: this(reader, false, DateTimeKind.Local)
137140
{
@@ -140,7 +143,7 @@ public BsonReader(BinaryReader reader)
140143
/// <summary>
141144
/// Initializes a new instance of the <see cref="BsonReader"/> class.
142145
/// </summary>
143-
/// <param name="stream">The stream.</param>
146+
/// <param name="stream">The <see cref="Stream"/> containing the BSON data to read.</param>
144147
/// <param name="readRootValueAsArray">if set to <c>true</c> the root object will be read as a JSON array.</param>
145148
/// <param name="dateTimeKindHandling">The <see cref="DateTimeKind" /> used when reading <see cref="DateTime"/> values from BSON.</param>
146149
public BsonReader(Stream stream, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling)
@@ -155,7 +158,7 @@ public BsonReader(Stream stream, bool readRootValueAsArray, DateTimeKind dateTim
155158
/// <summary>
156159
/// Initializes a new instance of the <see cref="BsonReader"/> class.
157160
/// </summary>
158-
/// <param name="reader">The reader.</param>
161+
/// <param name="reader">The <see cref="BinaryReader"/> containing the BSON data to read.</param>
159162
/// <param name="readRootValueAsArray">if set to <c>true</c> the root object will be read as a JSON array.</param>
160163
/// <param name="dateTimeKindHandling">The <see cref="DateTimeKind" /> used when reading <see cref="DateTime"/> values from BSON.</param>
161164
public BsonReader(BinaryReader reader, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling)
@@ -175,10 +178,10 @@ private string ReadElement()
175178
}
176179

177180
/// <summary>
178-
/// Reads the next JSON token from the stream.
181+
/// Reads the next JSON token from the underlying <see cref="Stream"/>.
179182
/// </summary>
180183
/// <returns>
181-
/// true if the next token was read successfully; false if there are no more tokens to read.
184+
/// <c>true</c> if the next token was read successfully; <c>false</c> if there are no more tokens to read.
182185
/// </returns>
183186
public override bool Read()
184187
{
@@ -223,18 +226,19 @@ public override bool Read()
223226
}
224227

225228
/// <summary>
226-
/// Changes the <see cref="JsonReader.State"/> to Closed.
229+
/// Changes the reader's state to <see cref="JsonReader.State.Closed"/>.
230+
/// If <see cref="JsonReader.CloseInput"/> is set to <c>true</c>, the underlying <see cref="Stream"/> is also closed.
227231
/// </summary>
228232
public override void Close()
229233
{
230234
base.Close();
231235

232-
if (CloseInput && _reader != null)
236+
if (CloseInput)
233237
{
234-
#if !(DOTNET || PORTABLE40 || PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5)
235-
_reader.Close();
238+
#if HAVE_STREAM_READER_WRITER_CLOSE
239+
_reader?.Close();
236240
#else
237-
_reader.Dispose();
241+
_reader?.Dispose();
238242
#endif
239243
}
240244
}
@@ -368,6 +372,11 @@ private bool ReadNormal()
368372
ContainerContext context = _currentContext;
369373
if (context == null)
370374
{
375+
if (SupportMultipleContent)
376+
{
377+
goto case State.Start;
378+
}
379+
371380
return false;
372381
}
373382

src/Exceptionless/Newtonsoft.Json/Bson/BsonToken.cs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
using System.Collections;
2727
using System.Collections.Generic;
2828

29+
#nullable disable
30+
2931
namespace Exceptionless.Json.Bson
3032
{
3133
internal abstract class BsonToken
@@ -45,10 +47,7 @@ public void Add(string name, BsonToken token)
4547
token.Parent = this;
4648
}
4749

48-
public override BsonType Type
49-
{
50-
get { return BsonType.Object; }
51-
}
50+
public override BsonType Type => BsonType.Object;
5251

5352
public IEnumerator<BsonProperty> GetEnumerator()
5453
{
@@ -71,10 +70,7 @@ public void Add(BsonToken token)
7170
token.Parent = this;
7271
}
7372

74-
public override BsonType Type
75-
{
76-
get { return BsonType.Array; }
77-
}
73+
public override BsonType Type => BsonType.Array;
7874

7975
public IEnumerator<BsonToken> GetEnumerator()
8076
{
@@ -87,6 +83,19 @@ IEnumerator IEnumerable.GetEnumerator()
8783
}
8884
}
8985

86+
internal class BsonEmpty : BsonToken
87+
{
88+
public static readonly BsonToken Null = new BsonEmpty(BsonType.Null);
89+
public static readonly BsonToken Undefined = new BsonEmpty(BsonType.Undefined);
90+
91+
private BsonEmpty(BsonType type)
92+
{
93+
Type = type;
94+
}
95+
96+
public override BsonType Type { get; }
97+
}
98+
9099
internal class BsonValue : BsonToken
91100
{
92101
private readonly object _value;
@@ -98,21 +107,26 @@ public BsonValue(object value, BsonType type)
98107
_type = type;
99108
}
100109

101-
public object Value
102-
{
103-
get { return _value; }
104-
}
110+
public object Value => _value;
111+
112+
public override BsonType Type => _type;
113+
}
114+
115+
internal class BsonBoolean : BsonValue
116+
{
117+
public static readonly BsonBoolean False = new BsonBoolean(false);
118+
public static readonly BsonBoolean True = new BsonBoolean(true);
105119

106-
public override BsonType Type
120+
private BsonBoolean(bool value)
121+
: base(value, BsonType.Boolean)
107122
{
108-
get { return _type; }
109123
}
110124
}
111125

112126
internal class BsonString : BsonValue
113127
{
114128
public int ByteCount { get; set; }
115-
public bool IncludeLength { get; set; }
129+
public bool IncludeLength { get; }
116130

117131
public BsonString(object value, bool includeLength)
118132
: base(value, BsonType.String)
@@ -143,10 +157,7 @@ public BsonRegex(string pattern, string options)
143157
Options = new BsonString(options, false);
144158
}
145159

146-
public override BsonType Type
147-
{
148-
get { return BsonType.Regex; }
149-
}
160+
public override BsonType Type => BsonType.Regex;
150161
}
151162

152163
internal class BsonProperty

src/Exceptionless/Newtonsoft.Json/Bson/BsonType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// OTHER DEALINGS IN THE SOFTWARE.
2424
#endregion
2525

26+
#nullable disable
27+
2628
namespace Exceptionless.Json.Bson
2729
{
2830
internal enum BsonType : sbyte

0 commit comments

Comments
 (0)