Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CSharpDriver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,72 +64,105 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release_CSharp_14|Any CPU = Release_CSharp_14|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9FCB42A5-3BC6-492B-8EA0-53EF32E9F8CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FCB42A5-3BC6-492B-8EA0-53EF32E9F8CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FCB42A5-3BC6-492B-8EA0-53EF32E9F8CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FCB42A5-3BC6-492B-8EA0-53EF32E9F8CD}.Release|Any CPU.Build.0 = Release|Any CPU
{9FCB42A5-3BC6-492B-8EA0-53EF32E9F8CD}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{9FCB42A5-3BC6-492B-8EA0-53EF32E9F8CD}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{3CE61F2A-B852-45F9-B607-E0FFFEF9DBC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CE61F2A-B852-45F9-B607-E0FFFEF9DBC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CE61F2A-B852-45F9-B607-E0FFFEF9DBC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CE61F2A-B852-45F9-B607-E0FFFEF9DBC6}.Release|Any CPU.Build.0 = Release|Any CPU
{3CE61F2A-B852-45F9-B607-E0FFFEF9DBC6}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{3CE61F2A-B852-45F9-B607-E0FFFEF9DBC6}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{4D6F0AD1-91CE-4736-AD4E-D9B11E49F206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D6F0AD1-91CE-4736-AD4E-D9B11E49F206}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D6F0AD1-91CE-4736-AD4E-D9B11E49F206}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D6F0AD1-91CE-4736-AD4E-D9B11E49F206}.Release|Any CPU.Build.0 = Release|Any CPU
{4D6F0AD1-91CE-4736-AD4E-D9B11E49F206}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{4D6F0AD1-91CE-4736-AD4E-D9B11E49F206}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{756980B3-0DCF-42F0-A324-C386B1A3E9F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{756980B3-0DCF-42F0-A324-C386B1A3E9F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{756980B3-0DCF-42F0-A324-C386B1A3E9F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{756980B3-0DCF-42F0-A324-C386B1A3E9F4}.Release|Any CPU.Build.0 = Release|Any CPU
{756980B3-0DCF-42F0-A324-C386B1A3E9F4}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{756980B3-0DCF-42F0-A324-C386B1A3E9F4}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{253DBC37-A955-4CCE-8EAF-9CF4A91895DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{253DBC37-A955-4CCE-8EAF-9CF4A91895DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{253DBC37-A955-4CCE-8EAF-9CF4A91895DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{253DBC37-A955-4CCE-8EAF-9CF4A91895DB}.Release|Any CPU.Build.0 = Release|Any CPU
{253DBC37-A955-4CCE-8EAF-9CF4A91895DB}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{253DBC37-A955-4CCE-8EAF-9CF4A91895DB}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{FD003B6D-C0C3-4D1E-832D-1AA96AF0244C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD003B6D-C0C3-4D1E-832D-1AA96AF0244C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD003B6D-C0C3-4D1E-832D-1AA96AF0244C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD003B6D-C0C3-4D1E-832D-1AA96AF0244C}.Release|Any CPU.Build.0 = Release|Any CPU
{FD003B6D-C0C3-4D1E-832D-1AA96AF0244C}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{FD003B6D-C0C3-4D1E-832D-1AA96AF0244C}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{F2E68945-76FC-49D5-8CB2-B23C76FF09C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2E68945-76FC-49D5-8CB2-B23C76FF09C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2E68945-76FC-49D5-8CB2-B23C76FF09C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2E68945-76FC-49D5-8CB2-B23C76FF09C7}.Release|Any CPU.Build.0 = Release|Any CPU
{F2E68945-76FC-49D5-8CB2-B23C76FF09C7}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{F2E68945-76FC-49D5-8CB2-B23C76FF09C7}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{C50D554C-2771-4CC1-9B2C-BB17FB27F935}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C50D554C-2771-4CC1-9B2C-BB17FB27F935}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C50D554C-2771-4CC1-9B2C-BB17FB27F935}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C50D554C-2771-4CC1-9B2C-BB17FB27F935}.Release|Any CPU.Build.0 = Release|Any CPU
{C50D554C-2771-4CC1-9B2C-BB17FB27F935}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{C50D554C-2771-4CC1-9B2C-BB17FB27F935}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{B90F025F-89D3-436A-AD78-6AA304A6E240}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B90F025F-89D3-436A-AD78-6AA304A6E240}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B90F025F-89D3-436A-AD78-6AA304A6E240}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B90F025F-89D3-436A-AD78-6AA304A6E240}.Release|Any CPU.Build.0 = Release|Any CPU
{B90F025F-89D3-436A-AD78-6AA304A6E240}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{B90F025F-89D3-436A-AD78-6AA304A6E240}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{B711A69F-A337-452C-95E1-A6B15C727CBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B711A69F-A337-452C-95E1-A6B15C727CBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B711A69F-A337-452C-95E1-A6B15C727CBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B711A69F-A337-452C-95E1-A6B15C727CBA}.Release|Any CPU.Build.0 = Release|Any CPU
{B711A69F-A337-452C-95E1-A6B15C727CBA}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{B711A69F-A337-452C-95E1-A6B15C727CBA}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{DF888021-744F-4A8B-9324-831DEFC48AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF888021-744F-4A8B-9324-831DEFC48AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF888021-744F-4A8B-9324-831DEFC48AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF888021-744F-4A8B-9324-831DEFC48AB8}.Release|Any CPU.Build.0 = Release|Any CPU
{DF888021-744F-4A8B-9324-831DEFC48AB8}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{DF888021-744F-4A8B-9324-831DEFC48AB8}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{CF670F4A-49DD-4030-A4A0-1F4D600EB70A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF670F4A-49DD-4030-A4A0-1F4D600EB70A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF670F4A-49DD-4030-A4A0-1F4D600EB70A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF670F4A-49DD-4030-A4A0-1F4D600EB70A}.Release|Any CPU.Build.0 = Release|Any CPU
{CF670F4A-49DD-4030-A4A0-1F4D600EB70A}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{CF670F4A-49DD-4030-A4A0-1F4D600EB70A}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{33B11279-DA4A-46EA-99BF-9DEDCAC50D95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33B11279-DA4A-46EA-99BF-9DEDCAC50D95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33B11279-DA4A-46EA-99BF-9DEDCAC50D95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33B11279-DA4A-46EA-99BF-9DEDCAC50D95}.Release|Any CPU.Build.0 = Release|Any CPU
{33B11279-DA4A-46EA-99BF-9DEDCAC50D95}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{33B11279-DA4A-46EA-99BF-9DEDCAC50D95}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{642518BC-D28A-4ABC-851C-BC18CC34EEDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{642518BC-D28A-4ABC-851C-BC18CC34EEDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{642518BC-D28A-4ABC-851C-BC18CC34EEDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{642518BC-D28A-4ABC-851C-BC18CC34EEDA}.Release|Any CPU.Build.0 = Release|Any CPU
{642518BC-D28A-4ABC-851C-BC18CC34EEDA}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{642518BC-D28A-4ABC-851C-BC18CC34EEDA}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{AB4AD0CB-756C-444F-9F37-26DA35148934}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB4AD0CB-756C-444F-9F37-26DA35148934}.Release|Any CPU.Build.0 = Release|Any CPU
{AB4AD0CB-756C-444F-9F37-26DA35148934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB4AD0CB-756C-444F-9F37-26DA35148934}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB4AD0CB-756C-444F-9F37-26DA35148934}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{AB4AD0CB-756C-444F-9F37-26DA35148934}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
{A0CAC199-457E-4862-AF9E-971C7A77CBF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0CAC199-457E-4862-AF9E-971C7A77CBF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0CAC199-457E-4862-AF9E-971C7A77CBF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0CAC199-457E-4862-AF9E-971C7A77CBF9}.Release|Any CPU.Build.0 = Release|Any CPU
{A0CAC199-457E-4862-AF9E-971C7A77CBF9}.Release_CSharp_14|Any CPU.ActiveCfg = Release_CSharp_14|Any CPU
{A0CAC199-457E-4862-AF9E-971C7A77CBF9}.Release_CSharp_14|Any CPU.Build.0 = Release_CSharp_14|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 3 additions & 1 deletion evergreen/compile-sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
set -o errexit # Exit the script with error if any of the commands fail

SOURCE_PROJECT=${1:-CSharpDriver.sln}
CONFIGURATION=${CONFIGURATION:-'Release'}

if [ -z "$PACKAGE_VERSION" ]; then
PACKAGE_VERSION=$(bash ./evergreen/get-version.sh)
echo Calculated PACKAGE_VERSION value: "$PACKAGE_VERSION"
Expand Down Expand Up @@ -30,4 +32,4 @@ do
sleep $DELAY
done

dotnet build "${SOURCE_PROJECT}" -c Release --no-restore -p:Version="$PACKAGE_VERSION"
dotnet build "${SOURCE_PROJECT}" -c "${CONFIGURATION}" --no-restore -p:Version="$PACKAGE_VERSION"
15 changes: 15 additions & 0 deletions evergreen/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ functions:
shell: "bash"
include_expansions_in_env:
- "FRAMEWORK"
- "CONFIGURATION"
script: |
${PREPARE_SHELL}
bash ./evergreen/run-unit-tests.sh
Expand Down Expand Up @@ -1123,6 +1124,16 @@ tasks:
FRAMEWORK: net10.0
- func: run-unit-tests

- name: unit-tests-net100-csharp14
commands:
- func: configure-framework
vars:
FRAMEWORK: net10.0
DOTNET_SDK_VERSION: 10.0
- func: run-unit-tests
vars:
CONFIGURATION: "Release_CSharp_14"

- name: test-net472
commands:
- func: setup-csfle-secrets
Expand Down Expand Up @@ -2390,6 +2401,7 @@ buildvariants:
- name: unit-tests-netstandard21
- name: unit-tests-net60
- name: unit-tests-net100
- name: unit-tests-net100-csharp14

- name: unit-tests-ubuntu
display_name: Unit Tests on Ubuntu
Expand All @@ -2400,6 +2412,7 @@ buildvariants:
- name: unit-tests-netstandard21
- name: unit-tests-net60
- name: unit-tests-net100
- name: unit-tests-net100-csharp14

- name: unit-tests-macos
display_name: Unit Tests on MacOs
Expand All @@ -2410,6 +2423,7 @@ buildvariants:
- name: unit-tests-netstandard21
- name: unit-tests-net60
- name: unit-tests-net100
- name: unit-tests-net100-csharp14

- name: unit-tests-macos-arm
display_name: Unit Tests on MacOs Arm
Expand All @@ -2419,6 +2433,7 @@ buildvariants:
tasks:
- name: unit-tests-net60
- name: unit-tests-net100
- name: unit-tests-net100-csharp14

- matrix_name: stable-api-tests
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: ["standalone", "sharded-cluster"], auth: "auth", ssl: "nossl", os: "windows-64" }
Expand Down
3 changes: 2 additions & 1 deletion evergreen/execute-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set -o errexit # Exit the script with error if any of the commands fail
FRAMEWORK=${FRAMEWORK:-}
TEST_CATEGORY=${TEST_CATEGORY:-Integration}
TEST_PROJECT_PATH=${TEST_PROJECT_PATH:-./tests/**/[!AtlasConnectivity]*.Tests.csproj}
CONFIGURATION=${CONFIGURATION:-'Release'}

if [ "$FRAMEWORK" = "netstandard2.1" ]; then
FRAMEWORK="netcoreapp3.1"
Expand All @@ -31,5 +32,5 @@ if [[ -n "${FRAMEWORK}" ]]; then
fi

for file in $TEST_PROJECT_PATH; do
dotnet test "${file}" -c Release --no-build ${FILTER_PARAMETER} ${FRAMEWORK_PARAMETER} --results-directory ./build/test-results --logger "junit;verbosity=detailed;LogFileName=TEST-{assembly}.xml;FailureBodyFormat=Verbose" --logger "console;verbosity=detailed"
dotnet test "${file}" -c ${CONFIGURATION} --no-build ${FILTER_PARAMETER} ${FRAMEWORK_PARAMETER} --results-directory ./build/test-results --logger "junit;verbosity=detailed;LogFileName=TEST-{assembly}.xml;FailureBodyFormat=Verbose" --logger "console;verbosity=detailed"
done
7 changes: 4 additions & 3 deletions evergreen/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
#!/usr/bin/env bash
set -o errexit # Exit the script with error if any of the commands fail

FRAMEWORK=${FRAMEWORK:-net6.0}
CONFIGURATION=${CONFIGURATION:-'Release'}

./evergreen/compile-sources.sh
TEST_CATEGORY="!Integration" ./evergreen/execute-tests.sh
CONFIGURATION=${CONFIGURATION} ./evergreen/compile-sources.sh
CONFIGURATION=${CONFIGURATION} TEST_CATEGORY="!Integration" ./evergreen/execute-tests.sh
5 changes: 5 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<CodeAnalysisRuleSet>..\..\MongoDB.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release_CSharp_14' ">
<!--Do not update LangVersion to 14 in Driver-->
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize>
</PropertyGroup>

<PropertyGroup>
<Company>MongoDB Inc.</Company>
<Copyright>Copyright © 2010-present MongoDB Inc.</Copyright>
Expand Down
18 changes: 16 additions & 2 deletions tests/BuildProps/Tests.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
</PropertyGroup>

<PropertyGroup>
<Configurations>Debug;Release;Release_CSharp_14</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release_CSharp_14' ">
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize>
<DefineConstants>$(DefineConstants);CSHARP_14</DefineConstants>
<LangVersion>14</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' != 'Release_CSharp_14' ">
<LangVersion>12</LangVersion>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0;net10.0</TargetFrameworks>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">$(TargetFrameworks);net472</TargetFrameworks>
Expand All @@ -14,7 +29,6 @@
</PropertyGroup>

<PropertyGroup>
<LangVersion>12</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand All @@ -28,7 +42,7 @@
</PropertyGroup>

<PropertyGroup>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)'=='true'">
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
Expand Down
46 changes: 26 additions & 20 deletions tests/MongoDB.Bson.TestHelpers/Reflector.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* Copyright 2018-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.
*/
/* 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.
*/

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -40,13 +40,19 @@ public static object GetStaticFieldValue(Type type, string name, BindingFlags fl
return fieldInfo.GetValue(null);
}

public static TFieldType GetStaticFieldValue<TObjectType, TFieldType>(string name, BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Static)
{
var fieldInfo = GetDeclaredOrInheritedField(typeof(TObjectType), name, flags);
return (TFieldType)fieldInfo.GetValue(null);
}

public static object Invoke(object obj, string name, BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance)
{
try
{
var methodInfo = obj.GetType().GetMethods(flags)
.Where(m => m.Name == name && m.GetParameters().Length == 0)
.Single();
var methodInfo = obj.GetType()
.GetMethods(flags)
.Single(m => m.Name == name && m.GetParameters().Length == 0);
return methodInfo.Invoke(obj, new object[] { });
}
catch (TargetInvocationException exception)
Expand All @@ -58,9 +64,9 @@ public static object Invoke(object obj, string name, BindingFlags flags = Bindin
public static object Invoke<T1>(object obj, string name, T1 arg1)
{
var parameterTypes = new[] { typeof(T1) };
var methodInfo = obj.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
.Where(m => m.Name == name && m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes))
.Single();
var methodInfo = obj.GetType()
.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
.Single(m => m.Name == name && m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes));
try
{
return methodInfo.Invoke(obj, new object[] { arg1 });
Expand Down
Loading