diff options
author | Joel Martinez <joelmartinez@gmail.com> | 2018-06-14 21:35:29 +0300 |
---|---|---|
committer | Joel Martinez <joelmartinez@gmail.com> | 2018-06-14 21:36:37 +0300 |
commit | b9e0c40c9f90bc3f0864a185e464ff9b0db23308 (patch) | |
tree | c39cd5131313fbdd79b5a478bdb8133e31ae87e6 | |
parent | 55b98ed27958e43280a6e6b18d4815633c4c263c (diff) |
revert fix for #76.mdoc-5.7
Commit being reverted - f92ac8bcf7f4c0f7c1f12c3d23c1e5a829d7041d
22 files changed, 64 insertions, 810 deletions
diff --git a/mdoc/Mono.Documentation/MDocUpdater.cs b/mdoc/Mono.Documentation/MDocUpdater.cs index 1345b859..f2ef9cfd 100644 --- a/mdoc/Mono.Documentation/MDocUpdater.cs +++ b/mdoc/Mono.Documentation/MDocUpdater.cs @@ -320,8 +320,7 @@ namespace Mono.Documentation Console.Write ("."); foreach (var assembly in assemblySet.Assemblies) { - var a = cacheIndex.StartProcessingAssembly (assemblySet, assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); - + var a = cacheIndex.StartProcessingAssembly (assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); foreach (var type in assembly.GetTypes ()) { var t = a.ProcessType (type); @@ -673,14 +672,13 @@ namespace Mono.Documentation var namespacesSet = new HashSet<string>(); memberSet = new HashSet<string>(); - var frameworkEntry = frameworks.StartProcessingAssembly(assemblySet, assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); - assemblySet.Framework = frameworkEntry; + var frameworkEntry = frameworks.StartProcessingAssembly(assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); foreach (TypeDefinition type in docEnum.GetDocumentationTypes(assembly, typenames)) { var typeEntry = frameworkEntry.ProcessType(type); - string relpath = DoUpdateType(assemblySet, type, typeEntry, basepath, dest); + string relpath = DoUpdateType(type, typeEntry, basepath, dest); if (relpath == null) continue; @@ -689,7 +687,7 @@ namespace Mono.Documentation if (index == null) continue; - index.Add(assemblySet, assembly); + index.Add(assembly); index.Add(type); namespacesSet.Add(type.Namespace); @@ -736,12 +734,12 @@ namespace Mono.Documentation index_assemblies = WriteElement (index.DocumentElement, "Assemblies"); } - public void Add (AssemblySet set, AssemblyDefinition assembly) + public void Add (AssemblyDefinition assembly) { if (index_assemblies.SelectSingleNode ("Assembly[@Name='" + assembly.Name.Name + "']") != null) return; - app.AddIndexAssembly (assembly, index_assemblies, set.Framework); + app.AddIndexAssembly (assembly, index_assemblies); } public void Add (TypeDefinition type) @@ -779,12 +777,12 @@ namespace Mono.Documentation return file.Exists; } - public string DoUpdateType (AssemblySet set, TypeDefinition type, FrameworkTypeEntry typeEntry, string basepath, string dest) + public string DoUpdateType (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 (!DocUtils.IsPublic (type)) + if (!IsPublic (type)) return null; if (type.HasCustomAttributes && CustomAttributeNamesToSkip.All(x => type.CustomAttributes.Any(y => y.AttributeType.FullName == x))) @@ -876,7 +874,7 @@ namespace Mono.Documentation else { // Stub - XmlElement td = StubType (set, type, output, typeEntry.Framework.Importers, typeEntry.Framework.Id, typeEntry.Framework.Version); + XmlElement td = StubType (type, output, typeEntry.Framework.Importers, typeEntry.Framework.Id, typeEntry.Framework.Version); if (td == null) return null; } @@ -925,7 +923,7 @@ namespace Mono.Documentation return filename.ToString (); } - private void AddIndexAssembly (AssemblyDefinition assembly, XmlElement parent, FrameworkEntry fx) + private void AddIndexAssembly (AssemblyDefinition assembly, XmlElement parent) { XmlElement index_assembly = null; if (IsMultiAssembly) @@ -957,7 +955,7 @@ namespace Mono.Documentation index_assembly.AppendChild (culture); } - MakeAttributes (index_assembly, GetCustomAttributes (assembly.CustomAttributes, ""), fx, assemblyFilename:assembly.MainModule.FileName); + MakeAttributes (index_assembly, GetCustomAttributes (assembly.CustomAttributes, "")); parent.AppendChild (index_assembly); } @@ -1025,9 +1023,8 @@ namespace Mono.Documentation { using (assm) { + AddIndexAssembly(assm, index_assemblies); DoUpdateAssembly(assemblySet, assm, index_types, source, dest, goodfiles); - AddIndexAssembly (assm, index_assemblies, assemblySet.Framework); - processedAssemblyCount++; } } @@ -1063,7 +1060,7 @@ namespace Mono.Documentation var typeSet = new HashSet<string> (); memberSet = new HashSet<string> (); - var frameworkEntry = frameworks.StartProcessingAssembly (assemblySet, assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); + var frameworkEntry = frameworks.StartProcessingAssembly (assembly, assemblySet.Importers, assemblySet.Id, assemblySet.Version); foreach (TypeDefinition type in docEnum.GetDocumentationTypes (assembly, null)) { string typename = GetTypeFileName (type); @@ -1072,7 +1069,7 @@ namespace Mono.Documentation var typeEntry = frameworkEntry.ProcessType (type); - string reltypepath = DoUpdateType (assemblySet, type, typeEntry, source, dest); + string reltypepath = DoUpdateType (type, typeEntry, source, dest); if (reltypepath == null) continue; @@ -1892,7 +1889,7 @@ namespace Mono.Documentation // CREATE A STUB DOCUMENTATION FILE - public XmlElement StubType (AssemblySet set, TypeDefinition type, string output, IEnumerable<DocumentationImporter> importers, string Id, string Version) + public XmlElement StubType (TypeDefinition type, string output, IEnumerable<DocumentationImporter> importers, string Id, string Version) { string typesig = typeFormatters[0].GetDeclaration (type); if (typesig == null) return null; // not publicly visible @@ -1901,7 +1898,7 @@ namespace Mono.Documentation XmlElement root = doc.CreateElement ("Type"); doc.AppendChild (root); - var frameworkEntry = frameworks.StartProcessingAssembly (set, type.Module.Assembly, importers, Id, Version); + var frameworkEntry = frameworks.StartProcessingAssembly (type.Module.Assembly, importers, Id, Version); var typeEntry = frameworkEntry.ProcessType (type); DoUpdateType2 ("New Type", doc, type, typeEntry, output, true); statisticsCollector.AddMetric (typeEntry.Framework.Name, StatisticsItem.Types, StatisticsMetrics.Added); @@ -1964,7 +1961,7 @@ namespace Mono.Documentation if (type.IsGenericType ()) { - MakeTypeParameters (typeEntry, root, type.GenericParameters, type, MDocUpdater.HasDroppedNamespace (type)); + MakeTypeParameters (root, type.GenericParameters, type, MDocUpdater.HasDroppedNamespace (type)); } else { @@ -2053,16 +2050,16 @@ namespace Mono.Documentation ClearElement (root, "Interfaces"); } - MakeAttributes (root, GetCustomAttributes (type), typeEntry.Framework, type, typeEntry: typeEntry); + MakeAttributes (root, GetCustomAttributes (type), type); if (DocUtils.IsDelegate (type)) { - MakeTypeParameters (typeEntry, root, type.GenericParameters, type, MDocUpdater.HasDroppedNamespace (type)); + MakeTypeParameters (root, type.GenericParameters, type, MDocUpdater.HasDroppedNamespace (type)); var member = type.GetMethod ("Invoke"); bool fxAlternateTriggered = false; MakeParameters (root, member, member.Parameters, typeEntry, ref fxAlternateTriggered); - MakeReturnValue (typeEntry, root, member); + MakeReturnValue (root, member); } DocsNodeInfo typeInfo = new DocsNodeInfo (WriteElement (root, "Docs"), type); @@ -2169,14 +2166,14 @@ namespace Mono.Documentation ClearElement (me, "AssemblyInfo"); } - MakeAttributes (me, GetCustomAttributes (mi), typeEntry.Framework, mi.DeclaringType, typeEntry: typeEntry); + MakeAttributes (me, GetCustomAttributes (mi), mi.DeclaringType); - MakeReturnValue (typeEntry, me, mi, MDocUpdater.HasDroppedNamespace (mi)); + MakeReturnValue (me, mi, MDocUpdater.HasDroppedNamespace (mi)); if (mi is MethodReference) { MethodReference mb = (MethodReference)mi; if (mb.IsGenericMethod ()) - MakeTypeParameters (typeEntry, me, mb.GenericParameters, mi, MDocUpdater.HasDroppedNamespace (mi)); + MakeTypeParameters (me, mb.GenericParameters, mi, MDocUpdater.HasDroppedNamespace (mi)); } bool fxAlternateTriggered = false; MakeParameters (me, mi, typeEntry, ref fxAlternateTriggered, MDocUpdater.HasDroppedNamespace (mi)); @@ -3092,9 +3089,6 @@ namespace Mono.Documentation private static void NormalizeWhitespace (XmlElement e) { - if (e == null) - return; - // Remove all text and whitespace nodes from the element so it // is outputted with nice indentation and no blank lines. ArrayList deleteNodes = new ArrayList (); @@ -3262,119 +3256,33 @@ namespace Mono.Documentation } } - public static void MakeAttributes (XmlElement root, IEnumerable<string> attributes, FrameworkEntry fx, TypeReference t = null, FrameworkTypeEntry typeEntry = null, string assemblyFilename = null)//FrameworkEntry fx, TypeReference t = null) + private void MakeAttributes (XmlElement root, IEnumerable<string> attributes, TypeReference t = null) { - XmlElement e = (XmlElement)root.SelectSingleNode ("Attributes"); - 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<XmlElement> () - .Select (elem => new - { - ExistingValue = elem.FirstChild.InnerText, - XElement = elem, - }).ToArray(); - - - // iterate this framework's attributes and compare against the state - foreach(var currentAttribute in attributesCurrent) + if (!attributes.Any ()) { - var alreadyExists = attributesState.FirstOrDefault (state => state.ExistingValue == currentAttribute.Key); - if (alreadyExists != null) - { - // if FXA, add fx.name - if (fx.Frameworks.Count() > 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); - + ClearElement (root, "Attributes"); + return; + } - // add FXA if this isn't the first framework, and - bool typeNotExisted = (typeEntry != null && !typeEntry.PreviouslyProcessedFrameworkTypes.Any ()); - bool assemblyNotExisted = (assemblyFilename != null && !fx.PreviousFXContainsAssembly (assemblyFilename)); + XmlElement e = (XmlElement)root.SelectSingleNode ("Attributes"); + if (e != null) + e.RemoveAll (); + else if (e == null) + e = root.OwnerDocument.CreateElement ("Attributes"); - if (fx.Frameworks.Count() > 1 && !fx.IsFirstFramework && (!typeNotExisted && !assemblyNotExisted)) - { - ae.SetAttribute (Consts.FrameworkAlternate, fx.Name); - } - } - } - // iterate the state's attributes to find attributes that aren't - // a part of this framework's attributes. - foreach(var stateAttribute in attributesState) + foreach (string attribute in attributes) { - if (attributesCurrent.ContainsKey(stateAttribute.ExistingValue)) - { - continue; - } - else // let's remove it - { - - if (fx.Frameworks.Count() > 1) { - - if (stateAttribute.XElement.HasAttribute (Consts.FrameworkAlternate)) - { - // if has FXA, remove from list - var newfxlist = FXUtils.RemoveFXFromList (stateAttribute.XElement.GetAttribute (Consts.FrameworkAlternate), fx.Name); - stateAttribute.XElement.SetAttribute (Consts.FrameworkAlternate, newfxlist); - } - else if (!fx.IsFirstFramework) // doesn't have FXA, and isn't the first framework - { - // if not, we need to make sure - var priorfxList = fx.PreviousFrameworks.Select (f => f.Name).ToArray (); - stateAttribute.XElement.SetAttribute (Consts.FrameworkAlternate, string.Join (";", priorfxList)); - } - else if (fx.IsFirstFramework) - { - stateAttribute.XElement.ParentNode.RemoveChild (stateAttribute.XElement); - } - } - else - stateAttribute.XElement.ParentNode.RemoveChild (stateAttribute.XElement); - } - } - - // clean up - if (fx.IsLastFramework) { - foreach(var attr in e.ChildNodes.Cast<XmlElement> ().ToArray()) { - if (attr.HasAttribute (Consts.FrameworkAlternate) && string.IsNullOrWhiteSpace (attr.GetAttribute (Consts.FrameworkAlternate))) - attr.ParentNode.RemoveChild (attr); - } + XmlElement ae = root.OwnerDocument.CreateElement ("Attribute"); + e.AppendChild (ae); + var value = new String (FilterSpecialChars (attribute).ToArray ()); + WriteElementText (ae, "AttributeName", value); } - if (e != null && e.ParentNode == null) + if (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) @@ -3450,7 +3358,7 @@ namespace Mono.Documentation if (addfx) pe.SetAttribute (Consts.FrameworkAlternate, fx); - MakeAttributes (pe, GetCustomAttributes (param.CustomAttributes, ""), typeEntry.Framework, typeEntry: typeEntry); + MakeAttributes (pe, GetCustomAttributes (param.CustomAttributes, "")); }; /// addFXAttributes, adds the index attribute to all existing elements. /// Used when we first detect the scenario which requires this. @@ -3583,7 +3491,7 @@ namespace Mono.Documentation } } - private void MakeTypeParameters (FrameworkTypeEntry entry, XmlElement root, IList<GenericParameter> typeParams, MemberReference member, bool shouldDuplicateWithNew) + private void MakeTypeParameters (XmlElement root, IList<GenericParameter> typeParams, MemberReference member, bool shouldDuplicateWithNew) { if (typeParams == null || typeParams.Count == 0) { @@ -3618,7 +3526,7 @@ namespace Mono.Documentation XmlElement pe = root.OwnerDocument.CreateElement ("TypeParameter"); e.AppendChild (pe); pe.SetAttribute ("Name", t.Name); - MakeAttributes (pe, GetCustomAttributes (t.CustomAttributes, ""), entry.Framework, t.DeclaringType, typeEntry: entry); + MakeAttributes (pe, GetCustomAttributes (t.CustomAttributes, ""), t.DeclaringType); XmlElement ce = (XmlElement)e.SelectSingleNode ("Constraints"); if (attrs == GenericParameterAttributes.NonVariant && constraints.Count == 0) { @@ -3692,7 +3600,7 @@ namespace Mono.Documentation return GetDocTypeFullName (type).Replace ("@", "&"); } - private void MakeReturnValue (FrameworkTypeEntry typeEntry, XmlElement root, TypeReference type, IList<CustomAttribute> attributes, bool shouldDuplicateWithNew = false) + private void MakeReturnValue (XmlElement root, TypeReference type, IList<CustomAttribute> attributes, bool shouldDuplicateWithNew = false) { XmlElement e = WriteElement (root, "ReturnValue"); var valueToUse = GetDocTypeFullName (type); @@ -3704,25 +3612,25 @@ namespace Mono.Documentation { var newNode = WriteElementText (e, "ReturnType", valueToUse, forceNewElement: true); if (attributes != null) - MakeAttributes (e, GetCustomAttributes (attributes, ""), typeEntry.Framework, type, typeEntry: typeEntry); + MakeAttributes (e, GetCustomAttributes (attributes, ""), type); return newNode; }, type); } - private void MakeReturnValue (FrameworkTypeEntry typeEntry, XmlElement root, MemberReference mi, bool shouldDuplicateWithNew = false) + private void MakeReturnValue (XmlElement root, MemberReference mi, bool shouldDuplicateWithNew = false) { if (mi is MethodDefinition && ((MethodDefinition)mi).IsConstructor) return; else if (mi is MethodDefinition) - MakeReturnValue (typeEntry, root, ((MethodDefinition)mi).ReturnType, ((MethodDefinition)mi).MethodReturnType.CustomAttributes, shouldDuplicateWithNew); + MakeReturnValue (root, ((MethodDefinition)mi).ReturnType, ((MethodDefinition)mi).MethodReturnType.CustomAttributes, shouldDuplicateWithNew); else if (mi is PropertyDefinition) - MakeReturnValue (typeEntry, root, ((PropertyDefinition)mi).PropertyType, null, shouldDuplicateWithNew); + MakeReturnValue (root, ((PropertyDefinition)mi).PropertyType, null, shouldDuplicateWithNew); else if (mi is FieldDefinition) - MakeReturnValue (typeEntry, root, ((FieldDefinition)mi).FieldType, null, shouldDuplicateWithNew); + MakeReturnValue (root, ((FieldDefinition)mi).FieldType, null, shouldDuplicateWithNew); else if (mi is EventDefinition) - MakeReturnValue (typeEntry, root, ((EventDefinition)mi).EventType, null, shouldDuplicateWithNew); + MakeReturnValue (root, ((EventDefinition)mi).EventType, null, shouldDuplicateWithNew); else if (mi is AttachedEventReference) return; else if (mi is AttachedPropertyReference) diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/AssemblySet.cs b/mdoc/Mono.Documentation/Updater/Frameworks/AssemblySet.cs index 496d5624..6affe4cd 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/AssemblySet.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/AssemblySet.cs @@ -10,7 +10,7 @@ namespace Mono.Documentation.Updater.Frameworks /// <summary> /// Represents a set of assemblies that we want to document /// </summary> - public class AssemblySet : IDisposable + class AssemblySet : IDisposable { static readonly BaseAssemblyResolver resolver = new Frameworks.MDocResolver (); static IAssemblyResolver cachedResolver; @@ -23,23 +23,6 @@ namespace Mono.Documentation.Updater.Frameworks IEnumerable<string> importPaths; public IEnumerable<DocumentationImporter> Importers { get; private set; } - FrameworkEntry fx; - public FrameworkEntry Framework - { - get => fx; - set - { - fx = value; - fx.AddAssemblySet (this); - } - } - - /// <summary>This is meant only for unit test access</summary> - public IDictionary<string, bool> AssemblyMapsPath - { - get => assemblyPathsMap; - } - public AssemblySet (IEnumerable<string> paths) : this ("Default", paths, new string[0]) { } public AssemblySet (string name, IEnumerable<string> paths, IEnumerable<string> resolverSearchPaths, IEnumerable<string> imports = null, string version = null, string id = null) diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs index 304fc22e..5c98db27 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkEntry.cs @@ -11,9 +11,7 @@ namespace Mono.Documentation.Updater.Frameworks SortedSet<FrameworkTypeEntry> types = new SortedSet<FrameworkTypeEntry> (); IList<FrameworkEntry> allframeworks; - ISet<AssemblySet> allAssemblies = new SortedSet<AssemblySet> (); - - public int Index = 0; + public int index = 0; public FrameworkEntry (IList<FrameworkEntry> frameworks) { @@ -21,50 +19,13 @@ namespace Mono.Documentation.Updater.Frameworks if (allframeworks == null) allframeworks = new List<FrameworkEntry> (0); - Index = allframeworks.Count; + index = allframeworks.Count; } public string Name { get; set; } public string Version { get; set; } public string Id { get; set; } - /// <summary>Gets a value indicating whether this <see cref="T:Mono.Documentation.Updater.Frameworks.FrameworkEntry"/> is last framework being processed.</summary> - public bool IsLastFramework { - get => Index == allframeworks.Count - 1; - } - - public IEnumerable<FrameworkEntry> PreviousFrameworks { - get => allframeworks.Where (f => f.Index < this.Index); - } - - public ISet<AssemblySet> AllProcessedAssemblies { get => allAssemblies; } - - public void AddAssemblySet (AssemblySet assemblySet) - { - allAssemblies.Add (assemblySet); - } - - /// <summary>Checks to see if this assembly is contained in previously processed frameworks</summary> - public bool PreviousFXContainsAssembly(string name) - { - if (name.Contains (System.IO.Path.DirectorySeparatorChar)) - name = System.IO.Path.GetFileName (name); - - return PreviousFrameworks.Any (pf => pf.ContainsAssembly (name)); - } - - public bool ContainsAssembly(string name) { - if (name.Contains (System.IO.Path.DirectorySeparatorChar)) - name = System.IO.Path.GetFileName (name); - - return allAssemblies.Any (a => a.Contains (name)); - } - - /// <summary>Gets a value indicating whether this <see cref="T:Mono.Documentation.Updater.Frameworks.FrameworkEntry"/> is first framework being processed.</summary> - public bool IsFirstFramework { - get => this.Index == 0; - } - /// <summary>Only Use in Unit Tests</summary> public string Replace=""; diff --git a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs index e9e19600..25ae158b 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkIndex.cs @@ -26,13 +26,10 @@ namespace Mono.Documentation.Updater.Frameworks } } - public FrameworkEntry StartProcessingAssembly (AssemblySet set, AssemblyDefinition assembly, IEnumerable<DocumentationImporter> importers, string Id, string Version) + public FrameworkEntry StartProcessingAssembly (AssemblyDefinition assembly, IEnumerable<DocumentationImporter> importers, string Id, string Version) { - if (string.IsNullOrWhiteSpace (this.path)) - { - set.Framework = FrameworkEntry.Empty; - return FrameworkEntry.Empty; - } + if (string.IsNullOrWhiteSpace (this.path)) + return FrameworkEntry.Empty; string assemblyPath = assembly.MainModule.FileName; var frameworksDirectory = this.path.EndsWith ("frameworks.xml", StringComparison.OrdinalIgnoreCase) @@ -48,8 +45,6 @@ namespace Mono.Documentation.Updater.Frameworks entry = new FrameworkEntry (frameworks) { 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 f95dda87..a6886c8c 100644 --- a/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs +++ b/mdoc/Mono.Documentation/Updater/Frameworks/FrameworkTypeEntry.cs @@ -36,7 +36,7 @@ namespace Mono.Documentation.Updater.Frameworks { previouslyProcessedFXTypes = new Lazy<FrameworkTypeEntry[]> ( () => 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 092f8ca6..28a81f70 100644 --- a/mdoc/Test/DocTest-frameworkalternate.cs +++ b/mdoc/Test/DocTest-frameworkalternate.cs @@ -1,18 +1,12 @@ -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-frameworkalternate-aligned/FrameworksIndex/One.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/One.xml index a8c88e19..8248544a 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/One.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/One.xml @@ -1,15 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Framework Name="One"> <Namespace Name="Monodoc.Test"> - <Type Name="Monodoc.Test.FirstAttribute" Id="T:Monodoc.Test.FirstAttribute"> - <Member Id="M:Monodoc.Test.FirstAttribute.#ctor" /> - </Type> <Type Name="Monodoc.Test.MyClass" Id="T:Monodoc.Test.MyClass"> <Member Id="M:Monodoc.Test.MyClass.#ctor" /> <Member Id="M:Monodoc.Test.MyClass.Meth(System.Int32,System.String,System.Int32)" /> </Type> - <Type Name="Monodoc.Test.SecondAttribute" Id="T:Monodoc.Test.SecondAttribute"> - <Member Id="M:Monodoc.Test.SecondAttribute.#ctor" /> - </Type> </Namespace> </Framework>
\ 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 75f797af..9bb0a092 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Three.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Three.xml @@ -1,15 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Framework Name="Three"> <Namespace Name="Monodoc.Test"> - <Type Name="Monodoc.Test.FirstAttribute" Id="T:Monodoc.Test.FirstAttribute"> - <Member Id="M:Monodoc.Test.FirstAttribute.#ctor" /> - </Type> <Type Name="Monodoc.Test.MyClass" Id="T:Monodoc.Test.MyClass"> <Member Id="M:Monodoc.Test.MyClass.#ctor" /> <Member Id="M:Monodoc.Test.MyClass.Meth(System.Int32,System.String,System.Int32)" /> </Type> - <Type Name="Monodoc.Test.SecondAttribute" Id="T:Monodoc.Test.SecondAttribute"> - <Member Id="M:Monodoc.Test.SecondAttribute.#ctor" /> - </Type> </Namespace> </Framework>
\ 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 fc5ce8dd..7ba7f611 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Two.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/FrameworksIndex/Two.xml @@ -1,15 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Framework Name="Two"> <Namespace Name="Monodoc.Test"> - <Type Name="Monodoc.Test.FirstAttribute" Id="T:Monodoc.Test.FirstAttribute"> - <Member Id="M:Monodoc.Test.FirstAttribute.#ctor" /> - </Type> <Type Name="Monodoc.Test.MyClass" Id="T:Monodoc.Test.MyClass"> <Member Id="M:Monodoc.Test.MyClass.#ctor" /> <Member Id="M:Monodoc.Test.MyClass.Meth(System.Int32,System.String,System.Int32)" /> </Type> - <Type Name="Monodoc.Test.SecondAttribute" Id="T:Monodoc.Test.SecondAttribute"> - <Member Id="M:Monodoc.Test.SecondAttribute.#ctor" /> - </Type> </Namespace> </Framework>
\ 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 deleted file mode 100644 index 85eac346..00000000 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/FirstAttribute.xml +++ /dev/null @@ -1,40 +0,0 @@ -<Type Name="FirstAttribute" FullName="Monodoc.Test.FirstAttribute"> - <TypeSignature Language="C#" Value="public class FirstAttribute : Attribute" /> - <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit FirstAttribute extends System.Attribute" /> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Base> - <BaseTypeName>System.Attribute</BaseTypeName> - </Base> - <Interfaces /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - <Members> - <Member MemberName=".ctor"> - <MemberSignature Language="C#" Value="public FirstAttribute ();" /> - <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /> - <MemberType>Constructor</MemberType> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Parameters /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - </Member> - </Members> -</Type> 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 b7e6ee6d..8a01c986 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/MyClass.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/MyClass.xml @@ -48,11 +48,6 @@ <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> <AssemblyVersion>0.0.0.0</AssemblyVersion> </AssemblyInfo> - <Attributes> - <Attribute> - <AttributeName>Monodoc.Test.First</AttributeName> - </Attribute> - </Attributes> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/SecondAttribute.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/SecondAttribute.xml deleted file mode 100644 index f797bfe4..00000000 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/Monodoc.Test/SecondAttribute.xml +++ /dev/null @@ -1,40 +0,0 @@ -<Type Name="SecondAttribute" FullName="Monodoc.Test.SecondAttribute"> - <TypeSignature Language="C#" Value="public class SecondAttribute : Attribute" /> - <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit SecondAttribute extends System.Attribute" /> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Base> - <BaseTypeName>System.Attribute</BaseTypeName> - </Base> - <Interfaces /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - <Members> - <Member MemberName=".ctor"> - <MemberSignature Language="C#" Value="public SecondAttribute ();" /> - <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /> - <MemberType>Constructor</MemberType> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Parameters /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - </Member> - </Members> -</Type> diff --git a/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml b/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml index d544561f..264c4b95 100644 --- a/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml +++ b/mdoc/Test/en.expected-frameworkalternate-aligned/index.xml @@ -25,9 +25,7 @@ <Copyright>To be added.</Copyright> <Types> <Namespace Name="Monodoc.Test"> - <Type Name="FirstAttribute" Kind="Class" /> <Type Name="MyClass" Kind="Class" /> - <Type Name="SecondAttribute" Kind="Class" /> </Namespace> </Types> <Title>Untitled</Title> diff --git a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml index a8c88e19..8248544a 100644 --- a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml +++ b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/One.xml @@ -1,15 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Framework Name="One"> <Namespace Name="Monodoc.Test"> - <Type Name="Monodoc.Test.FirstAttribute" Id="T:Monodoc.Test.FirstAttribute"> - <Member Id="M:Monodoc.Test.FirstAttribute.#ctor" /> - </Type> <Type Name="Monodoc.Test.MyClass" Id="T:Monodoc.Test.MyClass"> <Member Id="M:Monodoc.Test.MyClass.#ctor" /> <Member Id="M:Monodoc.Test.MyClass.Meth(System.Int32,System.String,System.Int32)" /> </Type> - <Type Name="Monodoc.Test.SecondAttribute" Id="T:Monodoc.Test.SecondAttribute"> - <Member Id="M:Monodoc.Test.SecondAttribute.#ctor" /> - </Type> </Namespace> </Framework>
\ 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 75f797af..9bb0a092 100644 --- a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Three.xml +++ b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Three.xml @@ -1,15 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Framework Name="Three"> <Namespace Name="Monodoc.Test"> - <Type Name="Monodoc.Test.FirstAttribute" Id="T:Monodoc.Test.FirstAttribute"> - <Member Id="M:Monodoc.Test.FirstAttribute.#ctor" /> - </Type> <Type Name="Monodoc.Test.MyClass" Id="T:Monodoc.Test.MyClass"> <Member Id="M:Monodoc.Test.MyClass.#ctor" /> <Member Id="M:Monodoc.Test.MyClass.Meth(System.Int32,System.String,System.Int32)" /> </Type> - <Type Name="Monodoc.Test.SecondAttribute" Id="T:Monodoc.Test.SecondAttribute"> - <Member Id="M:Monodoc.Test.SecondAttribute.#ctor" /> - </Type> </Namespace> </Framework>
\ 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 fc5ce8dd..7ba7f611 100644 --- a/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Two.xml +++ b/mdoc/Test/en.expected-frameworkalternate/FrameworksIndex/Two.xml @@ -1,15 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Framework Name="Two"> <Namespace Name="Monodoc.Test"> - <Type Name="Monodoc.Test.FirstAttribute" Id="T:Monodoc.Test.FirstAttribute"> - <Member Id="M:Monodoc.Test.FirstAttribute.#ctor" /> - </Type> <Type Name="Monodoc.Test.MyClass" Id="T:Monodoc.Test.MyClass"> <Member Id="M:Monodoc.Test.MyClass.#ctor" /> <Member Id="M:Monodoc.Test.MyClass.Meth(System.Int32,System.String,System.Int32)" /> </Type> - <Type Name="Monodoc.Test.SecondAttribute" Id="T:Monodoc.Test.SecondAttribute"> - <Member Id="M:Monodoc.Test.SecondAttribute.#ctor" /> - </Type> </Namespace> </Framework>
\ 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 deleted file mode 100644 index 85eac346..00000000 --- a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/FirstAttribute.xml +++ /dev/null @@ -1,40 +0,0 @@ -<Type Name="FirstAttribute" FullName="Monodoc.Test.FirstAttribute"> - <TypeSignature Language="C#" Value="public class FirstAttribute : Attribute" /> - <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit FirstAttribute extends System.Attribute" /> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Base> - <BaseTypeName>System.Attribute</BaseTypeName> - </Base> - <Interfaces /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - <Members> - <Member MemberName=".ctor"> - <MemberSignature Language="C#" Value="public FirstAttribute ();" /> - <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /> - <MemberType>Constructor</MemberType> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Parameters /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - </Member> - </Members> -</Type> diff --git a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml index 4632b3fa..a0559f3b 100644 --- a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml +++ b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/MyClass.xml @@ -50,14 +50,6 @@ <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> <AssemblyVersion>0.0.0.0</AssemblyVersion> </AssemblyInfo> - <Attributes> - <Attribute> - <AttributeName>Monodoc.Test.First</AttributeName> - </Attribute> - <Attribute FrameworkAlternate="Two"> - <AttributeName>Monodoc.Test.Second</AttributeName> - </Attribute> - </Attributes> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> diff --git a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/SecondAttribute.xml b/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/SecondAttribute.xml deleted file mode 100644 index f797bfe4..00000000 --- a/mdoc/Test/en.expected-frameworkalternate/Monodoc.Test/SecondAttribute.xml +++ /dev/null @@ -1,40 +0,0 @@ -<Type Name="SecondAttribute" FullName="Monodoc.Test.SecondAttribute"> - <TypeSignature Language="C#" Value="public class SecondAttribute : Attribute" /> - <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit SecondAttribute extends System.Attribute" /> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Base> - <BaseTypeName>System.Attribute</BaseTypeName> - </Base> - <Interfaces /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - <Members> - <Member MemberName=".ctor"> - <MemberSignature Language="C#" Value="public SecondAttribute ();" /> - <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /> - <MemberType>Constructor</MemberType> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-one</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <AssemblyInfo> - <AssemblyName>DocTest-frameworkalternate-two</AssemblyName> - <AssemblyVersion>0.0.0.0</AssemblyVersion> - </AssemblyInfo> - <Parameters /> - <Docs> - <summary>To be added.</summary> - <remarks>To be added.</remarks> - </Docs> - </Member> - </Members> -</Type> diff --git a/mdoc/Test/en.expected-frameworkalternate/index.xml b/mdoc/Test/en.expected-frameworkalternate/index.xml index d544561f..264c4b95 100644 --- a/mdoc/Test/en.expected-frameworkalternate/index.xml +++ b/mdoc/Test/en.expected-frameworkalternate/index.xml @@ -25,9 +25,7 @@ <Copyright>To be added.</Copyright> <Types> <Namespace Name="Monodoc.Test"> - <Type Name="FirstAttribute" Kind="Class" /> <Type Name="MyClass" Kind="Class" /> - <Type Name="SecondAttribute" Kind="Class" /> </Namespace> </Types> <Title>Untitled</Title> diff --git a/mdoc/mdoc.Test/FrameworkAlternateTests.cs b/mdoc/mdoc.Test/FrameworkAlternateTests.cs index 4ae5200b..1727106d 100644 --- a/mdoc/mdoc.Test/FrameworkAlternateTests.cs +++ b/mdoc/mdoc.Test/FrameworkAlternateTests.cs @@ -1,7 +1,6 @@ using Mono.Documentation.Updater.Frameworks;
using NUnit.Framework; using System; -using System.Collections.Generic; using System.Linq; namespace mdoc.Test @@ -17,58 +16,12 @@ namespace mdoc.Test 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 LastFramework()
- {
- List<FrameworkEntry> entries = new List<FrameworkEntry>();
- 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<FrameworkEntry> entries = new List<FrameworkEntry> ();
- 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 39f58663..4d4aba38 100644 --- a/mdoc/mdoc.Test/XmlUpdateTests.cs +++ b/mdoc/mdoc.Test/XmlUpdateTests.cs @@ -8,45 +8,29 @@ using System.Collections.Generic; using Mono.Documentation.Updater.Frameworks; using Mono.Documentation.Updater; -namespace mdoc.Test +namespace mdoc.Test2 { - public class OneAttribute : Attribute { } - public class TwoAttribute : Attribute { } - - [One] public class MyClass { - [One] - public void Meth (int a, string d, int c) { } - + public void Meth (int a, string b, int c) { } } public class MyClass2 { - public void Meth (int a, string b, int c) { } + public void Meth (int d, string e, int f) { } } - } - -namespace mdoc.Test2 +namespace mdoc.Test { - using mdoc.Test; - - [One, Two] public class MyClass { - [One, Two] - public void Meth (int a, string b, int c) { } - } + public void Meth(int a, string d, int c) {} - [Two] + } public class MyClass2 { - [Two] - public void Meth (int d, string e, int f) { } + public void Meth (int a, string b, int c) { } } -} -namespace mdoc.Test -{ + /// <summary> /// Tests functions that update the EcmaXMl under various conditions from /// corresponding classes. @@ -428,313 +412,6 @@ namespace mdoc.Test 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<MyClass> (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, context.method.DeclaringType, typeEntry); - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement>().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<MyClass> (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, context.method.DeclaringType, typeEntry); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().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<MyClass> (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, context.method.DeclaringType, typeEntry); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().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<MyClass> (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, context.method.DeclaringType, typeEntry); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().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<MyClass> (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, context.method.DeclaringType, typeEntry); - } - - // 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, context.method.DeclaringType, typeEntry); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().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<MyClass> (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, context.method.DeclaringType, typeEntry); - } - - // 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, context.method.DeclaringType, typeEntry); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().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<MyClass> (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, context.method.DeclaringType, typeEntry); - } - - // 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, context.method.DeclaringType, typeEntry); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().ToArray (); - - Assert.IsTrue (attributes.Count () == 2); - Assert.AreEqual ("One", attributes[1].FirstChild.InnerText); - Assert.IsTrue (attributes[1].HasAttribute (Consts.FrameworkAlternate)); - Assert.AreEqual ("Two", attributes[1].GetAttribute (Consts.FrameworkAlternate)); - Assert.AreEqual ("Two", attributes[0].FirstChild.InnerText); - Assert.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); - - } - - [Test] - public void Attributes_TypeOrMethod_AllFX_OneMissing_Middle () - { - var context = InitContext<MyClass> (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, context.method.DeclaringType, typeEntry); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().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<MyClass> (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); - - foreach (var fx in context.fx.Frameworks) - { - FrameworkTypeEntry typeEntry = fx.Types.First (); - - string[] attributeList = new[] { "One" }; - string assemblyName = "one.dll"; - if (!fx.IsLastFramework && !fx.IsFirstFramework) - { - attributeList = new string[0]; - assemblyName = "three.dll"; - } - - - MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx, - - assemblyFilename: "three.dll"); - } - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().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<MyClass> (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, - assemblyFilename: "three.dll"); - - - var attrNode = context.doc.FirstChild.SelectSingleNode ("Attributes"); - var attributes = attrNode.SelectNodes ("Attribute").Cast<XmlElement> ().ToArray (); - - Assert.IsTrue (attributes.Count () == 1); - Assert.AreEqual ("One", attributes[0].FirstChild.InnerText); - Assert.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); - } - string Normalize(string xml) { XmlDocument doc = new XmlDocument (); @@ -953,10 +630,6 @@ namespace mdoc.Test { var t = f.ProcessType (type); t.ProcessMember (method); - - var aset = new AssemblySet (new[] { "one.dll" }); - f.AddAssemblySet (aset); - } else { var t = f.ProcessType (type2); |