From 74e78184739ce413c82c932ffd4198dda8535c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Thu, 7 Feb 2013 12:50:38 +0100 Subject: [PATCH] Added TypeParameters property to IType (for consistency with the IMethod interface & makes usage easier). --- ICSharpCode.NRefactory/TypeSystem/IType.cs | 6 ++++++ .../Implementation/AbstractResolvedTypeParameter.cs | 5 +++++ .../TypeSystem/Implementation/AbstractType.cs | 5 +++++ ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs | 6 +++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.NRefactory/TypeSystem/IType.cs b/ICSharpCode.NRefactory/TypeSystem/IType.cs index d611d0c065..e13ebb7113 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IType.cs @@ -82,6 +82,12 @@ namespace ICSharpCode.NRefactory.TypeSystem /// int TypeParameterCount { get; } + /// + /// If the type has type parameters it's the same as GetDefinition ().TypeParameters otherwise it returns an empty list. + /// NOTE: The type will change to IReadOnlyList in future versions. + /// + IList TypeParameters { get; } + /// /// Gets the type arguments passed to this type. /// If only the type parameters for the class were specified and the generic type diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs index 6afa854d0c..77662a5422 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs @@ -207,6 +207,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return 0; } } + readonly static IList emptyTypeParameters = new ITypeParameter[0]; + IList IType.TypeParameters { + get { return emptyTypeParameters; } + } + readonly static IList emptyTypeArguments = new IType[0]; IList IType.TypeArguments { get { return emptyTypeArguments; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs index 3d68ee62d0..8e42020ea8 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs @@ -59,6 +59,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return 0; } } + readonly static IList emptyTypeParameters = new ITypeParameter[0]; + public virtual IList TypeParameters { + get { return emptyTypeParameters; } + } + readonly static IList emptyTypeArguments = new IType[0]; IList IType.TypeArguments { get { return emptyTypeArguments; } diff --git a/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs b/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs index 658f715e0c..f53a68dcc5 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs @@ -103,7 +103,11 @@ namespace ICSharpCode.NRefactory.TypeSystem public int TypeParameterCount { get { return typeArguments.Length; } } - + + public IList TypeParameters { + get { return genericType.TypeParameters; } + } + public string FullName { get { return genericType.FullName; } }