Skip to content

Commit acd6644

Browse files
authored
CHARP-4752: Remove deprecated GridFS fields (#1491)
1 parent a3283e3 commit acd6644

File tree

9 files changed

+2
-233
lines changed

9 files changed

+2
-233
lines changed

specifications/gridfs/tests/upload.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@
287287
"$hex": "11"
288288
},
289289
"options": {
290-
"chunkSizeBytes": 4,
291-
"contentType": "image/jpeg"
290+
"chunkSizeBytes": 4
292291
}
293292
}
294293
},
@@ -303,8 +302,7 @@
303302
"length": 1,
304303
"chunkSize": 4,
305304
"uploadDate": "*actual",
306-
"filename": "filename",
307-
"contentType": "image/jpeg"
305+
"filename": "filename"
308306
}
309307
]
310308
},

src/MongoDB.Driver/GridFS/GridFSBucket.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,6 @@ private GridFSUploadStream<TFileId> CreateUploadStream(IReadWriteBindingHandle b
736736
id,
737737
filename,
738738
options.Metadata,
739-
options.Aliases,
740-
options.ContentType,
741739
chunkSizeBytes,
742740
batchSize);
743741
#pragma warning restore

src/MongoDB.Driver/GridFS/GridFSFileInfo.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ public GridFSFileInfo(BsonDocument backingDocument, IGridFSFileInfoSerializer<TF
3939
{
4040
}
4141

42-
// public properties
43-
/// <summary>
44-
/// Gets the aliases.
45-
/// </summary>
46-
/// <value>
47-
/// The aliases.
48-
/// </value>
49-
[Obsolete("Place aliases inside metadata instead.")]
50-
public IEnumerable<string> Aliases
51-
{
52-
get { return GetValue<string[]>("Aliases", null); }
53-
}
54-
5542
/// <summary>
5643
/// Gets the backing document.
5744
/// </summary>
@@ -74,18 +61,6 @@ public int ChunkSizeBytes
7461
get { return GetValue<int>("ChunkSizeBytes"); }
7562
}
7663

77-
/// <summary>
78-
/// Gets the type of the content.
79-
/// </summary>
80-
/// <value>
81-
/// The type of the content.
82-
/// </value>
83-
[Obsolete("Place contentType inside metadata instead.")]
84-
public string ContentType
85-
{
86-
get { return GetValue<string>("ContentType", null); }
87-
}
88-
8964
/// <summary>
9065
/// Gets the filename.
9166
/// </summary>

src/MongoDB.Driver/GridFS/GridFSFileInfoCompat.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ public GridFSFileInfo(BsonDocument backingDocument)
4040
{
4141
}
4242

43-
// public properties
44-
/// <summary>
45-
/// Gets the aliases.
46-
/// </summary>
47-
/// <value>
48-
/// The aliases.
49-
/// </value>
50-
[Obsolete("Place aliases inside metadata instead.")]
51-
public IEnumerable<string> Aliases
52-
{
53-
get { return GetValue<string[]>("Aliases", null); }
54-
}
55-
5643
/// <summary>
5744
/// Gets the backing document.
5845
/// </summary>
@@ -75,18 +62,6 @@ public int ChunkSizeBytes
7562
get { return GetValue<int>("ChunkSizeBytes"); }
7663
}
7764

78-
/// <summary>
79-
/// Gets the type of the content.
80-
/// </summary>
81-
/// <value>
82-
/// The type of the content.
83-
/// </value>
84-
[Obsolete("Place contentType inside metadata instead.")]
85-
public string ContentType
86-
{
87-
get { return GetValue<string>("ContentType", null); }
88-
}
89-
9065
/// <summary>
9166
/// Gets the filename.
9267
/// </summary>

src/MongoDB.Driver/GridFS/GridFSForwardOnlyUploadStream.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ internal class GridFSForwardOnlyUploadStream<TFileId> : GridFSUploadStream<TFile
3535

3636
// fields
3737
private bool _aborted;
38-
private readonly List<string> _aliases;
3938
private List<byte[]> _batch;
4039
private long _batchPosition;
4140
private int _batchSize;
4241
private readonly IWriteBinding _binding;
4342
private readonly GridFSBucket<TFileId> _bucket;
4443
private readonly int _chunkSizeBytes;
4544
private bool _closed;
46-
private readonly string _contentType;
4745
private bool _disposed;
4846
private readonly string _filename;
4947
private readonly TFileId _id;
@@ -58,8 +56,6 @@ public GridFSForwardOnlyUploadStream(
5856
TFileId id,
5957
string filename,
6058
BsonDocument metadata,
61-
IEnumerable<string> aliases,
62-
string contentType,
6359
int chunkSizeBytes,
6460
int batchSize)
6561
{
@@ -68,8 +64,6 @@ public GridFSForwardOnlyUploadStream(
6864
_id = id;
6965
_filename = filename;
7066
_metadata = metadata; // can be null
71-
_aliases = aliases == null ? null : aliases.ToList(); // can be null
72-
_contentType = contentType; // can be null
7367
_chunkSizeBytes = chunkSizeBytes;
7468
_batchSize = batchSize;
7569
_batch = new List<byte[]>();
@@ -315,8 +309,6 @@ private BsonDocument CreateFilesCollectionDocument()
315309
{ "chunkSize", _chunkSizeBytes },
316310
{ "uploadDate", uploadDateTime },
317311
{ "filename", _filename },
318-
{ "contentType", _contentType, _contentType != null },
319-
{ "aliases", () => new BsonArray(_aliases.Select(a => new BsonString(a))), _aliases != null },
320312
{ "metadata", _metadata, _metadata != null }
321313
};
322314
}

src/MongoDB.Driver/GridFS/GridFSUploadOptions.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,10 @@ namespace MongoDB.Driver.GridFS
2626
public class GridFSUploadOptions
2727
{
2828
// fields
29-
private IEnumerable<string> _aliases;
3029
private int? _batchSize;
3130
private int? _chunkSizeBytes;
32-
private string _contentType;
3331
private BsonDocument _metadata;
3432

35-
// properties
36-
/// <summary>
37-
/// Gets or sets the aliases.
38-
/// </summary>
39-
/// <value>
40-
/// The aliases.
41-
/// </value>
42-
[Obsolete("Place aliases inside metadata instead.")]
43-
public IEnumerable<string> Aliases
44-
{
45-
get { return _aliases; }
46-
set { _aliases = value; }
47-
}
48-
4933
/// <summary>
5034
/// Gets or sets the batch size.
5135
/// </summary>
@@ -73,19 +57,6 @@ public int? ChunkSizeBytes
7357
set { _chunkSizeBytes = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); }
7458
}
7559

76-
/// <summary>
77-
/// Gets or sets the type of the content.
78-
/// </summary>
79-
/// <value>
80-
/// The type of the content.
81-
/// </value>
82-
[Obsolete("Place contentType inside metadata instead.")]
83-
public string ContentType
84-
{
85-
get { return _contentType; }
86-
set { _contentType = Ensure.IsNullOrNotEmpty(value, nameof(value)); }
87-
}
88-
8960
/// <summary>
9061
/// Gets or sets the metadata.
9162
/// </summary>

tests/MongoDB.Driver.Tests/GridFS/GridFSFileInfoTests.cs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,6 @@ namespace MongoDB.Driver.Tests.GridFS
2727
{
2828
public class GridFSFileInfoTests
2929
{
30-
[Fact]
31-
public void Aliases_get_should_return_the_expected_result()
32-
{
33-
var value = new[] { "alias" };
34-
var subject = CreateSubject(aliases: value);
35-
36-
#pragma warning disable 618
37-
var result = subject.Aliases;
38-
#pragma warning restore
39-
40-
result.Should().Equal(value);
41-
}
42-
43-
[Theory]
44-
[ParameterAttributeData]
45-
public void Aliases_should_be_deserialized_correctly(
46-
[Values(null, new string[0], new string[] { null }, new[] { "a" }, new[] { "a", "b" })]
47-
string[] value)
48-
{
49-
var document = CreateFilesCollectionDocument();
50-
if (value != null)
51-
{
52-
document["aliases"] = new BsonArray(value);
53-
}
54-
55-
var subject = DeserializeFilesCollectionDocument(document);
56-
57-
#pragma warning disable 618
58-
subject.Aliases.Should().Equal(value);
59-
#pragma warning restore
60-
}
61-
6230
[Fact]
6331
public void BackingDocument_get_should_return_the_expected_result()
6432
{
@@ -101,38 +69,6 @@ public void constructor_should_initialize_instance()
10169
result.BackingDocument.Should().BeSameAs(backdocument);
10270
}
10371

104-
[Fact]
105-
public void ContentType_get_should_return_the_expected_result()
106-
{
107-
var value = "application/image";
108-
var subject = CreateSubject(contentType: value);
109-
110-
#pragma warning disable 618
111-
var result = subject.ContentType;
112-
#pragma warning restore
113-
114-
result.Should().Be(value);
115-
}
116-
117-
[Theory]
118-
[ParameterAttributeData]
119-
public void ContentType_should_be_deserialized_correctly(
120-
[Values(null, "type")]
121-
string value)
122-
{
123-
var document = CreateFilesCollectionDocument();
124-
if (value != null)
125-
{
126-
document["contentType"] = value;
127-
}
128-
129-
var subject = DeserializeFilesCollectionDocument(document);
130-
131-
#pragma warning disable 618
132-
subject.ContentType.Should().Be(value);
133-
#pragma warning restore
134-
}
135-
13672
[Theory]
13773
[ParameterAttributeData]
13874
public void ExtraElements_should_be_deserialized_correctly(

tests/MongoDB.Driver.Tests/GridFS/GridFSUploadOptionsTests.cs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,6 @@ namespace MongoDB.Driver.Tests.GridFS
2424
{
2525
public class GridFSUploadOptionsTests
2626
{
27-
[Fact]
28-
public void Aliases_get_should_return_expected_result()
29-
{
30-
#pragma warning disable 618
31-
var value = new[] { "alias" };
32-
var subject = new GridFSUploadOptions { Aliases = value };
33-
34-
var result = subject.Aliases;
35-
#pragma warning restore
36-
37-
result.Should().BeSameAs(value);
38-
}
39-
40-
[Fact]
41-
public void Aliases_set_should_have_expected_result()
42-
{
43-
var subject = new GridFSUploadOptions();
44-
var value = new[] { "alias" };
45-
46-
#pragma warning disable 618
47-
subject.Aliases = value;
48-
49-
subject.Aliases.Should().BeSameAs(value);
50-
#pragma warning restore
51-
}
52-
5327
[Fact]
5428
public void BatchSize_get_should_return_expected_result()
5529
{
@@ -116,52 +90,14 @@ public void ChunkSizeBytes_set_should_throw_when_value_is_invalid(
11690
action.ShouldThrow<ArgumentException>().And.ParamName.Should().Be("value");
11791
}
11892

119-
[Fact]
120-
public void ContentType_get_should_return_expected_result()
121-
{
122-
#pragma warning disable 618
123-
var subject = new GridFSUploadOptions { ContentType = "type" };
124-
125-
var result = subject.ContentType;
126-
127-
result.Should().Be("type");
128-
#pragma warning restore
129-
}
130-
131-
[Fact]
132-
public void ContentType_set_should_have_expected_result()
133-
{
134-
#pragma warning disable 618
135-
var subject = new GridFSUploadOptions();
136-
137-
subject.ContentType = "type";
138-
139-
subject.ContentType.Should().Be("type");
140-
#pragma warning restore
141-
}
142-
143-
[Fact]
144-
public void ContentType_set_should_throw_when_value_is_invalid()
145-
{
146-
#pragma warning disable 618
147-
var subject = new GridFSUploadOptions();
148-
149-
Action action = () => subject.ContentType = "";
150-
151-
action.ShouldThrow<ArgumentException>().And.ParamName.Should().Be("value");
152-
#pragma warning restore
153-
}
154-
15593
[Fact]
15694
public void default_constructor_should_return_expected_result()
15795
{
15896
var result = new GridFSUploadOptions();
15997

16098
#pragma warning disable 618
161-
result.Aliases.Should().BeNull();
16299
result.BatchSize.Should().NotHaveValue();
163100
result.ChunkSizeBytes.Should().NotHaveValue();
164-
result.ContentType.Should().BeNull();
165101
result.Metadata.Should().BeNull();
166102
#pragma warning restore
167103
}

tests/MongoDB.Driver.Tests/Specifications/gridfs/GridFSUploadFromBytesTest.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,10 @@ private void ParseOptions(BsonDocument options)
8585
_options = _options ?? new GridFSUploadOptions();
8686
switch (option.Name)
8787
{
88-
case "aliases":
89-
#pragma warning disable 618
90-
_options.Aliases = option.Value.AsBsonArray.Select(v => v.AsString);
91-
#pragma warning restore
92-
break;
93-
9488
case "chunkSizeBytes":
9589
_options.ChunkSizeBytes = option.Value.ToInt32();
9690
break;
9791

98-
case "contentType":
99-
#pragma warning disable 618
100-
_options.ContentType = option.Value.AsString;
101-
#pragma warning restore
102-
break;
103-
10492
case "metadata":
10593
_options.Metadata = option.Value.AsBsonDocument;
10694
break;

0 commit comments

Comments
 (0)