Skip to content

Commit

Permalink
CSHARP-5171: Adjust changes to driver conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstam committed Jul 22, 2024
1 parent d3a0baa commit acbcd72
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
33 changes: 17 additions & 16 deletions src/MongoDB.Driver/Linq/Linq3Implementation/Misc/TypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -265,9 +265,10 @@ public static bool IsValueTuple(this Type type)

public static bool TryGetGenericInterface(this Type type, Type[] interfaceDefinitions, out Type genericInterface)
{
genericInterface = type.IsConstructedGenericType && interfaceDefinitions.Contains(type.GetGenericTypeDefinition())
? type
: type.GetInterfaces().FirstOrDefault(i => i.IsGenericType && interfaceDefinitions.Contains(i.GetGenericTypeDefinition()));
genericInterface =
type.IsConstructedGenericType && interfaceDefinitions.Contains(type.GetGenericTypeDefinition()) ?
type :
type.GetInterfaces().FirstOrDefault(i => i.IsConstructedGenericType && interfaceDefinitions.Contains(i.GetGenericTypeDefinition()));
return genericInterface != null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -55,8 +55,8 @@ public void Select_ReadOnlyDictionary_item_with_string_using_call_to_get_item_sh
var collection = GetCollection(linqProvider);
var x = Expression.Parameter(typeof(C), "x");
var body = Expression.Call(
Expression.Property(x, typeof(C).GetProperty("Dictionary")!),
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item")!.GetGetMethod(),
Expression.Property(x, typeof(C).GetProperty("Dictionary")),
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item").GetGetMethod(),
Expression.Constant("a"));
var selector = Expression.Lambda<Func<C, int>>(body, [x]);

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

var queryable = collection.AsQueryable()
Expand Down Expand Up @@ -130,8 +130,8 @@ public void Where_ReadOnlyDictionary_item_with_string_using_call_to_get_item_sho
var x = Expression.Parameter(typeof(C), "x");
var body = Expression.Equal(
Expression.Call(
Expression.Property(x, typeof(C).GetProperty("Dictionary")!),
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item")!.GetGetMethod(),
Expression.Property(x, typeof(C).GetProperty("Dictionary")),
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item").GetGetMethod(),
Expression.Constant("a")),
Expression.Constant(1));
var predicate = Expression.Lambda<Func<C, bool>>(body, [x]);
Expand All @@ -155,9 +155,9 @@ public void Where_ReadOnlyDictionary_item_with_string_using_MakeIndex_should_wor
var x = Expression.Parameter(typeof(C), "x");
var body = Expression.Equal(
Expression.MakeIndex(
Expression.Property(x, typeof(C).GetProperty("Dictionary")!),
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item")!,
new Expression[] {Expression.Constant("a")}),
Expression.Property(x, typeof(C).GetProperty("Dictionary")),
typeof(IReadOnlyDictionary<string, int>).GetProperty("Item"),
[Expression.Constant("a")]),
Expression.Constant(1));
var predicate = Expression.Lambda<Func<C, bool>>(body, [x]);

Expand Down

0 comments on commit acbcd72

Please sign in to comment.