diff --git a/Allure.Net.Commons.Tests/FunctionTests/IdTests.cs b/Allure.Net.Commons.Tests/FunctionTests/IdTests.cs index d648ca12..0a66fc21 100644 --- a/Allure.Net.Commons.Tests/FunctionTests/IdTests.cs +++ b/Allure.Net.Commons.Tests/FunctionTests/IdTests.cs @@ -157,7 +157,7 @@ public void TestFullNameFromMethodOfNestedGenericClass() public void TestFullNameFromConstructedGenericMethodOfNestedConstructedGenericClass() { var method = typeof(MyClass).GetMethod( - nameof(MyClass.GenericMethodOfGenericClass), + nameof(MyClass.GenericMethodOfGenericClass), BindingFlags.Instance | BindingFlags.NonPublic ).MakeGenericMethod(typeof(MyClass)); @@ -166,11 +166,9 @@ public void TestFullNameFromConstructedGenericMethodOfNestedConstructedGenericCl Assert.That(actualFullName, Is.EqualTo( "Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass`1[" + "Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass]" + - ".GenericMethodOfGenericClass[" + - "Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass" + - "](" + + ".GenericMethodOfGenericClass[V](" + "System.Collections.Generic.List`1[Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass]," + - "System.Collections.Generic.List`1[Allure.Net.Commons.Tests:Allure.Net.Commons.Tests.FunctionTests.IdTests+MyClass]" + + "System.Collections.Generic.List`1[V]" + ")" )); } diff --git a/Allure.Net.Commons/Functions/IdFunctions.cs b/Allure.Net.Commons/Functions/IdFunctions.cs index 7290fdb0..aed70834 100644 --- a/Allure.Net.Commons/Functions/IdFunctions.cs +++ b/Allure.Net.Commons/Functions/IdFunctions.cs @@ -32,24 +32,29 @@ public static string CreateFullName(Type targetClass) => /// /// Creates a string that unuquely identifies a given method. /// + /// + /// A method. + /// If it's a constructed generic method, its generic definition is used instead. + /// /// /// For a given test method the full name includes: /// - /// - /// fully-qualified name of the declaring type (including type parameters) - /// - /// name of the method - /// generic parameters of the method - /// - /// fully-qualified names of the parameter types, (including parameter - /// modifiers, if any) - /// + /// assembly name + /// namespace (if any) + /// name of type (including its declaring types, if any) + /// type parameters of the declaring type (for generic type definitions) + /// type arguments of the declaring type (for constructed generic types) + /// type parameters of the method (if any) + /// parameter types /// - /// A fully-qualified name of a type includes the assembly name, the - /// namespace and the class name (can be a nested class). /// - public static string CreateFullName(MethodBase method) + public static string CreateFullName(MethodInfo method) { + if (method.IsGenericMethod && !method.IsGenericMethodDefinition) + { + method = method.GetGenericMethodDefinition(); + } + var className = SerializeType(method.DeclaringType); var methodName = method.Name; var typeParameters = method.GetGenericArguments();