diff --git a/CHANGELOG.md b/CHANGELOG.md index c64259b44..1408b2c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,11 @@ * Enhance BoDi error handling to provide the name of the interface being registered when that interface has already been resolved (#324) * Improve code-behind feature file compilation speed (#336) +* Improve parameter type naming for generic types (#343) ## Bug fixes: -*Contributors of this release (in alphabetical order):* @clrudolphi, @obligaron +*Contributors of this release (in alphabetical order):* @clrudolphi, @obligaron, @olegKoshmeliuk # v2.2.1 - 2024-11-08 diff --git a/Reqnroll/Bindings/Reflection/RuntimeBindingType.cs b/Reqnroll/Bindings/Reflection/RuntimeBindingType.cs index 7d99c8467..ecccc9ef3 100644 --- a/Reqnroll/Bindings/Reflection/RuntimeBindingType.cs +++ b/Reqnroll/Bindings/Reflection/RuntimeBindingType.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace Reqnroll.Bindings.Reflection { @@ -8,13 +9,30 @@ public class RuntimeBindingType : IPolymorphicBindingType public string Name => Type.Name; - public string FullName => Type.FullName; - + public string FullName { get;} + public string AssemblyName => Type.Assembly.GetName().Name; public RuntimeBindingType(Type type) { Type = type; + FullName = GetFullName(type); + } + + private static string GetFullName(Type type) + { + if (!type.IsConstructedGenericType) + { + return type.FullName; + } + + if (type.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return type.GenericTypeArguments[0].FullName + "?"; + } + + var genericParams = string.Join(",", type.GenericTypeArguments.Select(x => x.Name)); + return $"{type.Namespace}.{type.Name.Split('`')[0]}<{genericParams}>"; } public bool IsAssignableTo(IBindingType baseType)