From 2bd889a088339980c1d47df1f37da284d5cfa944 Mon Sep 17 00:00:00 2001 From: Joel Martinez Date: Thu, 28 Jun 2018 14:59:16 -0400 Subject: [PATCH 1/2] Attributes now get a FrameworkAlternate when they don't appear in all frameworks. Resolves #76 --- mdoc/Mono.Documentation/MDocUpdater.cs | 195 +++++++--- .../Updater/Frameworks/AssemblySet.cs | 19 +- .../Updater/Frameworks/FXUtils.cs | 78 +++- .../Updater/Frameworks/FrameworkEntry.cs | 52 ++- .../Updater/Frameworks/FrameworkIndex.cs | 20 +- .../Updater/Frameworks/FrameworkTypeEntry.cs | 2 +- mdoc/Test/DocTest-frameworkalternate.cs | 6 + mdoc/Test/en.expected-cppcli/index.xml | 8 +- mdoc/Test/en.expected-cppcx/index.xml | 8 +- mdoc/Test/en.expected-cppwinrt/index.xml | 8 +- mdoc/Test/en.expected-docid/index.xml | 8 +- .../FrameworksIndex/One.xml | 6 + .../FrameworksIndex/Three.xml | 6 + .../FrameworksIndex/Two.xml | 6 + .../Monodoc.Test/FirstAttribute.xml | 40 ++ .../Monodoc.Test/MyClass.xml | 5 + .../Monodoc.Test/SecondAttribute.xml | 40 ++ .../index.xml | 10 +- .../FrameworksIndex/One.xml | 6 + .../FrameworksIndex/Three.xml | 6 + .../FrameworksIndex/Two.xml | 6 + .../Monodoc.Test/FirstAttribute.xml | 40 ++ .../Monodoc.Test/MyClass.xml | 8 + .../Monodoc.Test/SecondAttribute.xml | 40 ++ .../en.expected-frameworkalternate/index.xml | 10 +- .../index.xml | 8 +- mdoc/Test/en.expected-frameworks/index.xml | 8 +- .../Mono.DocTest.Generic/Func`2.xml | 10 +- .../Mono.DocTest.Generic/GenericBase`1.xml | 2 +- .../Mono.DocTest.Generic/MyList`1.xml | 2 +- .../Mono.DocTest/DocAttribute.xml | 2 +- .../Mono.DocTest/Widget+Direction.xml | 2 +- .../Mono.DocTest/Widget.xml | 32 +- mdoc/Test/en.expected-fx-import/index.xml | 12 +- mdoc/Test/en.expected-vbnet/index.xml | 8 +- .../index.xml | 8 +- mdoc/mdoc.Test/FrameworkAlternateTests.cs | 78 ++++ mdoc/mdoc.Test/XmlUpdateTests.cs | 341 +++++++++++++++++- mdoc/mdoc.csproj | 2 +- 39 files changed, 999 insertions(+), 149 deletions(-) create mode 100644 mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/FirstAttribute.xml create mode 100644 mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/SecondAttribute.xml create mode 100644 mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/FirstAttribute.xml create mode 100644 mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/SecondAttribute.xml diff --git a/mdoc/Mono.Documentation/MDocUpdater.cs b/mdoc/Mono.Documentation/MDocUpdater.cs index f2ef9cfd7..dbc84383b 100644 --- a/mdoc/Mono.Documentation/MDocUpdater.cs +++ b/mdoc/Mono.Documentation/MDocUpdater.cs @@ -250,6 +250,8 @@ public override void Run (IEnumerable args) "[OPTIONS]+ ASSEMBLIES", "Create or update documentation from ASSEMBLIES."); + int fxCount = 1; + if (!string.IsNullOrWhiteSpace (FrameworksPath)) { var configPath = FrameworksPath; @@ -277,8 +279,9 @@ public override void Run (IEnumerable args) Id = f.Elements("package") ?.FirstOrDefault()?.Attribute("Id")?.Value }) - .Where (f => Directory.Exists (f.Path)); - + .Where (f => Directory.Exists (f.Path)) + .ToArray(); + fxCount = fxd.Count (); oldFrameworkXmls = fxconfig.Root .Elements("Framework") .Select(f => new @@ -312,7 +315,7 @@ public override void Run (IEnumerable args) // Create a cache of all frameworks, so we can look up // members that may exist only other frameworks before deleting them Console.Write ("Creating frameworks cache: "); - FrameworkIndex cacheIndex = new FrameworkIndex (FrameworksPath); + FrameworkIndex cacheIndex = new FrameworkIndex (FrameworksPath, fxCount); foreach (var assemblySet in this.assemblies) { using (assemblySet) @@ -320,7 +323,8 @@ public override void Run (IEnumerable args) Console.Write ("."); foreach (var assembly in assemblySet.Assemblies) { - var a = cacheIndex.StartProcessingAssembly (assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); + var a = cacheIndex.StartProcessingAssembly (assemblySet, assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); + foreach (var type in assembly.GetTypes ()) { var t = a.ProcessType (type); @@ -371,7 +375,7 @@ public override void Run (IEnumerable args) docEnum = docEnum ?? new DocumentationEnumerator (); // PERFORM THE UPDATES - frameworks = new FrameworkIndex (FrameworksPath); + frameworks = new FrameworkIndex (FrameworksPath, fxCount); if (types.Count > 0) { @@ -672,13 +676,14 @@ public void DoUpdateTypes (string basepath, List typenames, string dest) var namespacesSet = new HashSet(); memberSet = new HashSet(); - var frameworkEntry = frameworks.StartProcessingAssembly(assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); + var frameworkEntry = frameworks.StartProcessingAssembly(assemblySet, assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); + assemblySet.Framework = frameworkEntry; foreach (TypeDefinition type in docEnum.GetDocumentationTypes(assembly, typenames)) { var typeEntry = frameworkEntry.ProcessType(type); - string relpath = DoUpdateType(type, typeEntry, basepath, dest); + string relpath = DoUpdateType(assemblySet, type, typeEntry, basepath, dest); if (relpath == null) continue; @@ -687,7 +692,7 @@ public void DoUpdateTypes (string basepath, List typenames, string dest) if (index == null) continue; - index.Add(assembly); + index.Add(assemblySet, assembly); index.Add(type); namespacesSet.Add(type.Namespace); @@ -734,12 +739,12 @@ public IndexForTypes (MDocUpdater app, string indexFile, XmlDocument index) index_assemblies = WriteElement (index.DocumentElement, "Assemblies"); } - public void Add (AssemblyDefinition assembly) + public void Add (AssemblySet set, AssemblyDefinition assembly) { if (index_assemblies.SelectSingleNode ("Assembly[@Name='" + assembly.Name.Name + "']") != null) return; - app.AddIndexAssembly (assembly, index_assemblies); + app.AddIndexAssembly (assembly, index_assemblies, set.Framework); } public void Add (TypeDefinition type) @@ -777,12 +782,12 @@ bool TryFindTypeFile (string nsname, string typename, string basepath, out Tuple return file.Exists; } - public string DoUpdateType (TypeDefinition type, FrameworkTypeEntry typeEntry, string basepath, string dest) + public string DoUpdateType (AssemblySet set, TypeDefinition type, FrameworkTypeEntry typeEntry, string basepath, string dest) { if (type.Namespace == null) Warning ("warning: The type `{0}' is in the root namespace. This may cause problems with display within monodoc.", type.FullName); - if (!IsPublic (type)) + if (!DocUtils.IsPublic (type)) return null; if (type.HasCustomAttributes && CustomAttributeNamesToSkip.All(x => type.CustomAttributes.Any(y => y.AttributeType.FullName == x))) @@ -874,7 +879,7 @@ public string DoUpdateType (TypeDefinition type, FrameworkTypeEntry typeEntry, s else { // Stub - XmlElement td = StubType (type, output, typeEntry.Framework.Importers, typeEntry.Framework.Id, typeEntry.Framework.Version); + XmlElement td = StubType (set, type, output, typeEntry.Framework.Importers, typeEntry.Framework.Id, typeEntry.Framework.Version); if (td == null) return null; } @@ -923,7 +928,7 @@ public static string GetTypeFileName (string typename) return filename.ToString (); } - private void AddIndexAssembly (AssemblyDefinition assembly, XmlElement parent) + private void AddIndexAssembly (AssemblyDefinition assembly, XmlElement parent, FrameworkEntry fx) { XmlElement index_assembly = null; if (IsMultiAssembly) @@ -955,7 +960,7 @@ private void AddIndexAssembly (AssemblyDefinition assembly, XmlElement parent) index_assembly.AppendChild (culture); } - MakeAttributes (index_assembly, GetCustomAttributes (assembly.CustomAttributes, "")); + MakeAttributes (index_assembly, GetCustomAttributes (assembly.CustomAttributes, ""), fx); parent.AppendChild (index_assembly); } @@ -1023,8 +1028,9 @@ private void DoUpdateAssemblies (string source, string dest) { using (assm) { - AddIndexAssembly(assm, index_assemblies); DoUpdateAssembly(assemblySet, assm, index_types, source, dest, goodfiles); + AddIndexAssembly (assm, index_assemblies, assemblySet.Framework); + processedAssemblyCount++; } } @@ -1060,7 +1066,7 @@ private void DoUpdateAssembly (AssemblySet assemblySet, AssemblyDefinition assem var typeSet = new HashSet (); memberSet = new HashSet (); - var frameworkEntry = frameworks.StartProcessingAssembly (assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); + var frameworkEntry = frameworks.StartProcessingAssembly (assemblySet, assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); foreach (TypeDefinition type in docEnum.GetDocumentationTypes (assembly, null)) { string typename = GetTypeFileName (type); @@ -1069,7 +1075,7 @@ private void DoUpdateAssembly (AssemblySet assemblySet, AssemblyDefinition assem var typeEntry = frameworkEntry.ProcessType (type); - string reltypepath = DoUpdateType (type, typeEntry, source, dest); + string reltypepath = DoUpdateType (assemblySet, type, typeEntry, source, dest); if (reltypepath == null) continue; @@ -1889,7 +1895,7 @@ private static bool MemberDocsHaveUserContent (XmlNode e) // CREATE A STUB DOCUMENTATION FILE - public XmlElement StubType (TypeDefinition type, string output, IEnumerable importers, string Id, string Version) + public XmlElement StubType (AssemblySet set, TypeDefinition type, string output, IEnumerable importers, string Id, string Version) { string typesig = typeFormatters[0].GetDeclaration (type); if (typesig == null) return null; // not publicly visible @@ -1898,7 +1904,7 @@ public XmlElement StubType (TypeDefinition type, string output, IEnumerable FilterSpecialCharsCore (string value) } } - private void MakeAttributes (XmlElement root, IEnumerable attributes, TypeReference t = null) + public static void MakeAttributes (XmlElement root, IEnumerable attributes, FrameworkEntry fx) { - if (!attributes.Any ()) - { - ClearElement (root, "Attributes"); - return; - } - XmlElement e = (XmlElement)root.SelectSingleNode ("Attributes"); - if (e != null) - e.RemoveAll (); - else if (e == null) + bool isLastFx = fx != null && fx.IsLastFramework; + bool noAttributes = attributes.Any (); + bool currentlyHasAttributes = e != null && e.ChildNodes.Count > 0; + + + if (e == null) e = root.OwnerDocument.CreateElement ("Attributes"); + + var attributesCurrent = attributes + .Select (FilterSpecialChars) + .Distinct () // make sure there aren't any dupes + .ToDictionary (a => a, a => false); // key is the attribute, value is whether it was found + + var attributesState = e.ChildNodes.Cast () + .Select (elem => new + { + ExistingValue = elem.FirstChild.InnerText, + XElement = elem, + }).ToArray(); - foreach (string attribute in attributes) + // iterate this framework's attributes and compare against the state + foreach(var currentAttribute in attributesCurrent) { - XmlElement ae = root.OwnerDocument.CreateElement ("Attribute"); - e.AppendChild (ae); - var value = new String (FilterSpecialChars (attribute).ToArray ()); - WriteElementText (ae, "AttributeName", value); + var alreadyExists = attributesState.FirstOrDefault (state => state.ExistingValue == currentAttribute.Key); + if (alreadyExists != null) + { + // TODO: add to unconditionally + // if FXA, add fx.name + if (fx.FrameworksCount > 1)// && alreadyExists.XElement.HasAttribute(Consts.FrameworkAlternate)) + { + var newfxlist = FXUtils.AddFXToList (alreadyExists.XElement.GetAttribute (Consts.FrameworkAlternate), fx.Name); + alreadyExists.XElement.SetAttribute (Consts.FrameworkAlternate, newfxlist); + } + continue; + } + else // let's create it + { + XmlElement ae = root.OwnerDocument.CreateElement ("Attribute"); + e.AppendChild (ae); + WriteElementText (ae, "AttributeName", currentAttribute.Key); + + if (fx.FrameworksCount > 1) + { + ae.SetAttribute (Consts.FrameworkAlternate, fx.Name); + } + } } - if (e.ParentNode == null) + // iterate the state's attributes to find attributes that aren't + // a part of this framework's attributes. + foreach(var stateAttribute in attributesState) + { + if (attributesCurrent.ContainsKey(stateAttribute.ExistingValue)) + { + continue; + } + else // let's remove it + { + if (fx.FrameworksCount > 1) + { + var newfxlist = FXUtils.RemoveFXFromList (stateAttribute.XElement.GetAttribute (Consts.FrameworkAlternate), fx.Name); + stateAttribute.XElement.SetAttribute (Consts.FrameworkAlternate, newfxlist); + + } + else + stateAttribute.XElement.ParentNode.RemoveChild (stateAttribute.XElement); + } + } + + // clean up + if (fx.IsLastFramework) { + foreach(var attr in e.ChildNodes.Cast ().ToArray()) { + if (attr.HasAttribute (Consts.FrameworkAlternate)) + { + var fxAttributeValue = attr.GetAttribute (Consts.FrameworkAlternate); + + if (string.IsNullOrWhiteSpace (fxAttributeValue)) + { + attr.ParentNode.RemoveChild (attr); + continue; + } + + if (fxAttributeValue.Equals(fx.AllFrameworksString, StringComparison.Ordinal)) + attr.RemoveAttribute (Consts.FrameworkAlternate); + + } + } + } + + if (e != null && e.ParentNode == null) root.AppendChild (e); + if (e.ChildNodes.Count == 0 && e.ParentNode != null) { + var parent = e.ParentNode as XmlElement; + parent.RemoveChild (e); + if (parent.ChildNodes.Count == 0) + parent.IsEmpty = true; + return; + } + NormalizeWhitespace (e); + + return; } public static string MakeAttributesValueString (object v, TypeReference valueType) @@ -3358,7 +3447,7 @@ public void MakeParameters (XmlElement root, MemberReference member, IList typeParams, MemberReference member, bool shouldDuplicateWithNew) + private void MakeTypeParameters (FrameworkTypeEntry entry, XmlElement root, IList typeParams, MemberReference member, bool shouldDuplicateWithNew) { if (typeParams == null || typeParams.Count == 0) { @@ -3526,7 +3615,7 @@ private void MakeTypeParameters (XmlElement root, IList typePa XmlElement pe = root.OwnerDocument.CreateElement ("TypeParameter"); e.AppendChild (pe); pe.SetAttribute ("Name", t.Name); - MakeAttributes (pe, GetCustomAttributes (t.CustomAttributes, ""), t.DeclaringType); + MakeAttributes (pe, GetCustomAttributes (t.CustomAttributes, ""), entry.Framework); XmlElement ce = (XmlElement)e.SelectSingleNode ("Constraints"); if (attrs == GenericParameterAttributes.NonVariant && constraints.Count == 0) { @@ -3600,7 +3689,7 @@ public static string GetDocParameterType (TypeReference type) return GetDocTypeFullName (type).Replace ("@", "&"); } - private void MakeReturnValue (XmlElement root, TypeReference type, IList attributes, bool shouldDuplicateWithNew = false) + private void MakeReturnValue (FrameworkTypeEntry typeEntry, XmlElement root, TypeReference type, IList attributes, bool shouldDuplicateWithNew = false) { XmlElement e = WriteElement (root, "ReturnValue"); var valueToUse = GetDocTypeFullName (type); @@ -3612,25 +3701,25 @@ private void MakeReturnValue (XmlElement root, TypeReference type, IList /// Represents a set of assemblies that we want to document /// - class AssemblySet : IDisposable + public class AssemblySet : IDisposable { static readonly BaseAssemblyResolver resolver = new Frameworks.MDocResolver (); static IAssemblyResolver cachedResolver; @@ -23,6 +23,23 @@ class AssemblySet : IDisposable IEnumerable importPaths; public IEnumerable Importers { get; private set; } + FrameworkEntry fx; + public FrameworkEntry Framework + { + get => fx; + set + { + fx = value; + fx.AddAssemblySet (this); + } + } + + /// This is meant only for unit test access + public IDictionary AssemblyMapsPath + { + get => assemblyPathsMap; + } + public AssemblySet (IEnumerable paths) : this ("Default", paths, new string[0]) { } public AssemblySet (string name, IEnumerable paths, IEnumerable resolverSearchPaths, IEnumerable imports = null, string version = null, string id = null) diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/FXUtils.cs b/mdoc/Mono.Documentation/Updater/Frameworks/FXUtils.cs index c009b1107..c9a57565a 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/FXUtils.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FXUtils.cs @@ -7,20 +7,36 @@ public static class FXUtils { public static string AddFXToList (string existingValue, string newFX) { + var cachedValue = GetCache (existingValue, newFX, CacheAction.Add); + if (!string.IsNullOrWhiteSpace (cachedValue)) + return cachedValue; + var splitValue = SplitList (existingValue); if (!splitValue.Contains (newFX)) splitValue.Add (newFX); - return JoinList (splitValue); + var returnVal = JoinList (splitValue); + + SetCache (existingValue, newFX, returnVal, CacheAction.Add); + + return returnVal; } public static string RemoveFXFromList (string existingValue, string FXToRemove) { + var cachedValue = GetCache (existingValue, FXToRemove, CacheAction.Remove); + if (!string.IsNullOrWhiteSpace (cachedValue)) + return cachedValue; + var splitValue = SplitList (existingValue); splitValue.Remove (FXToRemove); - return JoinList (splitValue); + var returnVal = JoinList (splitValue); + + SetCache (existingValue, FXToRemove, returnVal, CacheAction.Remove); + + return returnVal; } /// Returns a list of all previously processed frameworks (not including the current) - internal static string PreviouslyProcessedFXString (FrameworkTypeEntry typeEntry) + internal static string PreviouslyProcessedFXString (FrameworkTypeEntry typeEntry) { if (typeEntry == null) return string.Empty; @@ -31,7 +47,7 @@ internal static string PreviouslyProcessedFXString (FrameworkTypeEntry typeEntry .Where (n => !string.IsNullOrWhiteSpace (n)) .ToArray ()); } - + static List SplitList (string existingValue) { @@ -44,5 +60,59 @@ static string JoinList (List splitValue) { return string.Join (";", splitValue.ToArray ()); } + + #region Framework String Cache Stuff + + /// Cache for modified framework strings + static Dictionary, Dictionary>> map = new Dictionary, Dictionary>> (); + enum CacheAction { Add, Remove } + + static string GetCache (string currentValue, string value, CacheAction action) + { + ValueTuple, Dictionary> cacheKey; + if (map.TryGetValue (currentValue, out cacheKey)) + { + string cachedValue = string.Empty; + switch (action) + { + case CacheAction.Add: + cacheKey.Item1.TryGetValue (value, out cachedValue); + break; + case CacheAction.Remove: + cacheKey.Item2.TryGetValue (value, out cachedValue); + break; + } + return cachedValue; + } + return string.Empty; + } + static void SetCache (string currentValue, string value, string newValue, CacheAction action) + { + ValueTuple, Dictionary> outerCacheValue; + if (!map.TryGetValue (currentValue, out outerCacheValue)) + { + outerCacheValue = new ValueTuple, Dictionary> (new Dictionary (), new Dictionary ()); + map.Add (currentValue, outerCacheValue); + } + + Dictionary innerCacheContainer = null; + switch (action) + { + case CacheAction.Add: + innerCacheContainer = outerCacheValue.Item1; + break; + case CacheAction.Remove: + innerCacheContainer = outerCacheValue.Item2; + break; + } + + if (!innerCacheContainer.ContainsKey (value)) + { + innerCacheContainer.Add (value, newValue); + } + + } + + #endregion } } diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs index 5c98db27f..3f1223c22 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs @@ -11,21 +11,65 @@ public class FrameworkEntry SortedSet types = new SortedSet (); IList allframeworks; - public int index = 0; + ISet allAssemblies = new SortedSet (); - public FrameworkEntry (IList frameworks) + public int Index = 0; + int _fxCount; + public int FrameworksCount { + get => _fxCount < 1 ? allframeworks.Count : _fxCount; + } + + public FrameworkEntry (IList frameworks) : this(frameworks, -1) {} + + public FrameworkEntry (IList frameworks, int fxCount) { allframeworks = frameworks; if (allframeworks == null) allframeworks = new List (0); - index = allframeworks.Count; + Index = allframeworks.Count; + _fxCount = fxCount; } public string Name { get; set; } public string Version { get; set; } public string Id { get; set; } + /// Gets a value indicating whether this is last framework being processed. + public bool IsLastFramework { + get => Index == FrameworksCount - 1; + } + + string _allFxString = ""; + public string AllFrameworksString { + get + { + Lazy fxString = new Lazy(() => string.Join (";", allframeworks.Select (f => f.Name).ToArray ())); + + if (!this.IsLastFramework) return fxString.Value; + if (string.IsNullOrWhiteSpace(_allFxString)) + { + _allFxString = fxString.Value; + } + return _allFxString; + } + } + public IEnumerable PreviousFrameworks { + get => allframeworks.Where (f => f.Index < this.Index); + } + + public ISet AllProcessedAssemblies { get => allAssemblies; } + + public void AddAssemblySet (AssemblySet assemblySet) + { + allAssemblies.Add (assemblySet); + } + + /// Gets a value indicating whether this is first framework being processed. + public bool IsFirstFramework { + get => this.Index == 0; + } + /// Only Use in Unit Tests public string Replace=""; @@ -90,7 +134,7 @@ string Str(string value) { class EmptyFrameworkEntry : FrameworkEntry { - public EmptyFrameworkEntry () : base (null) { } + public EmptyFrameworkEntry () : base (null, 1) { } public override FrameworkTypeEntry ProcessType (TypeDefinition type) { return FrameworkTypeEntry.Empty; } } } diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs index 25ae158bb..0b68e7018 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs @@ -15,21 +15,29 @@ public class FrameworkIndex List frameworks = new List (); string path; - public FrameworkIndex (string pathToFrameworks) + public FrameworkIndex (string pathToFrameworks, int fxCount) { path = pathToFrameworks; + FrameworksCount = fxCount; } + public int FrameworksCount { + get; private set; + } + public IList Frameworks { get { return this.frameworks; } } - public FrameworkEntry StartProcessingAssembly (AssemblyDefinition assembly, IEnumerable importers, string Id, string Version) + public FrameworkEntry StartProcessingAssembly (AssemblySet set, AssemblyDefinition assembly, IEnumerable importers, string Id, string Version) { - if (string.IsNullOrWhiteSpace (this.path)) - return FrameworkEntry.Empty; + if (string.IsNullOrWhiteSpace (this.path)) + { + set.Framework = FrameworkEntry.Empty; + return FrameworkEntry.Empty; + } string assemblyPath = assembly.MainModule.FileName; var frameworksDirectory = this.path.EndsWith ("frameworks.xml", StringComparison.OrdinalIgnoreCase) @@ -42,9 +50,11 @@ public FrameworkEntry StartProcessingAssembly (AssemblyDefinition assembly, IEnu var entry = frameworks.FirstOrDefault (f => f.Name.Equals (shortPath)); if (entry == null) { - entry = new FrameworkEntry (frameworks) { Name = shortPath, Importers = importers, Id = Id, Version = Version}; + entry = new FrameworkEntry (frameworks, FrameworksCount) { Name = shortPath, Importers = importers, Id = Id, Version = Version}; frameworks.Add (entry); } + + set.Framework = entry; return entry; } diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs index a6886c8c4..f95dda87c 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs @@ -36,7 +36,7 @@ public FrameworkTypeEntry[] PreviouslyProcessedFrameworkTypes { { previouslyProcessedFXTypes = new Lazy ( () => this.Framework.Frameworks - .Where (f => f.index < this.Framework.index) + .Where (f => f.Index < this.Framework.Index) .Select (f => f.FindTypeEntry (this)) .ToArray () ); diff --git a/mdoc/Test/DocTest-frameworkalternate.cs b/mdoc/Test/DocTest-frameworkalternate.cs index 28a81f70e..092f8ca65 100644 --- a/mdoc/Test/DocTest-frameworkalternate.cs +++ b/mdoc/Test/DocTest-frameworkalternate.cs @@ -1,12 +1,18 @@ +using System; + namespace Monodoc.Test { + public class FirstAttribute : Attribute {} + public class SecondAttribute : Attribute {} public class MyClass { #if FXONE + [First] public void Meth(int a, string b, int c) {} #endif #if FXTWO + [First, Second] public void Meth(int a, string d, int c) {} #endif } diff --git a/mdoc/Test/en.expected-cppcli/index.xml b/mdoc/Test/en.expected-cppcli/index.xml index e4a6fd3b6..10294c790 100644 --- a/mdoc/Test/en.expected-cppcli/index.xml +++ b/mdoc/Test/en.expected-cppcli/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/en.expected-cppcx/index.xml b/mdoc/Test/en.expected-cppcx/index.xml index 6abf14028..3356d73ff 100644 --- a/mdoc/Test/en.expected-cppcx/index.xml +++ b/mdoc/Test/en.expected-cppcx/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/en.expected-cppwinrt/index.xml b/mdoc/Test/en.expected-cppwinrt/index.xml index 6abf14028..3356d73ff 100644 --- a/mdoc/Test/en.expected-cppwinrt/index.xml +++ b/mdoc/Test/en.expected-cppwinrt/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/en.expected-docid/index.xml b/mdoc/Test/en.expected-docid/index.xml index bd4b84cf5..7136dc4f6 100644 --- a/mdoc/Test/en.expected-docid/index.xml +++ b/mdoc/Test/en.expected-docid/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/One.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/One.xml index 8248544a3..a8c88e198 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/One.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/One.xml @@ -1,9 +1,15 @@  + + + + + + \ No newline at end of file diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Three.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Three.xml index 9bb0a0920..75f797af3 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Three.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Three.xml @@ -1,9 +1,15 @@  + + + + + + \ No newline at end of file diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Two.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Two.xml index 7ba7f611f..fc5ce8dde 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Two.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Two.xml @@ -1,9 +1,15 @@  + + + + + + \ No newline at end of file diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/FirstAttribute.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/FirstAttribute.xml new file mode 100644 index 000000000..85eac346a --- /dev/null +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/FirstAttribute.xml @@ -0,0 +1,40 @@ + + + + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + System.Attribute + + + + To be added. + To be added. + + + + + + Constructor + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + + To be added. + To be added. + + + + diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/MyClass.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/MyClass.xml index 8a01c986c..b7e6ee6df 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/MyClass.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/MyClass.xml @@ -48,6 +48,11 @@ DocTest-frameworkalternate-two 0.0.0.0 + + + Monodoc.Test.First + + System.Void diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/SecondAttribute.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/SecondAttribute.xml new file mode 100644 index 000000000..f797bfe4c --- /dev/null +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/SecondAttribute.xml @@ -0,0 +1,40 @@ + + + + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + System.Attribute + + + + To be added. + To be added. + + + + + + Constructor + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + + To be added. + To be added. + + + + diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml index 264c4b959..592ea1e73 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.DisableOptimizations | System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.DisableOptimizations | System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) @@ -25,7 +25,9 @@ To be added. + + Untitled diff --git a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml index 8248544a3..a8c88e198 100644 --- a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml +++ b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml @@ -1,9 +1,15 @@  + + + + + + \ No newline at end of file diff --git a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Three.xml b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Three.xml index 9bb0a0920..75f797af3 100644 --- a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Three.xml +++ b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Three.xml @@ -1,9 +1,15 @@  + + + + + + \ No newline at end of file diff --git a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Two.xml b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Two.xml index 7ba7f611f..fc5ce8dde 100644 --- a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Two.xml +++ b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Two.xml @@ -1,9 +1,15 @@  + + + + + + \ No newline at end of file diff --git a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/FirstAttribute.xml b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/FirstAttribute.xml new file mode 100644 index 000000000..85eac346a --- /dev/null +++ b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/FirstAttribute.xml @@ -0,0 +1,40 @@ + + + + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + System.Attribute + + + + To be added. + To be added. + + + + + + Constructor + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + + To be added. + To be added. + + + + diff --git a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml index a0559f3b2..4632b3fac 100644 --- a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml +++ b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml @@ -50,6 +50,14 @@ DocTest-frameworkalternate-two 0.0.0.0 + + + Monodoc.Test.First + + + Monodoc.Test.Second + + System.Void diff --git a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/SecondAttribute.xml b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/SecondAttribute.xml new file mode 100644 index 000000000..f797bfe4c --- /dev/null +++ b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/SecondAttribute.xml @@ -0,0 +1,40 @@ + + + + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + System.Attribute + + + + To be added. + To be added. + + + + + + Constructor + + DocTest-frameworkalternate-one + 0.0.0.0 + + + DocTest-frameworkalternate-two + 0.0.0.0 + + + + To be added. + To be added. + + + + diff --git a/mdoc/Test/en.expected-frameworkalternate/index.xml b/mdoc/Test/en.expected-frameworkalternate/index.xml index 264c4b959..592ea1e73 100644 --- a/mdoc/Test/en.expected-frameworkalternate/index.xml +++ b/mdoc/Test/en.expected-frameworkalternate/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.DisableOptimizations | System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.DisableOptimizations | System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) @@ -25,7 +25,9 @@ To be added. + + Untitled diff --git a/mdoc/Test/en.expected-frameworks-inheritance/index.xml b/mdoc/Test/en.expected-frameworks-inheritance/index.xml index 81ba359f8..892cfd2c4 100644 --- a/mdoc/Test/en.expected-frameworks-inheritance/index.xml +++ b/mdoc/Test/en.expected-frameworks-inheritance/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/en.expected-frameworks/index.xml b/mdoc/Test/en.expected-frameworks/index.xml index 6abf14028..3356d73ff 100644 --- a/mdoc/Test/en.expected-frameworks/index.xml +++ b/mdoc/Test/en.expected-frameworks/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/Func`2.xml b/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/Func`2.xml index 9e1695e23..711168aec 100644 --- a/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/Func`2.xml +++ b/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/Func`2.xml @@ -8,7 +8,7 @@ - + Mono.DocTest.Doc("arg!") @@ -19,7 +19,7 @@ - + Mono.DocTest.Doc("ret!") @@ -32,14 +32,14 @@ System.Delegate - + Mono.DocTest.Doc("method") - + Mono.DocTest.Doc("arg-actual") @@ -48,7 +48,7 @@ TRet - + Mono.DocTest.Doc("return", Field=false) diff --git a/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/GenericBase`1.xml b/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/GenericBase`1.xml index 44866384f..b21412985 100644 --- a/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/GenericBase`1.xml +++ b/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/GenericBase`1.xml @@ -47,7 +47,7 @@ - + Mono.DocTest.Doc("S") diff --git a/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/MyList`1.xml b/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/MyList`1.xml index 72195508c..91f2c5ba2 100644 --- a/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/MyList`1.xml +++ b/mdoc/Test/en.expected-fx-import/Mono.DocTest.Generic/MyList`1.xml @@ -8,7 +8,7 @@ - + Mono.DocTest.Doc("Type Parameter!") diff --git a/mdoc/Test/en.expected-fx-import/Mono.DocTest/DocAttribute.xml b/mdoc/Test/en.expected-fx-import/Mono.DocTest/DocAttribute.xml index 3bbbb4e75..1684b7232 100644 --- a/mdoc/Test/en.expected-fx-import/Mono.DocTest/DocAttribute.xml +++ b/mdoc/Test/en.expected-fx-import/Mono.DocTest/DocAttribute.xml @@ -10,7 +10,7 @@ - + System.AttributeUsage(System.AttributeTargets.All) diff --git a/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget+Direction.xml b/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget+Direction.xml index b4ed214e6..4f1f608f8 100644 --- a/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget+Direction.xml +++ b/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget+Direction.xml @@ -9,7 +9,7 @@ System.Enum - + System.Flags diff --git a/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget.xml b/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget.xml index 22258eda8..5e2a2c898 100644 --- a/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget.xml +++ b/mdoc/Test/en.expected-fx-import/Mono.DocTest/Widget.xml @@ -97,13 +97,13 @@ 0.0.0.0 - + Mono.DocTest.Doc("Del event") - + add: Mono.DocTest.Doc("Del add accessor") - + remove: Mono.DocTest.Doc("Del remove accessor") @@ -344,7 +344,7 @@ 0.0.0.0 - + System.Obsolete("why not") @@ -422,7 +422,7 @@ 0.0.0.0 - + Mono.DocTest.Doc("Height property") @@ -445,10 +445,10 @@ 0.0.0.0 - + Mono.DocTest.Doc("Item property") - + set: Mono.DocTest.Doc("Item property set accessor") @@ -517,14 +517,14 @@ 0.0.0.0 - + Mono.DocTest.Doc("normal DocAttribute", Field=true) System.Void - + Mono.DocTest.Doc("return:DocAttribute", Property=typeof(Mono.DocTest.Widget)) @@ -532,21 +532,21 @@ - + Mono.DocTest.Doc("c", FlagsEnum=System.ConsoleModifiers.Alt | System.ConsoleModifiers.Control) - + Mono.DocTest.Doc("f", NonFlagsEnum=Mono.DocTest.Color.Red) - + Mono.DocTest.Doc("v") @@ -670,7 +670,7 @@ - + System.ParamArray @@ -910,13 +910,13 @@ 0.0.0.0 - + Mono.DocTest.Doc("Width property") - + get: Mono.DocTest.Doc("Width get accessor") - + set: Mono.DocTest.Doc("Width set accessor") diff --git a/mdoc/Test/en.expected-fx-import/index.xml b/mdoc/Test/en.expected-fx-import/index.xml index 3c247c33b..13747e7ff 100644 --- a/mdoc/Test/en.expected-fx-import/index.xml +++ b/mdoc/Test/en.expected-fx-import/index.xml @@ -2,30 +2,30 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/en.expected-vbnet/index.xml b/mdoc/Test/en.expected-vbnet/index.xml index b00fee0ae..0a3c4ef4f 100644 --- a/mdoc/Test/en.expected-vbnet/index.xml +++ b/mdoc/Test/en.expected-vbnet/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/Test/test-nuget-information/en.expected-frameworks-with-nuget-information/index.xml b/mdoc/Test/test-nuget-information/en.expected-frameworks-with-nuget-information/index.xml index 6abf14028..3356d73ff 100644 --- a/mdoc/Test/test-nuget-information/en.expected-frameworks-with-nuget-information/index.xml +++ b/mdoc/Test/test-nuget-information/en.expected-frameworks-with-nuget-information/index.xml @@ -2,20 +2,20 @@ - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) - + System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints) - + System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) diff --git a/mdoc/mdoc.Test/FrameworkAlternateTests.cs b/mdoc/mdoc.Test/FrameworkAlternateTests.cs index 1727106d6..86d551178 100644 --- a/mdoc/mdoc.Test/FrameworkAlternateTests.cs +++ b/mdoc/mdoc.Test/FrameworkAlternateTests.cs @@ -1,6 +1,7 @@ using Mono.Documentation.Updater.Frameworks; using NUnit.Framework; using System; +using System.Collections.Generic; using System.Linq; namespace mdoc.Test @@ -16,12 +17,89 @@ public void AddToEmptyList() Assert.AreEqual ("One", newValue); } + [Test ()] + public void AddToExistingList () + { + string newValue = FXUtils.AddFXToList ("One", "Two"); + + Assert.AreEqual ("One;Two", newValue); + } + + [Test ()] + public void AddDupeToExistingList () + { + string newValue = FXUtils.AddFXToList ("One", "One"); + + Assert.AreEqual ("One", newValue); + } + [Test ()] public void RemoveFromList() { string newValue = FXUtils.RemoveFXFromList ("One", "One"); Assert.AreEqual ("", newValue); + } + + + [Test ()] + public void RemoveFromMultiList () + { + string existingValue = "Pre;One;Post"; + string fxToRemove = "One"; + string postValue = "Pre;Post"; + + string newValue = FXUtils.RemoveFXFromList (existingValue, fxToRemove); + Assert.AreEqual (postValue, newValue); + + // make sure the cache returns the same value + newValue = FXUtils.RemoveFXFromList (existingValue, fxToRemove); + Assert.AreEqual (postValue, newValue); + } + + [Test ()] + public void AddToMultiList () + { + string existingValue = "Pre;Post"; + string fxToAdd = "One"; + string postValue = "Pre;Post;One"; + + string newValue = FXUtils.AddFXToList (existingValue, fxToAdd); + Assert.AreEqual (postValue, newValue); + + // make sure the cache returns the same value + newValue = FXUtils.AddFXToList (existingValue, fxToAdd); + Assert.AreEqual (postValue, newValue); + } + + [Test] + public void LastFramework() + { + List entries = new List(); + entries.Add (new FrameworkEntry (entries)); + entries.Add (new FrameworkEntry (entries)); + entries.Add (new FrameworkEntry (entries)); + entries.Add (new FrameworkEntry (entries)); + + Assert.IsFalse (entries[0].IsLastFramework); + Assert.IsFalse (entries[1].IsLastFramework); + Assert.IsFalse (entries[2].IsLastFramework); + Assert.IsTrue (entries[3].IsLastFramework); + } + + [Test] + public void FirstFramework () + { + List entries = new List (); + entries.Add (new FrameworkEntry (entries)); + entries.Add (new FrameworkEntry (entries)); + entries.Add (new FrameworkEntry (entries)); + entries.Add (new FrameworkEntry (entries)); + + Assert.IsTrue (entries[0].IsFirstFramework); + Assert.IsFalse (entries[1].IsFirstFramework); + Assert.IsFalse (entries[2].IsFirstFramework); + Assert.IsFalse (entries[3].IsFirstFramework); } } } diff --git a/mdoc/mdoc.Test/XmlUpdateTests.cs b/mdoc/mdoc.Test/XmlUpdateTests.cs index 4d4aba386..defc53d82 100644 --- a/mdoc/mdoc.Test/XmlUpdateTests.cs +++ b/mdoc/mdoc.Test/XmlUpdateTests.cs @@ -8,29 +8,45 @@ using Mono.Documentation.Updater.Frameworks; using Mono.Documentation.Updater; -namespace mdoc.Test2 +namespace mdoc.Test { + public class OneAttribute : Attribute { } + public class TwoAttribute : Attribute { } + + [One] public class MyClass { - public void Meth (int a, string b, int c) { } + [One] + public void Meth (int a, string d, int c) { } + } public class MyClass2 { - public void Meth (int d, string e, int f) { } + public void Meth (int a, string b, int c) { } } + } -namespace mdoc.Test + +namespace mdoc.Test2 { + using mdoc.Test; + + [One, Two] public class MyClass { - public void Meth(int a, string d, int c) {} - + [One, Two] + public void Meth (int a, string b, int c) { } } + + [Two] public class MyClass2 { - public void Meth (int a, string b, int c) { } + [Two] + public void Meth (int d, string e, int f) { } } - +} +namespace mdoc.Test +{ /// /// Tests functions that update the EcmaXMl under various conditions from /// corresponding classes. @@ -412,6 +428,309 @@ public void DocMemberEnumerator2 () Assert.IsTrue (matches.Any (m => m.Member == context.method && m.Node != null), "didn't match the member"); } + [Test] + public void Attributes_TypeOrMethod() + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + var fx = context.fx.Frameworks[1]; + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast().ToArray(); + + Assert.IsTrue (attributes.Count () == 1); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.AreEqual ("Three", attributes[0].GetAttribute (Consts.FrameworkAlternate)); + } + + [Test] + public void Attributes_TypeOrMethod_AllFX () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + foreach (var fx in context.fx.Frameworks) + { + //var fx = context.fx.Frameworks[1]; + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 1); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + } + + [Test] + public void Attributes_TypeOrMethod_AllFX_OneMissing () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + foreach (var fx in context.fx.Frameworks) + { + //var fx = context.fx.Frameworks[1]; + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + if (fx.IsFirstFramework) + attributeList = new string[0]; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 1); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsTrue (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("Three;Two", attributes[0].GetAttribute (Consts.FrameworkAlternate)); + } + + [Test] + public void Attributes_TypeOrMethod_AllFX_OneMissing_Last () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + foreach (var fx in context.fx.Frameworks) + { + //var fx = context.fx.Frameworks[1]; + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + if (fx.IsLastFramework) + attributeList = new string[0]; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 1); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsTrue (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("One;Three", attributes[0].GetAttribute (Consts.FrameworkAlternate)); + } + + [Test] + public void Attributes_TypeOrMethod_AllFX_RunExisting_Middle () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + // first, go through and add "One" and "Two" to all of them + foreach (var fx in context.fx.Frameworks) + { + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One", "Two" }; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + // Now, to test the first deployment on an existing set + // in this case, the truth of the matter is that `Two` only exists in the middle + foreach (var fx in context.fx.Frameworks) + { + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + if (!fx.IsFirstFramework && !fx.IsLastFramework) { + attributeList = new[] { "One", "Two" }; + } + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 2); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("Two", attributes[1].FirstChild.InnerText); + Assert.IsTrue (attributes[1].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("Three", attributes[1].GetAttribute (Consts.FrameworkAlternate)); + } + + [Test] + public void Attributes_TypeOrMethod_AllFX_RunExisting_First () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + // first, go through and add "One" and "Two" to all of them + foreach (var fx in context.fx.Frameworks) + { + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One", "Two" }; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + // Now, to test the first deployment on an existing set + // in this case, the truth of the matter is that `Two` only exists in the middle + foreach (var fx in context.fx.Frameworks) + { + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + if (fx.IsFirstFramework) + { + attributeList = new[] { "One", "Two" }; + } + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 2); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("Two", attributes[1].FirstChild.InnerText); + Assert.IsTrue (attributes[1].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("One", attributes[1].GetAttribute (Consts.FrameworkAlternate)); + } + + [Test] + public void Attributes_TypeOrMethod_AllFX_RunExisting_Last () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + // first, go through and add "One" and "Two" to all of them + foreach (var fx in context.fx.Frameworks) + { + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One", "Two" }; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + // Now, to test the first deployment on an existing set + // in this case, the truth of the matter is that `Two` only exists in the middle + foreach (var fx in context.fx.Frameworks) + { + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "Two" }; + + if (fx.IsLastFramework) + { + attributeList = new[] { "One", "Two" }; + } + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 2); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsTrue (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("Two", attributes[0].GetAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("Two", attributes[1].FirstChild.InnerText); + Assert.IsFalse (attributes[1].HasAttribute (Consts.FrameworkAlternate)); + + } + + [Test] + public void Attributes_TypeOrMethod_AllFX_OneMissing_Middle () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + foreach (var fx in context.fx.Frameworks) + { + //var fx = context.fx.Frameworks[1]; + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + if (!fx.IsLastFramework && !fx.IsFirstFramework) + attributeList = new string[0]; + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 1); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsTrue (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("One;Two", attributes[0].GetAttribute (Consts.FrameworkAlternate)); + } + + + [Test] + public void Attributes_Assembly () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + foreach (var fx in context.fx.Frameworks) + { + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + if (!fx.IsLastFramework && !fx.IsFirstFramework) + { + attributeList = new string[0]; + } + + + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + } + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 1); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsTrue (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + Assert.AreEqual ("One;Two", attributes[0].GetAttribute (Consts.FrameworkAlternate)); + } + + [Test] + public void Attributes_Assembly_OtherAssembly () + { + var context = InitContext (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); + + var fx = context.fx.Frameworks[1]; + + + FrameworkTypeEntry typeEntry = fx.Types.First (); + + string[] attributeList = new[] { "One" }; + + // this is the 'second' fx, and we've changed the expected assembly name, + // so the attribute, while it doesn't exist yet, shouldn't have an FX made since it doesn't exist in any other FX + MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx); + + + var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); + var attributes = attrNode.SelectNodes ("Attribute").Cast ().ToArray (); + + Assert.IsTrue (attributes.Count () == 1); + Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); + Assert.IsTrue (attributes[0].HasAttribute (Consts.FrameworkAlternate)); + } + string Normalize(string xml) { XmlDocument doc = new XmlDocument (); @@ -618,7 +937,7 @@ string Normalize(string xml) { // updater var updater = new MDocUpdater (); - var fx = new FrameworkIndex (""); + var fx = new FrameworkIndex ("", 3); fx.Frameworks.Add (new FrameworkEntry (fx.Frameworks) { Id = "One", Name = "One", Replace="mdoc.Test2", With="mdoc.Test" }); fx.Frameworks.Add (new FrameworkEntry (fx.Frameworks) { Id = "Three", Name = "Three", Replace = "mdoc.Test2", With = "mdoc.Test" }); fx.Frameworks.Add (new FrameworkEntry (fx.Frameworks) { Id = "Two", Name = "Two", Replace = "mdoc.Test2", With = "mdoc.Test" }); @@ -630,6 +949,10 @@ string Normalize(string xml) { { var t = f.ProcessType (type); t.ProcessMember (method); + + var aset = new AssemblySet (new[] { "one.dll" }); + f.AddAssemblySet (aset); + } else { var t = f.ProcessType (type2); diff --git a/mdoc/mdoc.csproj b/mdoc/mdoc.csproj index 6c6d229ee..454e1b3d9 100644 --- a/mdoc/mdoc.csproj +++ b/mdoc/mdoc.csproj @@ -9,7 +9,7 @@ Exe mdoc mdoc - v4.5 + v4.7.1 True From cb24522cb8fa793e8ddfb3907ec6a89b702730c4 Mon Sep 17 00:00:00 2001 From: Joel Martinez Date: Thu, 28 Jun 2018 15:00:20 -0400 Subject: [PATCH 2/2] bump to 5.7.1 --- mdoc/Consts.cs | 2 +- mdoc/mdoc.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mdoc/Consts.cs b/mdoc/Consts.cs index f9200f214..f06852ac7 100644 --- a/mdoc/Consts.cs +++ b/mdoc/Consts.cs @@ -3,7 +3,7 @@ namespace Mono.Documentation { public static class Consts { - public static string MonoVersion = "5.7.0.1"; + public static string MonoVersion = "5.7.1"; public const string DocId = "DocId"; public const string CppCli = "C++ CLI"; public const string CppCx = "C++ CX"; diff --git a/mdoc/mdoc.nuspec b/mdoc/mdoc.nuspec index 08b23b6cd..1f8c4c71c 100644 --- a/mdoc/mdoc.nuspec +++ b/mdoc/mdoc.nuspec @@ -2,7 +2,7 @@ mdoc - 5.7.0.1 + 5.7.1 mdoc Microsoft Microsoft