Skip to content

Commit d7bb0c8

Browse files
authored
VS-160: Support for 3.0 driver (#89)
1 parent 56916d9 commit d7bb0c8

File tree

88 files changed

+838
-1295
lines changed

Some content is hidden

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

88 files changed

+838
-1295
lines changed

MongoDB.Analyzer.sln

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,56 +24,33 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2424
.editorconfig = .editorconfig
2525
EndProjectSection
2626
EndProject
27-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Analyzer.Tests.Common.ClassLibrary", "tests\MongoDB.Analyzer.Tests.Common.ClassLibrary\MongoDB.Analyzer.Tests.Common.ClassLibrary.csproj", "{8335EFD4-C859-4E7B-B7D5-C57FC443700C}"
27+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Analyzer.Tests.Common.ClassLibrary", "tests\MongoDB.Analyzer.Tests.Common.ClassLibrary\MongoDB.Analyzer.Tests.Common.ClassLibrary.csproj", "{8335EFD4-C859-4E7B-B7D5-C57FC443700C}"
2828
EndProject
2929
Global
3030
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3131
Debug|Any CPU = Debug|Any CPU
3232
Release|Any CPU = Release|Any CPU
33-
DRIVER_2_27_OR_LOWER|Any CPU = DRIVER_2_27_OR_LOWER|Any CPU
34-
DRIVER_2_28_OR_GREATER|Any CPU = DRIVER_2_28_OR_GREATER|Any CPU
3533
EndGlobalSection
3634
GlobalSection(ProjectConfigurationPlatforms) = postSolution
3735
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3836
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
3937
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
4038
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.Release|Any CPU.Build.0 = Release|Any CPU
41-
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.DRIVER_2_27_OR_LOWER|Any CPU.ActiveCfg = Debug|Any CPU
42-
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.DRIVER_2_27_OR_LOWER|Any CPU.Build.0 = Debug|Any CPU
43-
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.DRIVER_2_28_OR_GREATER|Any CPU.ActiveCfg = Debug|Any CPU
44-
{F65EE23C-7B5B-4B8B-B9A7-386D08BDD3F5}.DRIVER_2_28_OR_GREATER|Any CPU.Build.0 = Debug|Any CPU
4539
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4640
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.Debug|Any CPU.Build.0 = Debug|Any CPU
4741
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.Release|Any CPU.ActiveCfg = Release|Any CPU
4842
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.Release|Any CPU.Build.0 = Release|Any CPU
49-
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.DRIVER_2_27_OR_LOWER|Any CPU.ActiveCfg = Debug|Any CPU
50-
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.DRIVER_2_27_OR_LOWER|Any CPU.Build.0 = Debug|Any CPU
51-
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.DRIVER_2_28_OR_GREATER|Any CPU.ActiveCfg = Debug|Any CPU
52-
{612B7D09-FEF8-4C12-B31A-04B02EC1F297}.DRIVER_2_28_OR_GREATER|Any CPU.Build.0 = Debug|Any CPU
5343
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5444
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
5545
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
5646
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.Release|Any CPU.Build.0 = Release|Any CPU
57-
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.DRIVER_2_27_OR_LOWER|Any CPU.ActiveCfg = Debug|Any CPU
58-
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.DRIVER_2_27_OR_LOWER|Any CPU.Build.0 = Debug|Any CPU
59-
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.DRIVER_2_28_OR_GREATER|Any CPU.ActiveCfg = Debug|Any CPU
60-
{ACB908A0-7F5C-44DA-B9D2-CCFBCAEADD1D}.DRIVER_2_28_OR_GREATER|Any CPU.Build.0 = Debug|Any CPU
6147
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.Debug|Any CPU.ActiveCfg = DRIVER_2_19|Any CPU
6248
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.Debug|Any CPU.Build.0 = DRIVER_2_19|Any CPU
63-
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.Release|Any CPU.ActiveCfg = DRIVER_2_19|Any CPU
64-
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.Release|Any CPU.Build.0 = DRIVER_2_19|Any CPU
65-
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.DRIVER_2_27_OR_LOWER|Any CPU.ActiveCfg = DRIVER_2_12|Any CPU
66-
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.DRIVER_2_27_OR_LOWER|Any CPU.Build.0 = DRIVER_2_12|Any CPU
67-
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.DRIVER_2_28_OR_GREATER|Any CPU.ActiveCfg = DRIVER_2_12|Any CPU
68-
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.DRIVER_2_28_OR_GREATER|Any CPU.Build.0 = DRIVER_2_12|Any CPU
69-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.Debug|Any CPU.ActiveCfg = DRIVER_2_28_OR_GREATER|Any CPU
70-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.Debug|Any CPU.Build.0 = DRIVER_2_28_OR_GREATER|Any CPU
71-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.Release|Any CPU.ActiveCfg = DRIVER_2_27_OR_LOWER|Any CPU
72-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.Release|Any CPU.Build.0 = DRIVER_2_27_OR_LOWER|Any CPU
73-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.DRIVER_2_27_OR_LOWER|Any CPU.ActiveCfg = DRIVER_2_27_OR_LOWER|Any CPU
74-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.DRIVER_2_27_OR_LOWER|Any CPU.Build.0 = DRIVER_2_27_OR_LOWER|Any CPU
75-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.DRIVER_2_28_OR_GREATER|Any CPU.ActiveCfg = DRIVER_2_28_OR_GREATER|Any CPU
76-
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.DRIVER_2_28_OR_GREATER|Any CPU.Build.0 = DRIVER_2_28_OR_GREATER|Any CPU
49+
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.Release|Any CPU.ActiveCfg = Release|Any CPU
50+
{C9D49CAA-3F1F-4969-BDC1-0D17F9DB2B65}.Release|Any CPU.Build.0 = Release|Any CPU
51+
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52+
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.Release|Any CPU.ActiveCfg = Debug|Any CPU
53+
{8335EFD4-C859-4E7B-B7D5-C57FC443700C}.Release|Any CPU.Build.0 = Debug|Any CPU
7754
EndGlobalSection
7855
GlobalSection(SolutionProperties) = preSolution
7956
HideSolutionNode = FALSE
@@ -92,8 +69,8 @@ Global
9269
EndGlobalSection
9370
GlobalSection(SharedMSBuildProjectFiles) = preSolution
9471
tests\MongoDB.Analyzer.Tests.Common.TestCases\MongoDB.Analyzer.Tests.Common.TestCases.projitems*{1845551f-deff-4082-b2db-3548a44f83af}*SharedItemsImports = 13
95-
tests\MongoDB.Analyzer.Tests.Common\MongoDB.Analyzer.Tests.Common.projitems*{41218684-a8e3-41ac-8f85-58b9b2f43b09}*SharedItemsImports = 5
9672
tests\MongoDB.Analyzer.Tests.Common\MongoDB.Analyzer.Tests.Common.projitems*{4f59be68-9ab5-4dcc-8049-04ad7bb36ab6}*SharedItemsImports = 13
73+
tests\MongoDB.Analyzer.Tests.Common\MongoDB.Analyzer.Tests.Common.projitems*{8335efd4-c859-4e7b-b7d5-c57fc443700c}*SharedItemsImports = 5
9774
tests\MongoDB.Analyzer.Tests.Common.TestCases\MongoDB.Analyzer.Tests.Common.TestCases.projitems*{acb908a0-7f5c-44da-b9d2-ccfbcaeadd1d}*SharedItemsImports = 5
9875
tests\MongoDB.Analyzer.Tests.Common\MongoDB.Analyzer.Tests.Common.projitems*{acb908a0-7f5c-44da-b9d2-ccfbcaeadd1d}*SharedItemsImports = 5
9976
EndGlobalSection

evergreen/evergreen.yml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -351,30 +351,10 @@ axes:
351351
display_name: "latest"
352352
variables:
353353
DRIVER_VERSION: "latest"
354-
- id: "2.25"
355-
display_name: "2.25.0"
354+
- id: "3.0.0"
355+
display_name: "3.0.0"
356356
variables:
357-
DRIVER_VERSION: "2.25.0"
358-
- id: "2.23"
359-
display_name: "2.23.0"
360-
variables:
361-
DRIVER_VERSION: "2.23.0"
362-
- id: "2.21"
363-
display_name: "2.21.0"
364-
variables:
365-
DRIVER_VERSION: "2.21.0"
366-
- id: "2.19.0"
367-
display_name: "2.19.0"
368-
variables:
369-
DRIVER_VERSION: "2.19.0"
370-
- id: "2.18.0"
371-
display_name: "2.18.0"
372-
variables:
373-
DRIVER_VERSION: "2.18.0"
374-
- id: "2.12.4"
375-
display_name: "2.12.4"
376-
variables:
377-
DRIVER_VERSION: "2.12.4"
357+
DRIVER_VERSION: "3.0.0"
378358

379359
- id: os
380360
display_name: OS
@@ -390,12 +370,12 @@ axes:
390370
OS: "ubuntu-2004"
391371
python3_binary: "/opt/python/3.8/bin/python3"
392372
run_on: ubuntu2004-test
393-
- id: "macos-1100"
394-
display_name: "macOS 11.00"
373+
- id: "macos-14"
374+
display_name: "macOS 14.00"
395375
variables:
396-
OS: "macos-1100"
376+
OS: "macos-1400"
397377
python3_binary: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
398-
run_on: macos-1100
378+
run_on: macos-14
399379

400380
buildvariants:
401381
- matrix_name: "tests-linux"
@@ -406,7 +386,7 @@ buildvariants:
406386
- name: test-netcoreapp31
407387

408388
- matrix_name: "tests-mac"
409-
matrix_spec: { os: ["macos-1100"], driver: "*"}
389+
matrix_spec: { os: ["macos-14"], driver: "*"}
410390
display_name: "${driver} CSharp Analyzer on ${os}, driver version ${driver}"
411391
tags: ["tests-variant"]
412392
tasks:

evergreen/run-tests.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ echo Testing with driver: "${DRIVER_VERSION}" "${TARGET_FRAMEWORK}"
66

77
dotnet clean "./MongoDB.Analyzer.sln"
88

9-
dotnet build "./tests/MongoDB.Analyzer.Tests.Common.ClassLibrary" -f netstandard2.0 -c DRIVER_2_27_OR_LOWER
10-
dotnet build "./tests/MongoDB.Analyzer.Tests.Common.ClassLibrary" -f netstandard2.0 -c DRIVER_2_28_OR_GREATER
9+
dotnet build "./tests/MongoDB.Analyzer.Tests.Common.ClassLibrary" -f netstandard2.0 -c Debug
1110

1211
dotnet test "./MongoDB.Analyzer.sln" -e DRIVER_VERSION="${DRIVER_VERSION}" --framework "${TARGET_FRAMEWORK}" -c Release --results-directory ./build/test-results --logger "junit;LogFileName=TEST-MongoDB.Analyzer.xml;FailureBodyFormat=Verbose"

src/MongoDB.Analyzer.Helpers/Builders/MqlGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static class MqlGenerator
2727
private static readonly Int32 s_dummyRef1; // using System
2828
private static readonly BsonType s_dummyRef2; // using MongoDB.Bson
2929
private static readonly TimeSpanUnits s_dummyRef3; // using MongoDB.Bson.Serialization.Option
30+
private static readonly IQueryable<int> s_dummyRef4; // using System.Linq
3031
#pragma warning restore IDE0051 // These fields are never used, they are needed to ensure that the relevant usings are not accidently removed
3132
#pragma warning restore CS0169
3233

@@ -36,7 +37,6 @@ private sealed class MqlGeneratorTemplateType
3637
}
3738

3839
public static string GetDriverVersion() => typeof(Builders<>).Assembly.GetName().Version.ToString(3);
39-
public static int[] LinqReference => Enumerable.Range(1, 10).ToArray();
4040

4141
public static string GetMQL()
4242
{

src/MongoDB.Analyzer.Helpers/Builders/Renderer.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,37 @@ public static partial class Renderer
2121
{
2222
public static string Render<T>(FilterDefinition<T> filterDefinition)
2323
{
24-
var renderedBuildersDefinition = filterDefinition.Render(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
24+
var renderedBuildersDefinition = filterDefinition.Render(GetRenderArgs<T>());
2525
return renderedBuildersDefinition.ToString();
2626
}
2727

2828
public static string Render<T>(UpdateDefinition<T> updateDefinition)
2929
{
30-
var renderedBuildersDefinition = updateDefinition.Render(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
30+
var renderedBuildersDefinition = updateDefinition.Render(GetRenderArgs<T>());
3131
return renderedBuildersDefinition.ToString();
3232
}
3333

3434
public static string Render<T>(SortDefinition<T> sortDefinition)
3535
{
36-
var renderedBuildersDefinition = sortDefinition.Render(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
36+
var renderedBuildersDefinition = sortDefinition.Render(GetRenderArgs<T>());
3737
return renderedBuildersDefinition.ToString();
3838
}
3939

4040
public static string Render<T>(IndexKeysDefinition<T> indexDefinition)
4141
{
42-
var renderedBuildersDefinition = indexDefinition.Render(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
42+
var renderedBuildersDefinition = indexDefinition.Render(GetRenderArgs<T>());
4343
return renderedBuildersDefinition.ToString();
4444
}
4545

4646
public static string Render<T>(ProjectionDefinition<T> projectionDefinition)
4747
{
48-
var renderedBuildersDefinition = projectionDefinition.Render(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
48+
var renderedBuildersDefinition = projectionDefinition.Render(GetRenderArgs<T>());
4949
return renderedBuildersDefinition.ToString();
5050
}
5151

5252
public static string Render<T, E>(ProjectionDefinition<T, E> projectionDefinition)
5353
{
54-
var renderedBuildersDefinition = projectionDefinition.Render(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
54+
var renderedBuildersDefinition = projectionDefinition.Render(GetRenderArgs<T>());
5555
return renderedBuildersDefinition.Document.ToString();
5656
}
5757

@@ -60,19 +60,12 @@ public static string Render<T, E>(IFindFluent<T, E> fluentDefinition)
6060
return fluentDefinition.ToString();
6161
}
6262

63-
#if DRIVER_2_21_OR_GREATER
6463
public static string Render<T>(MongoDB.Driver.Search.SearchDefinition<T> searchDefinition)
6564
{
66-
var renderedBuildersDefinition = searchDefinition.Render(new MongoDB.Driver.Search.SearchDefinitionRenderContext<T>(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry));
65+
var renderedBuildersDefinition = searchDefinition.Render(GetRenderArgs<T>());
6766
return renderedBuildersDefinition.ToString();
6867
}
69-
#elif DRIVER_2_19_OR_GREATER
70-
public static string Render<T>(MongoDB.Driver.Search.SearchDefinition<T> searchDefinition)
71-
{
72-
var renderedBuildersDefinition = searchDefinition.Render(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
73-
return renderedBuildersDefinition.ToString();
74-
}
75-
#endif
68+
69+
private static RenderArgs<T> GetRenderArgs<T>() => new RenderArgs<T>(BsonSerializer.LookupSerializer<T>(), BsonSerializer.SerializerRegistry);
7670
}
7771
}
78-

src/MongoDB.Analyzer.Helpers/EmptyCursor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ public void Dispose() { }
2828
public Task<bool> MoveNextAsync(CancellationToken cancellationToken = default) => Task.FromResult(false);
2929
}
3030
}
31-

src/MongoDB.Analyzer.Helpers/Linq/MqlGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ private sealed class MqlGeneratorTemplateType
3535
public Tuple<int, int> Field { get; set; }
3636
}
3737

38-
public static string GetDriverVersion() => typeof(IMongoQueryable<>).Assembly.GetName().Version.ToString(3);
38+
public static string GetDriverVersion() => typeof(MongoQueryable).Assembly.GetName().Version.ToString(3);
3939

40-
public static string GetMQL(bool isV3)
40+
public static string GetMQL()
4141
{
42-
var queryable = QueryableProvider.GetQueryable<MqlGeneratorTemplateType>(isV3);
42+
var queryable = new MongoCollectionMock<MqlGeneratorTemplateType>().AsQueryable();
4343
var queryableWithExpression = queryable.Where(t => t.Field.Item1 == 1);
4444

4545
queryableWithExpression.FirstOrDefault();

src/MongoDB.Analyzer.Helpers/Linq/QueryableProvider.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)