Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martinez <joelmartinez@gmail.com>2018-10-10 21:45:22 +0300
committerJoel Martinez <joelmartinez@gmail.com>2018-10-10 21:57:45 +0300
commit5d1f8a2044f0fd15946ceb05f1a5d850e83822b7 (patch)
treeaa30df9d18a9a758673dd5953392de94bd16209b /mdoc/Mono.Documentation/Updater/DocUtils.cs
parente2cff76aa6c9ab74d606dc4ad5327b306b2e5807 (diff)
all interfaces are now listed.
Closes #334
Diffstat (limited to 'mdoc/Mono.Documentation/Updater/DocUtils.cs')
-rw-r--r--mdoc/Mono.Documentation/Updater/DocUtils.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/mdoc/Mono.Documentation/Updater/DocUtils.cs b/mdoc/Mono.Documentation/Updater/DocUtils.cs
index 869b9609..e5609e05 100644
--- a/mdoc/Mono.Documentation/Updater/DocUtils.cs
+++ b/mdoc/Mono.Documentation/Updater/DocUtils.cs
@@ -285,6 +285,44 @@ namespace Mono.Documentation.Updater
return inst != null
? inst.GenericArguments.Count
: type.GenericParameters.Count;
+ }
+
+ class TypeEquality : IEqualityComparer<TypeReference>
+ {
+ bool IEqualityComparer<TypeReference>.Equals (TypeReference x, TypeReference y)
+ {
+ if (x is null && y is null) return true;
+ if (x is null || y is null) return false;
+ return x.FullName == y.FullName;
+ }
+
+ int IEqualityComparer<TypeReference>.GetHashCode (TypeReference obj)
+ {
+ return obj.GetHashCode ();
+ }
+ }
+ static TypeEquality typeEqualityComparer = new TypeEquality ();
+
+ public static IEnumerable<TypeReference> GetAllPublicInterfaces (TypeDefinition type)
+ {
+ return GetAllInterfacesFromType (type)
+ .Where (i => IsPublic (i.Resolve ()))
+ .Distinct (typeEqualityComparer);
+ }
+
+ private static IEnumerable<TypeReference> GetAllInterfacesFromType(TypeDefinition type)
+ {
+ if (type is null)
+ yield break;
+
+ foreach(var i in type.Interfaces)
+ {
+ yield return i.InterfaceType;
+ foreach(var ii in GetAllInterfacesFromType(i.InterfaceType.Resolve()))
+ {
+ yield return ii;
+ }
+ }
}
public static IEnumerable<TypeReference> GetUserImplementedInterfaces (TypeDefinition type)