Skip to content

Commit 0d19f21

Browse files
committed
fixing up warnings raised by mono and not compiling certain tests where the mono compiler doesn't infer generic arguments.
1 parent 9cb3c0d commit 0d19f21

File tree

11 files changed

+53
-50
lines changed

11 files changed

+53
-50
lines changed

build/build.fsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ Target "Build" (fun _ ->
107107
|> Seq.iter (RestorePackage (fun x -> { x with OutputPath = srcDir @@ "packages" }))
108108

109109

110-
let properties = ["Configuration", config
111-
"TargetFrameworkVersion", "v4.5"]
110+
let mutable properties = ["Configuration", config
111+
"TargetFrameworkVersion", "v4.5"]
112+
113+
if isMono then
114+
properties <- properties @ ["DefineConstants", "MONO"]
112115

113116
[slnFile]
114117
|> MSBuild binDir45 "Build" properties

src/CSharpDriver-Mono.sln

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.31101.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Bson", "MongoDB.Bson\MongoDB.Bson.csproj", "{0E9A3A2A-49CD-4F6C-847C-DC79B4B65CE6}"
77
EndProject
@@ -39,6 +39,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Legacy", "Legacy", "{C0AC2F
3939
EndProject
4040
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{391D831D-5AC7-43F8-8BCB-6AE81B027658}"
4141
EndProject
42+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.GridFS", "MongoDB.Driver.GridFS\MongoDB.Driver.GridFS.csproj", "{6B5D1EA6-1088-4122-B8C4-B341822C7915}"
43+
EndProject
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.GridFS.Tests", "MongoDB.Driver.GridFS.Tests\MongoDB.Driver.GridFS.Tests.csproj", "{1537C58E-BECD-4ED2-A900-1AFBB601D2B2}"
45+
EndProject
4246
Global
4347
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4448
Debug|Any CPU = Debug|Any CPU
@@ -97,6 +101,14 @@ Global
97101
{02AB2E44-785A-4D39-99C0-29F93A02EF84}.Debug|Any CPU.Build.0 = Debug|Any CPU
98102
{02AB2E44-785A-4D39-99C0-29F93A02EF84}.Release|Any CPU.ActiveCfg = Release|Any CPU
99103
{02AB2E44-785A-4D39-99C0-29F93A02EF84}.Release|Any CPU.Build.0 = Release|Any CPU
104+
{6B5D1EA6-1088-4122-B8C4-B341822C7915}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
105+
{6B5D1EA6-1088-4122-B8C4-B341822C7915}.Debug|Any CPU.Build.0 = Debug|Any CPU
106+
{6B5D1EA6-1088-4122-B8C4-B341822C7915}.Release|Any CPU.ActiveCfg = Release|Any CPU
107+
{6B5D1EA6-1088-4122-B8C4-B341822C7915}.Release|Any CPU.Build.0 = Release|Any CPU
108+
{1537C58E-BECD-4ED2-A900-1AFBB601D2B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109+
{1537C58E-BECD-4ED2-A900-1AFBB601D2B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
110+
{1537C58E-BECD-4ED2-A900-1AFBB601D2B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
111+
{1537C58E-BECD-4ED2-A900-1AFBB601D2B2}.Release|Any CPU.Build.0 = Release|Any CPU
100112
EndGlobalSection
101113
GlobalSection(SolutionProperties) = preSolution
102114
HideSolutionNode = FALSE
@@ -115,5 +127,7 @@ Global
115127
{4F42BA31-AAA3-4BD4-A4F2-7F7A53940D69} = {C0AC2FCF-37FB-4A64-ACC6-8490DC15091D}
116128
{89B92FFF-4126-4D9A-93C8-2BD7E0CD82FF} = {11282844-4584-4F65-9857-D4329046E84D}
117129
{02AB2E44-785A-4D39-99C0-29F93A02EF84} = {C0AC2FCF-37FB-4A64-ACC6-8490DC15091D}
130+
{6B5D1EA6-1088-4122-B8C4-B341822C7915} = {11282844-4584-4F65-9857-D4329046E84D}
131+
{1537C58E-BECD-4ED2-A900-1AFBB601D2B2} = {11282844-4584-4F65-9857-D4329046E84D}
118132
EndGlobalSection
119133
EndGlobal

src/MongoDB.Driver.GridFS/GridFSFileInfo.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,7 @@ public class GridFSFileInfoSerializer : BsonDocumentBackedClassSerializer<GridFS
182182
public static GridFSFileInfoSerializer Instance { get; } = new GridFSFileInfoSerializer();
183183
#endregion
184184

185-
/// <summary>
186-
/// Initializes a new instance of the <see cref="GridFSFileInfoSerializer"/> class.
187-
/// </summary>
188-
public GridFSFileInfoSerializer()
185+
private GridFSFileInfoSerializer()
189186
{
190187
RegisterMember("Aliases", "aliases", new ArraySerializer<string>());
191188
RegisterMember("ChunkSizeBytes", "chunkSize", new Int32Serializer());

src/MongoDB.Driver.Tests/AggregateFluentTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public void As_should_add_the_expected_stage()
3737
var result = subject
3838
.Match("{ X : 1 }")
3939
.As<BsonDocument>();
40-
var cursor = result.ToCursorAsync().GetAwaiter().GetResult();
40+
result.ToCursorAsync().GetAwaiter().GetResult();
4141

42-
Predicate<PipelineDefinition<C, BsonDocument>> isExpectedPipeline = pipeline =>
42+
Predicate<PipelineDefinition<C, BsonDocument>> isExpectedPipeline = pipeline =>
4343
{
4444
var serializerRegistry = BsonSerializer.SerializerRegistry;
4545
var inputSerializer = serializerRegistry.GetSerializer<C>();
4646
var rendederedPipeline = pipeline.Render(inputSerializer, serializerRegistry);
47-
return
48-
rendederedPipeline.Documents.Count == 1 &&
47+
return
48+
rendederedPipeline.Documents.Count == 1 &&
4949
rendederedPipeline.Documents[0] == BsonDocument.Parse("{ $match : { X : 1 } }") &&
5050
rendederedPipeline.OutputSerializer is BsonDocumentSerializer;
5151
};
@@ -65,7 +65,7 @@ public void OfType_should_add_the_expected_stage()
6565
.SortBy(c => c.X)
6666
.OfType<D>()
6767
.Match(d => d.Y == 2);
68-
var cursor = result.ToCursorAsync().GetAwaiter().GetResult();
68+
result.ToCursorAsync().GetAwaiter().GetResult();
6969

7070
Predicate<PipelineDefinition<C, D>> isExpectedPipeline = pipeline =>
7171
{

src/MongoDB.Driver.Tests/FieldDefinitionTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ public void Should_resolve_an_enum_without_field_type()
189189
[Test]
190190
public void Should_assign_a_non_typed_field_definition_from_a_typed_field_definition()
191191
{
192-
Expression<Func<Person, object>> exp = x => x.Gender;
193-
194192
FieldDefinition<Person, Gender> subject = new ExpressionFieldDefinition<Person, Gender>(x => x.Gender);
195193
FieldDefinition<Person> subject2 = subject;
196194

src/MongoDB.Driver.Tests/FindFluentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void As_should_change_the_result_type()
3535
var subject = CreateSubject();
3636

3737
var result = subject.As<BsonDocument>();
38-
var cursor = result.ToCursorAsync().GetAwaiter().GetResult();
38+
result.ToCursorAsync().GetAwaiter().GetResult();
3939

4040
Predicate<FindOptions<Person, BsonDocument>> hasExpectedProjection = options =>
4141
{

src/MongoDB.Driver.Tests/Linq/MongoQueryableTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public void GroupBy_select_anonymous_type_method()
266266
"{ $group: { _id: '$A', __agg0: { $first: '$B'} } }",
267267
"{ $project: { Key: '$_id', FirstB: '$__agg0', _id: 0 } }");
268268
}
269-
269+
#if !MONO
270270
[Test]
271271
public void GroupBy_select_anonymous_type_syntax()
272272
{
@@ -279,7 +279,7 @@ group p by p.A into g
279279
"{ $group: { _id: '$A', __agg0: { $first: '$B'} } }",
280280
"{ $project: { Key: '$_id', FirstB: '$__agg0', _id: 0 } }");
281281
}
282-
282+
#endif
283283
[Test]
284284
public void GroupBy_where_method()
285285
{
@@ -321,6 +321,7 @@ public void GroupBy_where_select_anonymous_type_with_duplicate_accumulators_meth
321321
"{ $project: { Key: '$_id', FirstB: '$__agg0', _id: 0 } }");
322322
}
323323

324+
#if !MONO
324325
[Test]
325326
public void GroupBy_where_select_anonymous_type_with_duplicate_accumulators_syntax()
326327
{
@@ -335,7 +336,7 @@ where g.First().B == "Balloon"
335336
"{ $match: { __agg0: 'Balloon' } }",
336337
"{ $project: { Key: '$_id', FirstB: '$__agg0', _id: 0 } }");
337338
}
338-
339+
#endif
339340
[Test]
340341
public void GroupBy_with_resultSelector_anonymous_type_method()
341342
{

src/MongoDB.Driver.Tests/MongoCollectionImplTests.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public void Settings_should_be_set()
8383
[Test]
8484
public async Task AggregateAsync_should_execute_the_AggregateOperation_when_out_is_not_specified()
8585
{
86-
var stages = new PipelineStageDefinition<BsonDocument, BsonDocument>[]
87-
{
86+
var stages = new PipelineStageDefinition<BsonDocument, BsonDocument>[]
87+
{
8888
BsonDocument.Parse("{$match: {x: 2}}")
8989
};
9090
var options = new AggregateOptions()
@@ -115,10 +115,10 @@ public async Task AggregateAsync_should_execute_the_AggregateOperation_when_out_
115115
[Test]
116116
public async Task AggregateAsync_should_execute_the_AggregateToCollectionOperation_and_the_FindOperation_when_out_is_specified()
117117
{
118-
var stages = new PipelineStageDefinition<BsonDocument, BsonDocument>[]
119-
{
120-
BsonDocument.Parse("{$match: {x: 2}}"),
121-
BsonDocument.Parse("{$out: \"funny\"}")
118+
var stages = new PipelineStageDefinition<BsonDocument, BsonDocument>[]
119+
{
120+
BsonDocument.Parse("{$match: {x: 2}}"),
121+
BsonDocument.Parse("{$out: \"funny\"}")
122122
};
123123
var options = new AggregateOptions()
124124
{
@@ -171,8 +171,8 @@ public async Task AggregateAsync_should_execute_the_AggregateToCollectionOperati
171171
[TestCase(false)]
172172
public async Task BulkWriteAsync_should_execute_the_BulkMixedWriteOperation(bool isOrdered)
173173
{
174-
var requests = new WriteModel<BsonDocument>[]
175-
{
174+
var requests = new WriteModel<BsonDocument>[]
175+
{
176176
new InsertOneModel<BsonDocument>(new BsonDocument("_id", 1).Add("a",1)),
177177
new DeleteManyModel<BsonDocument>(new BsonDocument("b", 1)),
178178
new DeleteOneModel<BsonDocument>(new BsonDocument("c", 1)),
@@ -546,7 +546,7 @@ public async Task FindAsync_with_Projection_As_should_execute_correctly()
546546
Projection = Builders<A>.Projection.As<BsonDocument>()
547547
};
548548

549-
var result = await subject.FindAsync(filter, options, CancellationToken.None);
549+
await subject.FindAsync(filter, options, CancellationToken.None);
550550

551551
var call = _operationExecutor.GetReadCall<IAsyncCursor<BsonDocument>>();
552552
call.Operation.Should().BeOfType<FindOperation<BsonDocument>>();
@@ -593,7 +593,7 @@ public async Task FindOneAndDeleteAsync_with_Projection_As_should_execute_correc
593593
Projection = Builders<A>.Projection.As<BsonDocument>()
594594
};
595595

596-
var result = await subject.FindOneAndDeleteAsync(filter, options, CancellationToken.None);
596+
await subject.FindOneAndDeleteAsync(filter, options, CancellationToken.None);
597597

598598
var call = _operationExecutor.GetWriteCall<BsonDocument>();
599599
call.Operation.Should().BeOfType<FindOneAndDeleteOperation<BsonDocument>>();
@@ -651,7 +651,7 @@ public async Task FindOneAndReplaceAsync_with_Projection_As_should_execute_corre
651651
Projection = Builders<A>.Projection.As<BsonDocument>()
652652
};
653653

654-
var result = await subject.FindOneAndReplaceAsync(filter, replacement, options, CancellationToken.None);
654+
await subject.FindOneAndReplaceAsync(filter, replacement, options, CancellationToken.None);
655655

656656
var call = _operationExecutor.GetWriteCall<BsonDocument>();
657657
call.Operation.Should().BeOfType<FindOneAndReplaceOperation<BsonDocument>>();
@@ -709,7 +709,7 @@ public async Task FindOneAndUpdateAsync_with_Projection_As_should_execute_correc
709709
Projection = Builders<A>.Projection.As<BsonDocument>()
710710
};
711711

712-
var result = await subject.FindOneAndUpdateAsync(filter, update, options, CancellationToken.None);
712+
await subject.FindOneAndUpdateAsync(filter, update, options, CancellationToken.None);
713713

714714
var call = _operationExecutor.GetWriteCall<BsonDocument>();
715715
call.Operation.Should().BeOfType<FindOneAndUpdateOperation<BsonDocument>>();
@@ -959,12 +959,12 @@ public void InsertOneAsync_should_throw_a_WriteException_when_an_error_occurs()
959959
[Test]
960960
public async Task InsertManyAsync_should_execute_the_BulkMixedOperation()
961961
{
962-
var documents = new[]
963-
{
962+
var documents = new[]
963+
{
964964
BsonDocument.Parse("{_id:1,a:1}"),
965965
BsonDocument.Parse("{_id:2,a:2}")
966966
};
967-
var expectedRequests = new[]
967+
var expectedRequests = new[]
968968
{
969969
new InsertRequest(documents[0]) { CorrelationId = 0 },
970970
new InsertRequest(documents[1]) { CorrelationId = 1 }

src/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ public void BulkWriteAsync_with_ReplaceOne()
138138
public void BulkWriteAsync_with_UpdateMany()
139139
{
140140
var subject = CreateSubject();
141-
var replacement = new B();
142141
var model = new UpdateManyModel<B>(_providedFilter, "{$set: {x: 1}}") { IsUpsert = true };
143142
var options = new BulkWriteOptions();
144143

@@ -157,7 +156,6 @@ public void BulkWriteAsync_with_UpdateMany()
157156
public void BulkWriteAsync_with_UpdateOne()
158157
{
159158
var subject = CreateSubject();
160-
var replacement = new B();
161159
var model = new UpdateOneModel<B>(_providedFilter, "{$set: {x: 1}}") { IsUpsert = true };
162160
var options = new BulkWriteOptions();
163161

@@ -298,7 +296,7 @@ public void OfType_should_resort_to_root_collections_OfType()
298296
{
299297
var subject = CreateSubject();
300298

301-
var result = subject.OfType<C>();
299+
subject.OfType<C>();
302300

303301
_rootCollection.Received().OfType<C>();
304302
_derivedCollection.DidNotReceive().OfType<C>();

src/MongoDB.Driver.Tests/Samples/AggregationSample.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void TestFixtureSetUp()
3535
_collection = db.GetCollection<ZipEntry>(DriverTestConfiguration.CollectionNamespace.CollectionName);
3636

3737
// This is a subset of the data from the mongodb docs zip code aggregation examples
38-
_collection.InsertManyAsync(new[]
38+
_collection.InsertManyAsync(new[]
3939
{
4040
new ZipEntry { Zip = "01053", City = "LEEDS", State = "MA", Population = 1350 },
4141
new ZipEntry { Zip = "01054", City = "LEVERETT", State = "MA", Population = 1748 },
@@ -71,15 +71,12 @@ public async Task States_with_pops_over_20000_queryable_method()
7171
.GroupBy(x => x.State, (k, s) => new { State = k, TotalPopulation = s.Sum(x => x.Population) })
7272
.Where(x => x.TotalPopulation > 20000);
7373

74-
//pipeline.ToString().Should().Be("aggregate([" +
75-
// "{ \"$group\" : { \"_id\" : \"$state\", \"TotalPopulation\" : { \"$sum\" : \"$pop\" } } }, " +
76-
// "{ \"$match\" : { \"TotalPopulation\" : { \"$gt\" : 20000 } } }])");
77-
7874
var result = await pipeline.ToListAsync();
7975

8076
result.Count.Should().Be(1);
8177
}
8278

79+
#if !MONO
8380
[Test]
8481
public async Task States_with_pops_over_20000_queryable_syntax()
8582
{
@@ -88,15 +85,11 @@ group z by z.State into g
8885
where g.Sum(x => x.Population) > 20000
8986
select new { State = g.Key, TotalPopulation = g.Sum(x => x.Population) };
9087

91-
//pipeline.ToString().Should().Be("aggregate([" +
92-
// "{ \"$group\" : { \"_id\" : \"$state\", \"TotalPopulation\" : { \"$sum\" : \"$pop\" } } }, " +
93-
// "{ \"$match\" : { \"TotalPopulation\" : { \"$gt\" : 20000 } } }, " +
94-
// "{ \"$project\" : { \"State\" : \"$_id\", \"TotalPopulation\" : { \"$gt\" : 20000 } } }])");
95-
9688
var result = await pipeline.ToListAsync();
9789

9890
result.Count.Should().Be(1);
9991
}
92+
#endif
10093

10194
[Test]
10295
public async Task Average_city_population_by_state()
@@ -161,7 +154,7 @@ public async Task Largest_and_smallest_cities_by_state()
161154
result[1].SmallestCity.Name.Should().Be("LEEDS");
162155
result[1].SmallestCity.Population.Should().Be(1350);
163156
}
164-
157+
#if !MONO
165158
[Test]
166159
public async Task Largest_and_smallest_cities_by_state_queryable_syntax()
167160
{
@@ -194,6 +187,7 @@ orderby g.Key
194187
result[1].SmallestCity.Name.Should().Be("LEEDS");
195188
result[1].SmallestCity.Population.Should().Be(1350);
196189
}
190+
#endif
197191

198192
[BsonIgnoreExtraElements]
199193
private class ZipEntry

src/MongoDB.Driver/Linq/Processors/SerializationBinder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ public static Expression Bind(Expression node, IBindingContext context, bool isC
3333
}
3434

3535
private readonly IBindingContext _bindingContext;
36-
private readonly Dictionary<MemberInfo, Expression> _memberMap;
3736
private bool _isInEmbeddedPipeline;
3837
private readonly bool _isClientSideProjection;
3938

4039
private SerializationBinder(IBindingContext bindingContext, bool isClientSideProjection)
4140
{
4241
_bindingContext = bindingContext;
4342
_isClientSideProjection = isClientSideProjection;
44-
_memberMap = new Dictionary<MemberInfo, Expression>();
4543
}
4644

4745
public override Expression Visit(Expression node)

0 commit comments

Comments
 (0)