Skip to content

Commit 2086b5a

Browse files
authored
CSHARP-5311: Remove deprecation from BSON area (#1482)
1 parent f57d274 commit 2086b5a

Some content is hidden

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

45 files changed

+53
-2061
lines changed

src/MongoDB.Bson/IO/BsonBinaryWriter.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,6 @@ public override void Flush()
137137
_bsonStream.Flush();
138138
}
139139

140-
/// <summary>
141-
/// Pops the max document size stack, restoring the previous max document size.
142-
/// </summary>
143-
[Obsolete("Use PopSettings instead.")]
144-
public void PopMaxDocumentSize()
145-
{
146-
PopSettings();
147-
}
148-
149-
/// <summary>
150-
/// Pushes a new max document size onto the max document size stack.
151-
/// </summary>
152-
/// <param name="maxDocumentSize">The maximum size of the document.</param>
153-
[Obsolete("Use PushSettings instead.")]
154-
public void PushMaxDocumentSize(int maxDocumentSize)
155-
{
156-
PushSettings(s => ((BsonBinaryWriterSettings)s).MaxDocumentSize = maxDocumentSize);
157-
}
158-
159140
#pragma warning disable 618 // about obsolete BsonBinarySubType.OldBinary
160141
/// <summary>
161142
/// Writes BSON binary data to the writer.

src/MongoDB.Bson/IO/JsonOutputMode.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ namespace MongoDB.Bson.IO
2222
/// </summary>
2323
public enum JsonOutputMode
2424
{
25-
/// <summary>
26-
/// Output strict JSON (an obsolete output mode that is similar to canonical extended JSON).
27-
/// </summary>
28-
[Obsolete("Use CanonicalExtendedJson instead.")]
29-
Strict,
30-
3125
/// <summary>
3226
/// Use a format that can be pasted in to the MongoDB shell.
3327
/// </summary>
@@ -42,17 +36,5 @@ public enum JsonOutputMode
4236
/// Output relaxed extended JSON.
4337
/// </summary>
4438
RelaxedExtendedJson,
45-
46-
/// <summary>
47-
/// Use JavaScript data types for some values.
48-
/// </summary>
49-
[Obsolete("Use Shell instead.")]
50-
JavaScript = Shell,
51-
52-
/// <summary>
53-
/// Use JavaScript and MongoDB data types for some values.
54-
/// </summary>
55-
[Obsolete("Use Shell instead.")]
56-
TenGen = Shell
5739
}
5840
}

src/MongoDB.Bson/IO/JsonWriter.cs

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ public override void WriteBinaryData(BsonBinaryData binaryData)
126126
WriteNameHelper(Name);
127127
switch (Settings.OutputMode)
128128
{
129-
#pragma warning disable 618
130-
case JsonOutputMode.Strict:
131-
#pragma warning restore 618
132-
_textWriter.Write("{{ \"$binary\" : \"{0}\", \"$type\" : \"{1}\" }}", Convert.ToBase64String(bytes), ((int)subType).ToString("x2"));
133-
break;
134-
135129
case JsonOutputMode.CanonicalExtendedJson:
136130
case JsonOutputMode.RelaxedExtendedJson:
137131
_textWriter.Write("{{ \"$binary\" : {{ \"base64\" : \"{0}\", \"subType\" : \"{1}\" }} }}", Convert.ToBase64String(bytes), ((int)subType).ToString("x2"));
@@ -198,12 +192,6 @@ public override void WriteDateTime(long value)
198192
WriteNameHelper(Name);
199193
switch (Settings.OutputMode)
200194
{
201-
#pragma warning disable 618
202-
case JsonOutputMode.Strict:
203-
#pragma warning restore 618
204-
_textWriter.Write("{{ \"$date\" : {0} }}", value);
205-
break;
206-
207195
case JsonOutputMode.RelaxedExtendedJson:
208196
if (value >= 0 && value <= BsonConstants.DateTimeMaxValueMillisecondsSinceEpoch)
209197
{
@@ -255,9 +243,6 @@ public override void WriteDecimal128(Decimal128 value)
255243
_textWriter.Write("NumberDecimal(\"{0}\")", value.ToString());
256244
break;
257245

258-
#pragma warning disable 618
259-
case JsonOutputMode.Strict:
260-
#pragma warning restore 618
261246
case JsonOutputMode.CanonicalExtendedJson:
262247
case JsonOutputMode.RelaxedExtendedJson:
263248
default:
@@ -303,9 +288,7 @@ public override void WriteDouble(double value)
303288
_textWriter.Write(stringRepresentation);
304289
}
305290
break;
306-
#pragma warning disable 618
307-
case JsonOutputMode.Strict:
308-
#pragma warning restore 618
291+
309292
case JsonOutputMode.Shell:
310293
default:
311294
_textWriter.Write(stringRepresentation);
@@ -420,9 +403,7 @@ public override void WriteInt32(int value)
420403
case JsonOutputMode.CanonicalExtendedJson:
421404
_textWriter.Write("{{ \"$numberInt\" : \"{0}\" }}", value);
422405
break;
423-
#pragma warning disable 618
424-
case JsonOutputMode.Strict:
425-
#pragma warning restore 618
406+
426407
case JsonOutputMode.RelaxedExtendedJson:
427408
case JsonOutputMode.Shell:
428409
default:
@@ -448,9 +429,6 @@ public override void WriteInt64(long value)
448429
WriteNameHelper(Name);
449430
switch (Settings.OutputMode)
450431
{
451-
#pragma warning disable 618
452-
case JsonOutputMode.Strict:
453-
#pragma warning restore 618
454432
case JsonOutputMode.RelaxedExtendedJson:
455433
_textWriter.Write(value);
456434
break;
@@ -527,9 +505,6 @@ public override void WriteMaxKey()
527505
WriteNameHelper(Name);
528506
switch (Settings.OutputMode)
529507
{
530-
#pragma warning disable 618
531-
case JsonOutputMode.Strict:
532-
#pragma warning restore 618
533508
case JsonOutputMode.CanonicalExtendedJson:
534509
case JsonOutputMode.RelaxedExtendedJson:
535510
_textWriter.Write("{ \"$maxKey\" : 1 }");
@@ -558,9 +533,6 @@ public override void WriteMinKey()
558533
WriteNameHelper(Name);
559534
switch (Settings.OutputMode)
560535
{
561-
#pragma warning disable 618
562-
case JsonOutputMode.Strict:
563-
#pragma warning restore 618
564536
case JsonOutputMode.CanonicalExtendedJson:
565537
case JsonOutputMode.RelaxedExtendedJson:
566538
_textWriter.Write("{ \"$minKey\" : 1 }");
@@ -607,9 +579,6 @@ public override void WriteObjectId(ObjectId objectId)
607579
WriteNameHelper(Name);
608580
switch (Settings.OutputMode)
609581
{
610-
#pragma warning disable 618
611-
case JsonOutputMode.Strict:
612-
#pragma warning restore 618
613582
case JsonOutputMode.CanonicalExtendedJson:
614583
case JsonOutputMode.RelaxedExtendedJson:
615584
_textWriter.Write("{{ \"$oid\" : \"{0}\" }}", objectId.ToString());
@@ -642,12 +611,6 @@ public override void WriteRegularExpression(BsonRegularExpression regex)
642611
WriteNameHelper(Name);
643612
switch (Settings.OutputMode)
644613
{
645-
#pragma warning disable 618
646-
case JsonOutputMode.Strict:
647-
#pragma warning restore 618
648-
_textWriter.Write("{{ \"$regex\" : \"{0}\", \"$options\" : \"{1}\" }}", EscapedString(pattern), EscapedString(options));
649-
break;
650-
651614
case JsonOutputMode.CanonicalExtendedJson:
652615
case JsonOutputMode.RelaxedExtendedJson:
653616
_textWriter.Write("{{ \"$regularExpression\" : {{ \"pattern\" : \"{0}\", \"options\" : \"{1}\" }} }}", EscapedString(pattern), EscapedString(options));
@@ -759,9 +722,6 @@ public override void WriteTimestamp(long value)
759722
WriteNameHelper(Name);
760723
switch (Settings.OutputMode)
761724
{
762-
#pragma warning disable 618
763-
case JsonOutputMode.Strict:
764-
#pragma warning restore 618
765725
case JsonOutputMode.CanonicalExtendedJson:
766726
case JsonOutputMode.RelaxedExtendedJson:
767727
_textWriter.Write("{{ \"$timestamp\" : {{ \"t\" : {0}, \"i\" : {1} }} }}", secondsSinceEpoch, increment);
@@ -790,9 +750,6 @@ public override void WriteUndefined()
790750
WriteNameHelper(Name);
791751
switch (Settings.OutputMode)
792752
{
793-
#pragma warning disable 618
794-
case JsonOutputMode.Strict:
795-
#pragma warning restore 618
796753
case JsonOutputMode.CanonicalExtendedJson:
797754
case JsonOutputMode.RelaxedExtendedJson:
798755
_textWriter.Write("{ \"$undefined\" : true }");

src/MongoDB.Bson/IO/JsonWriterSettings.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class JsonWriterSettings : BsonWriterSettings
2727
private static JsonWriterSettings __defaults = null; // delay creation to pick up the latest default values
2828

2929
// private fields
30-
private Encoding _encoding = Encoding.UTF8;
3130
private bool _indent = false;
3231
private string _indentChars = " ";
3332
private string _newLineChars = "\r\n";
@@ -59,21 +58,6 @@ public static JsonWriterSettings Defaults
5958
set { __defaults = value; }
6059
}
6160

62-
// public properties
63-
/// <summary>
64-
/// Gets or sets the output Encoding.
65-
/// </summary>
66-
[Obsolete("Set the Encoding when you create a StreamWriter instead (this property is ignored).")]
67-
public Encoding Encoding
68-
{
69-
get { return _encoding; }
70-
set
71-
{
72-
if (IsFrozen) { throw new InvalidOperationException("JsonWriterSettings is frozen."); }
73-
_encoding = value;
74-
}
75-
}
76-
7761
/// <summary>
7862
/// Gets or sets whether to indent the output.
7963
/// </summary>
@@ -158,9 +142,6 @@ protected override BsonWriterSettings CloneImplementation()
158142
{
159143
var clone = new JsonWriterSettings
160144
{
161-
#pragma warning disable 618
162-
Encoding = _encoding,
163-
#pragma warning restore 618
164145
Indent = _indent,
165146
IndentChars = _indentChars,
166147
MaxSerializationDepth = MaxSerializationDepth,

src/MongoDB.Bson/ObjectModel/BsonArray.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,6 @@ public virtual bool IsReadOnly
205205
get { return false; }
206206
}
207207

208-
/// <summary>
209-
/// Gets the array elements as raw values (see BsonValue.RawValue).
210-
/// </summary>
211-
[Obsolete("Use ToArray to ToList instead.")]
212-
public virtual IEnumerable<object> RawValues
213-
{
214-
get { return _values.Select(v => v.RawValue); }
215-
}
216-
217208
/// <summary>
218209
/// Gets the array elements.
219210
/// </summary>
@@ -547,20 +538,6 @@ public virtual void CopyTo(BsonValue[] array, int arrayIndex)
547538
}
548539
}
549540

550-
/// <summary>
551-
/// Copies elements from this array to another array as raw values (see BsonValue.RawValue).
552-
/// </summary>
553-
/// <param name="array">The other array.</param>
554-
/// <param name="arrayIndex">The zero based index of the other array at which to start copying.</param>
555-
[Obsolete("Use ToArray or ToList instead.")]
556-
public virtual void CopyTo(object[] array, int arrayIndex)
557-
{
558-
for (int i = 0, j = arrayIndex; i < _values.Count; i++, j++)
559-
{
560-
array[j] = _values[i].RawValue;
561-
}
562-
}
563-
564541
/// <summary>
565542
/// Creates a deep clone of the array (see also Clone).
566543
/// </summary>

src/MongoDB.Bson/ObjectModel/BsonBinaryData.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,6 @@ public byte[] Bytes
9292
get { return _bytes; }
9393
}
9494

95-
/// <summary>
96-
/// Gets the BsonBinaryData as a byte array or a Guid or null depending on the subtype.
97-
/// </summary>
98-
#pragma warning disable 618 // about obsolete BsonBinarySubType.OldBinary
99-
[Obsolete("Use Value instead.")]
100-
public override object RawValue
101-
{
102-
get
103-
{
104-
if (_subType == BsonBinarySubType.UuidStandard)
105-
{
106-
return ToGuid();
107-
}
108-
else
109-
{
110-
return _bytes;
111-
}
112-
}
113-
}
114-
#pragma warning restore 618
115-
11695
/// <summary>
11796
/// Gets the binary data subtype.
11897
/// </summary>

src/MongoDB.Bson/ObjectModel/BsonBoolean.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ public override BsonType BsonType
6767
get { return BsonType.Boolean; }
6868
}
6969

70-
/// <summary>
71-
/// Gets the BsonBoolean as a bool.
72-
/// </summary>
73-
[Obsolete("Use Value instead.")]
74-
public override object RawValue
75-
{
76-
get { return _value; }
77-
}
78-
7970
/// <summary>
8071
/// Gets the value of this BsonBoolean.
8172
/// </summary>

src/MongoDB.Bson/ObjectModel/BsonDateTime.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,6 @@ public long MillisecondsSinceEpoch
7676
get { return _millisecondsSinceEpoch; }
7777
}
7878

79-
/// <summary>
80-
/// Gets the number of milliseconds since the Unix Epoch.
81-
/// </summary>
82-
[Obsolete("Use MillisecondsSinceEpoch instead.")]
83-
public override object RawValue
84-
{
85-
get { return _millisecondsSinceEpoch; }
86-
}
87-
88-
/// <summary>
89-
/// Gets the DateTime value.
90-
/// </summary>
91-
[Obsolete("Use ToUniversalTime instead.")]
92-
public DateTime Value
93-
{
94-
get
95-
{
96-
return BsonUtils.ToDateTimeFromMillisecondsSinceEpoch(_millisecondsSinceEpoch);
97-
}
98-
}
99-
10079
// public operators
10180
/// <summary>
10281
/// Converts a DateTime to a BsonDateTime.

src/MongoDB.Bson/ObjectModel/BsonDecimal128.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ public override BsonType BsonType
4444
get { return BsonType.Decimal128; }
4545
}
4646

47-
/// <inheritdoc />
48-
[Obsolete("Use Value instead.")]
49-
public override object RawValue
50-
{
51-
get { return _value; }
52-
}
53-
5447
/// <summary>
5548
/// Gets the value.
5649
/// </summary>

0 commit comments

Comments
 (0)