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
8 changes: 3 additions & 5 deletions Allure.Net.Commons.Tests/FunctionTests/IdTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void TestFullNameFromMethodOfNestedGenericClass()
public void TestFullNameFromConstructedGenericMethodOfNestedConstructedGenericClass()
{
var method = typeof(MyClass<MyClass>).GetMethod(
nameof(MyClass<int>.GenericMethodOfGenericClass),
nameof(MyClass<MyClass>.GenericMethodOfGenericClass),
BindingFlags.Instance | BindingFlags.NonPublic
).MakeGenericMethod(typeof(MyClass));

Expand All @@ -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]" +
")"
));
}
Expand Down
29 changes: 17 additions & 12 deletions Allure.Net.Commons/Functions/IdFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,29 @@ public static string CreateFullName(Type targetClass) =>
/// <summary>
/// Creates a string that unuquely identifies a given method.
/// </summary>
/// <param name="method">
/// A method.
/// If it's a constructed generic method, its generic definition is used instead.
/// </param>
/// <remarks>
/// For a given test method the full name includes:
/// <list type="bullet">
/// <item>
/// fully-qualified name of the declaring type (including type parameters)
/// </item>
/// <item>name of the method</item>
/// <item>generic parameters of the method</item>
/// <item>
/// fully-qualified names of the parameter types, (including parameter
/// modifiers, if any)
/// </item>
/// <item>assembly name</item>
/// <item>namespace (if any)</item>
/// <item>name of type (including its declaring types, if any)</item>
/// <item>type parameters of the declaring type (for generic type definitions)</item>
/// <item>type arguments of the declaring type (for constructed generic types)</item>
/// <item>type parameters of the method (if any)</item>
/// <item>parameter types</item>
/// </list>
/// A fully-qualified name of a type includes the assembly name, the
/// namespace and the class name (can be a nested class).
/// </remarks>
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();
Expand Down
Loading