-Marked BSON classes as obsolete
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
#if !(NET20 || NET35 || NET40 || PORTABLE40)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -200,9 +200,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
byte[] data = HexToBytes("8C-00-00-00-12-30-00-FF-FF-FF-FF-FF-FF-FF-7F-12-31-00-FF-FF-FF-FF-FF-FF-FF-7F-10-32-00-FF-FF-FF-7F-10-33-00-FF-FF-FF-7F-10-34-00-FF-00-00-00-10-35-00-7F-00-00-00-02-36-00-02-00-00-00-61-00-01-37-00-00-00-00-00-00-00-F0-45-01-38-00-FF-FF-FF-FF-FF-FF-EF-7F-01-39-00-00-00-00-E0-FF-FF-EF-47-08-31-30-00-01-05-31-31-00-05-00-00-00-02-00-01-02-03-04-09-31-32-00-40-C5-E2-BA-E3-00-00-00-09-31-33-00-40-C5-E2-BA-E3-00-00-00-00");
|
||||
MemoryStream ms = new MemoryStream(data);
|
||||
BsonReader reader = new BsonReader(ms);
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
reader.ReadRootValueAsArray = true;
|
||||
reader.DateTimeKindHandling = DateTimeKind.Utc;
|
||||
|
||||
@@ -409,9 +407,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
|
||||
MemoryStream ms = new MemoryStream(data);
|
||||
BsonReader reader = new BsonReader(ms, true, DateTimeKind.Utc);
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
Assert.AreEqual(true, reader.ReadRootValueAsArray);
|
||||
Assert.AreEqual(DateTimeKind.Utc, reader.DateTimeKindHandling);
|
||||
@@ -1344,3 +1340,4 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
}
|
||||
|
||||
#endif
|
||||
#pragma warning restore 618
|
||||
@@ -23,6 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -284,9 +285,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
byte[] data = HexToBytes("8C-00-00-00-12-30-00-FF-FF-FF-FF-FF-FF-FF-7F-12-31-00-FF-FF-FF-FF-FF-FF-FF-7F-10-32-00-FF-FF-FF-7F-10-33-00-FF-FF-FF-7F-10-34-00-FF-00-00-00-10-35-00-7F-00-00-00-02-36-00-02-00-00-00-61-00-01-37-00-00-00-00-00-00-00-F0-45-01-38-00-FF-FF-FF-FF-FF-FF-EF-7F-01-39-00-00-00-00-E0-FF-FF-EF-47-08-31-30-00-01-05-31-31-00-05-00-00-00-02-00-01-02-03-04-09-31-32-00-40-C5-E2-BA-E3-00-00-00-09-31-33-00-40-C5-E2-BA-E3-00-00-00-00");
|
||||
MemoryStream ms = new MemoryStream(data);
|
||||
BsonReader reader = new BsonReader(ms);
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
reader.ReadRootValueAsArray = true;
|
||||
reader.DateTimeKindHandling = DateTimeKind.Utc;
|
||||
|
||||
@@ -493,9 +492,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
|
||||
MemoryStream ms = new MemoryStream(data);
|
||||
BsonReader reader = new BsonReader(ms, true, DateTimeKind.Utc);
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
Assert.AreEqual(true, reader.ReadRootValueAsArray);
|
||||
Assert.AreEqual(DateTimeKind.Utc, reader.DateTimeKindHandling);
|
||||
@@ -632,9 +629,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
byte[] data = HexToBytes(hexdoc);
|
||||
|
||||
BsonReader reader = new BsonReader(new MemoryStream(data));
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
JObject o = (JObject)JToken.ReadFrom(reader);
|
||||
Assert.AreEqual(3, o.Count);
|
||||
@@ -655,9 +650,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
"82-00-00-00-07-5F-69-64-00-4A-78-93-79-17-22-00-00-00-00-61-CF-04-61-00-5D-00-00-00-01-30-00-00-00-00-00-00-00-F0-3F-01-31-00-00-00-00-00-00-00-00-40-01-32-00-00-00-00-00-00-00-08-40-01-33-00-00-00-00-00-00-00-10-40-01-34-00-00-00-00-00-00-00-14-50-01-35-00-00-00-00-00-00-00-18-40-01-36-00-00-00-00-00-00-00-1C-40-01-37-00-00-00-00-00-00-00-20-40-00-02-62-00-05-00-00-00-74-65-73-74-00-00");
|
||||
|
||||
BsonReader reader1 = new BsonReader(new MemoryStream(data1));
|
||||
#pragma warning disable 612,618
|
||||
reader1.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
// oid
|
||||
JObject o1 = (JObject)JToken.ReadFrom(reader1);
|
||||
@@ -666,9 +659,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
"87-00-00-00-05-5F-69-64-00-0C-00-00-00-02-4A-78-93-79-17-22-00-00-00-00-61-CF-04-61-00-5D-00-00-00-01-30-00-00-00-00-00-00-00-F0-3F-01-31-00-00-00-00-00-00-00-00-40-01-32-00-00-00-00-00-00-00-08-40-01-33-00-00-00-00-00-00-00-10-40-01-34-00-00-00-00-00-00-00-14-50-01-35-00-00-00-00-00-00-00-18-40-01-36-00-00-00-00-00-00-00-1C-40-01-37-00-00-00-00-00-00-00-20-40-00-02-62-00-05-00-00-00-74-65-73-74-00-00");
|
||||
|
||||
BsonReader reader2 = new BsonReader(new MemoryStream(data2));
|
||||
#pragma warning disable 612,618
|
||||
reader2.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
// bytes
|
||||
JObject o2 = (JObject)JToken.ReadFrom(reader2);
|
||||
@@ -1623,9 +1614,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
var settings = new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Auto,
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Binder = binder
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
};
|
||||
|
||||
Zoo zoo = new Zoo
|
||||
@@ -1785,4 +1774,5 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
public object TheGuid { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 618
|
||||
@@ -23,8 +23,8 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
#if !(NET20 || NET35 || NET40 || PORTABLE40)
|
||||
|
||||
using System;
|
||||
#if !(NET20 || NET35 || PORTABLE) || NETSTANDARD1_1
|
||||
using System.Numerics;
|
||||
@@ -538,4 +538,5 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#pragma warning restore 618
|
||||
@@ -23,6 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if !(NET20 || NET35 || PORTABLE) || NETSTANDARD1_1
|
||||
@@ -941,4 +942,5 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 618
|
||||
@@ -274,6 +274,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual(t1.TableName, t2.TableName);
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void RoundtripBsonBytes()
|
||||
{
|
||||
@@ -314,6 +315,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
CollectionAssert.AreEquivalent(Encoding.UTF8.GetBytes("Hello world!"), (byte[])dr1["data"]);
|
||||
Assert.AreEqual(g, (Guid)dr1["id"]);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
|
||||
[Test]
|
||||
public void SerializeDataTableWithNull()
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Bson;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
@@ -84,4 +85,5 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual(c.Test, "1234£56");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 618
|
||||
@@ -114,6 +114,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual(RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture, r.Regex.Options);
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void SerializeToBson()
|
||||
{
|
||||
@@ -132,19 +133,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual(expected, bson);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializeFromText()
|
||||
{
|
||||
string json = @"{
|
||||
""Pattern"": ""abc"",
|
||||
""Options"": 513
|
||||
}";
|
||||
|
||||
Regex newRegex = JsonConvert.DeserializeObject<Regex>(json, new RegexConverter());
|
||||
Assert.AreEqual("abc", newRegex.ToString());
|
||||
Assert.AreEqual(RegexOptions.IgnoreCase | RegexOptions.CultureInvariant, newRegex.Options);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializeFromBson()
|
||||
{
|
||||
@@ -209,6 +197,20 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual("/", c.Regex.ToString());
|
||||
Assert.AreEqual(RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.ExplicitCapture, c.Regex.Options);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
|
||||
[Test]
|
||||
public void DeserializeFromText()
|
||||
{
|
||||
string json = @"{
|
||||
""Pattern"": ""abc"",
|
||||
""Options"": 513
|
||||
}";
|
||||
|
||||
Regex newRegex = JsonConvert.DeserializeObject<Regex>(json, new RegexConverter());
|
||||
Assert.AreEqual("abc", newRegex.ToString());
|
||||
Assert.AreEqual(RegexOptions.IgnoreCase | RegexOptions.CultureInvariant, newRegex.Options);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertEmptyRegexJson()
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
}
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
@@ -67,6 +68,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
// Movie Premiere
|
||||
}
|
||||
#endregion
|
||||
#pragma warning restore 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
}
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
@@ -73,6 +74,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
// Easter
|
||||
}
|
||||
#endregion
|
||||
#pragma warning restore 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
}
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
@@ -76,5 +77,6 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
|
||||
Assert.AreEqual("MQAAAAJOYW1lAA8AAABNb3ZpZSBQcmVtaWVyZQAJU3RhcnREYXRlAED982M8AQAAAA==", data);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
[TestFixture]
|
||||
public class ReadJTokenFromBson : TestFixtureBase
|
||||
{
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
@@ -64,5 +65,6 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
Assert.AreEqual("value1", value);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
[TestFixture]
|
||||
public class WriteJTokenToBson : TestFixtureBase
|
||||
{
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
@@ -67,5 +68,6 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
Assert.AreEqual("KQAAAAJuYW1lMQAHAAAAdmFsdWUxAAJuYW1lMgAHAAAAdmFsdWUyAAA=", data);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
}
|
||||
}
|
||||
@@ -684,6 +684,7 @@ If attributes are not mentioned, default values are used in each case.
|
||||
return Encoding.UTF8.GetBytes(json);
|
||||
}, "Json.NET");
|
||||
|
||||
#pragma warning disable 618
|
||||
byte[] bsonBytes = TimeOperation(() =>
|
||||
{
|
||||
MemoryStream ms = null;
|
||||
@@ -699,6 +700,7 @@ If attributes are not mentioned, default values are used in each case.
|
||||
|
||||
return ms.ToArray();
|
||||
}, "Json.NET BSON");
|
||||
#pragma warning restore 618
|
||||
|
||||
byte[] xmlBytes = TimeOperation(() =>
|
||||
{
|
||||
@@ -1051,6 +1053,7 @@ If attributes are not mentioned, default values are used in each case.
|
||||
}
|
||||
break;
|
||||
}
|
||||
#pragma warning disable 618
|
||||
case SerializeMethod.JsonNetBinary:
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(Buffer);
|
||||
@@ -1062,6 +1065,7 @@ If attributes are not mentioned, default values are used in each case.
|
||||
json = "Bytes = " + ms.Position;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore 618
|
||||
case SerializeMethod.JavaScriptSerializer:
|
||||
json = SerializeWebExtensions(value);
|
||||
break;
|
||||
@@ -1323,6 +1327,7 @@ If attributes are not mentioned, default values are used in each case.
|
||||
return a;
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
public T DeserializeJsonNetBinary<T>(byte[] bson)
|
||||
{
|
||||
Type type = typeof(T);
|
||||
@@ -1334,6 +1339,7 @@ If attributes are not mentioned, default values are used in each case.
|
||||
|
||||
return (T)serializer.Deserialize(new BsonReader(new MemoryStream(bson)), type);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
|
||||
public T DeserializeWebExtensions<T>(string json)
|
||||
{
|
||||
|
||||
@@ -7771,6 +7771,7 @@ Path '', line 1, position 1.");
|
||||
public DateTimeOffset Foo { get; set; }
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void TokenFromBson()
|
||||
{
|
||||
@@ -7794,6 +7795,7 @@ Path '', line 1, position 1.");
|
||||
""2000-01-02T03:04:05+06:00""
|
||||
]", a.ToString());
|
||||
}
|
||||
#pragma warning restore 618
|
||||
|
||||
[Test]
|
||||
public void ObjectRequiredDeserializeMissing()
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Newtonsoft.Json.Bson
|
||||
/// <summary>
|
||||
/// Represents a BSON Oid (object id).
|
||||
/// </summary>
|
||||
[Obsolete("BSON reading and writing has been moved to its own package. See https://www.nuget.org/packages/Newtonsoft.Json.Bson for more details.")]
|
||||
public class BsonObjectId
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Newtonsoft.Json.Bson
|
||||
/// <summary>
|
||||
/// Represents a reader that provides fast, non-cached, forward-only access to serialized BSON data.
|
||||
/// </summary>
|
||||
[Obsolete("BSON reading and writing has been moved to its own package. See https://www.nuget.org/packages/Newtonsoft.Json.Bson for more details.")]
|
||||
public class BsonReader : JsonReader
|
||||
{
|
||||
private const int MaxCharBytesSize = 128;
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace Newtonsoft.Json.Bson
|
||||
/// <summary>
|
||||
/// Represents a writer that provides a fast, non-cached, forward-only way of generating BSON data.
|
||||
/// </summary>
|
||||
[Obsolete("BSON reading and writing has been moved to its own package. See https://www.nuget.org/packages/Newtonsoft.Json.Bson for more details.")]
|
||||
public class BsonWriter : JsonWriter
|
||||
{
|
||||
private readonly BsonBinaryWriter _writer;
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Newtonsoft.Json.Converters
|
||||
/// <summary>
|
||||
/// Converts a <see cref="BsonObjectId"/> to and from JSON and BSON.
|
||||
/// </summary>
|
||||
[Obsolete("BSON reading and writing has been moved to its own package. See https://www.nuget.org/packages/Newtonsoft.Json.Bson for more details.")]
|
||||
public class BsonObjectIdConverter : JsonConverter
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -49,11 +49,13 @@ namespace Newtonsoft.Json.Converters
|
||||
{
|
||||
Regex regex = (Regex)value;
|
||||
|
||||
#pragma warning disable 618
|
||||
BsonWriter bsonWriter = writer as BsonWriter;
|
||||
if (bsonWriter != null)
|
||||
{
|
||||
WriteBson(bsonWriter, regex);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
else
|
||||
{
|
||||
WriteJson(writer, regex, serializer);
|
||||
@@ -65,6 +67,7 @@ namespace Newtonsoft.Json.Converters
|
||||
return ((options & flag) == flag);
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
private void WriteBson(BsonWriter writer, Regex regex)
|
||||
{
|
||||
// Regular expression - The first cstring is the regex pattern, the second
|
||||
@@ -100,6 +103,7 @@ namespace Newtonsoft.Json.Converters
|
||||
|
||||
writer.WriteRegex(regex.ToString(), options);
|
||||
}
|
||||
#pragma warning restore 618
|
||||
|
||||
private void WriteJson(JsonWriter writer, Regex regex, JsonSerializer serializer)
|
||||
{
|
||||
|
||||
@@ -80,7 +80,9 @@ namespace Newtonsoft.Json.Serialization
|
||||
new DiscriminatedUnionConverter(),
|
||||
#endif
|
||||
new KeyValuePairConverter(),
|
||||
#pragma warning disable 618
|
||||
new BsonObjectIdConverter(),
|
||||
#pragma warning restore 618
|
||||
new RegexConverter()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user