From 8822f7729c04ba22acbe9a9f1141d181ed725b6a Mon Sep 17 00:00:00 2001 From: Joel Martinez Date: Thu, 28 Sep 2017 16:20:38 -0400 Subject: mdoc: reformatting the MDocUpdater source code. We are changing our coding standards, and starting with the update subcommand. This moves many classes into their own code files and namespaces to better organize the source code. --- .../Updater/Frameworks/FrameworkTypeEntry.cs | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs (limited to 'mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs') diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs new file mode 100644 index 00000000..67bcee86 --- /dev/null +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using Mono.Cecil; +using Mono.Cecil.Rocks; + +namespace Mono.Documentation.Updater.Frameworks +{ + class FrameworkTypeEntry : IComparable + { + SortedSet members = new SortedSet (); + SortedSet memberscsharpsig = new SortedSet (); + + ILFullMemberFormatter formatter = new ILFullMemberFormatter (); + + FrameworkEntry fx; + + public static FrameworkTypeEntry Empty = new EmptyTypeEntry (FrameworkEntry.Empty) { Name = "Empty" }; + + public FrameworkTypeEntry (FrameworkEntry fx) + { + this.fx = fx; + } + + public string Id { get; set; } + public string Name { get; set; } + public string Namespace { get; set; } + public FrameworkEntry Framework { get { return fx; } } + + public ISet Members { + get { + return this.members; + } + } + + public virtual void ProcessMember (MemberReference member) + { + var resolvedMember = member.Resolve (); + if (resolvedMember != null) { + var docid = DocCommentId.GetDocCommentId (resolvedMember); + members.Add (docid); + } + else + members.Add (member.FullName); + + // this is for lookup purposes + try { + memberscsharpsig.Add(formatter.GetDeclaration(member)); + } + catch {} + } + + public bool ContainsCSharpSig (string sig) + { + return memberscsharpsig.Contains (sig); + } + + public override string ToString () => $"{this.Name} in {this.fx.Name}"; + + public int CompareTo (FrameworkTypeEntry other) + { + if (other == null) return -1; + if (this.Name == null) return 1; + + return string.Compare (this.Name, other.Name, StringComparison.CurrentCulture); + } + + public override bool Equals (object obj) + { + FrameworkTypeEntry other = obj as FrameworkTypeEntry; + if (other == null) return false; + return this.Name.Equals (other.Name); + } + + class EmptyTypeEntry : FrameworkTypeEntry + { + public EmptyTypeEntry (FrameworkEntry fx) : base (fx) { } + public override void ProcessMember (MemberReference member) { } + } + } +} -- cgit v1.2.3