diff --git a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs index a0a59c3560..0f02617087 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs @@ -92,7 +92,7 @@ namespace ICSharpCode.NRefactory.TypeSystem } #endregion - #region IsOpen / IsUnbound + #region IsOpen / IsUnbound / IsKnownType sealed class TypeClassificationVisitor : TypeVisitor { internal bool isOpen; @@ -140,6 +140,16 @@ namespace ICSharpCode.NRefactory.TypeSystem throw new ArgumentNullException("type"); return type is ITypeDefinition && type.TypeParameterCount > 0; } + + /// + /// Gets whether the type is the specified known type. + /// For generic known types, this returns true any parameterization of the type (and also for the definition itself). + /// + public static bool IsKnownType(this IType type, KnownTypeCode knownType) + { + var def = type.GetDefinition(); + return def != null && def.KnownTypeCode == knownType; + } #endregion #region Import