Skip to content

Commit acbcd72

Browse files
committed
CSHARP-5171: Adjust changes to driver conventions.
1 parent d3a0baa commit acbcd72

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

src/MongoDB.Driver/Linq/Linq3Implementation/Misc/TypeExtensions.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* Copyright 2010-present MongoDB Inc.
2-
*
3-
* Licensed under the Apache License, Version 2.0 (the "License");
4-
* you may not use this file except in compliance with the License.
5-
* You may obtain a copy of the License at
6-
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
9-
* Unless required by applicable law or agreed to in writing, software
10-
* distributed under the License is distributed on an "AS IS" BASIS,
11-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
* See the License for the specific language governing permissions and
13-
* limitations under the License.
14-
*/
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1515

1616
using System;
1717
using System.Collections.Generic;
@@ -265,9 +265,10 @@ public static bool IsValueTuple(this Type type)
265265

266266
public static bool TryGetGenericInterface(this Type type, Type[] interfaceDefinitions, out Type genericInterface)
267267
{
268-
genericInterface = type.IsConstructedGenericType && interfaceDefinitions.Contains(type.GetGenericTypeDefinition())
269-
? type
270-
: type.GetInterfaces().FirstOrDefault(i => i.IsGenericType && interfaceDefinitions.Contains(i.GetGenericTypeDefinition()));
268+
genericInterface =
269+
type.IsConstructedGenericType && interfaceDefinitions.Contains(type.GetGenericTypeDefinition()) ?
270+
type :
271+
type.GetInterfaces().FirstOrDefault(i => i.IsConstructedGenericType && interfaceDefinitions.Contains(i.GetGenericTypeDefinition()));
271272
return genericInterface != null;
272273
}
273274

tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp5171Tests.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* Copyright 2010-present MongoDB Inc.
2-
*
3-
* Licensed under the Apache License, Version 2.0 (the "License");
4-
* you may not use this file except in compliance with the License.
5-
* You may obtain a copy of the License at
6-
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
9-
* Unless required by applicable law or agreed to in writing, software
10-
* distributed under the License is distributed on an "AS IS" BASIS,
11-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
* See the License for the specific language governing permissions and
13-
* limitations under the License.
14-
*/
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1515

1616
using System;
1717
using System.Collections.Generic;
@@ -55,8 +55,8 @@ public void Select_ReadOnlyDictionary_item_with_string_using_call_to_get_item_sh
5555
var collection = GetCollection(linqProvider);
5656
var x = Expression.Parameter(typeof(C), "x");
5757
var body = Expression.Call(
58-
Expression.Property(x, typeof(C).GetProperty("Dictionary")!),
59-
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item")!.GetGetMethod(),
58+
Expression.Property(x, typeof(C).GetProperty("Dictionary")),
59+
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item").GetGetMethod(),
6060
Expression.Constant("a"));
6161
var selector = Expression.Lambda<Func<C, int>>(body, [x]);
6262

@@ -81,9 +81,9 @@ public void Select_ReadOnlyDictionary_item_with_string_using_MakeIndex_should_wo
8181
var collection = GetCollection(linqProvider);
8282
var x = Expression.Parameter(typeof(C), "x");
8383
var body = Expression.MakeIndex(
84-
Expression.Property(x, typeof(C).GetProperty("Dictionary")!),
84+
Expression.Property(x, typeof(C).GetProperty("Dictionary")),
8585
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item"),
86-
new Expression[] {Expression.Constant("a")});
86+
[Expression.Constant("a")]);
8787
var selector = Expression.Lambda<Func<C, int>>(body, [x]);
8888

8989
var queryable = collection.AsQueryable()
@@ -130,8 +130,8 @@ public void Where_ReadOnlyDictionary_item_with_string_using_call_to_get_item_sho
130130
var x = Expression.Parameter(typeof(C), "x");
131131
var body = Expression.Equal(
132132
Expression.Call(
133-
Expression.Property(x, typeof(C).GetProperty("Dictionary")!),
134-
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item")!.GetGetMethod(),
133+
Expression.Property(x, typeof(C).GetProperty("Dictionary")),
134+
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item").GetGetMethod(),
135135
Expression.Constant("a")),
136136
Expression.Constant(1));
137137
var predicate = Expression.Lambda<Func<C, bool>>(body, [x]);
@@ -155,9 +155,9 @@ public void Where_ReadOnlyDictionary_item_with_string_using_MakeIndex_should_wor
155155
var x = Expression.Parameter(typeof(C), "x");
156156
var body = Expression.Equal(
157157
Expression.MakeIndex(
158-
Expression.Property(x, typeof(C).GetProperty("Dictionary")!),
159-
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item")!,
160-
new Expression[] {Expression.Constant("a")}),
158+
Expression.Property(x, typeof(C).GetProperty("Dictionary")),
159+
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item"),
160+
[Expression.Constant("a")]),
161161
Expression.Constant(1));
162162
var predicate = Expression.Lambda<Func<C, bool>>(body, [x]);
163163

0 commit comments

Comments
 (0)