예제 #1
0
        public void InternalEIITest()
        {
            XmlDocument doc = new System.Xml.XmlDocument();

            doc.LoadXml(XmlConsts.internalEllXml);

            MemberReference oldmember = null;
            var             type      = GetType(typeof(mdoc.Test2.InternalEIICalss));
            var             docEnum   = new DocumentationEnumerator();

            bool internalEIIflagged = false;

            foreach (DocsNodeInfo info in docEnum.GetDocumentationMembers(doc, type, FrameworkTypeEntry.Empty))
            {
                var flag = MDocUpdater.IsMemberNotPrivateEII(info.Member);

                if (!flag)
                {
                    internalEIIflagged = true;
                    oldmember          = info.Member;
                    //Note : The following operation will not be carried out, just prompt
                    //-> DeleteMember();
                    //-> statisticsCollector.AddMetric();
                }
            }
            Assert.IsTrue(internalEIIflagged, "Internal EII was not flagged");
            Assert.AreEqual("System.String mdoc.Test2.InternalEIICalss::mdoc.Test.SampleClasses.InterfaceA.Getstring(System.Int32)", oldmember.FullName);
        }
예제 #2
0
        public void Update_ImportDoc_Test()
        {
            List <DocumentationImporter> setimporters = new List <DocumentationImporter>();
            List <DocumentationImporter> importers    = new List <DocumentationImporter>();
            var filePath = Path.Combine(Path.GetDirectoryName(this.GetType().Module.Assembly.Location), "SampleClasses\\testImportDoc.xml");
            MsxdocDocumentationImporter importer = new MsxdocDocumentationImporter(
                filePath);

            setimporters.Add(importer);

            XmlDocument doc = new System.Xml.XmlDocument();

            doc.LoadXml(XmlConsts.internalEllXml);

            var type    = GetType(typeof(mdoc.Test2.InternalEIICalss));
            var docEnum = new DocumentationEnumerator();

            var nodeMember = docEnum.GetDocumentationMembers(doc, type, FrameworkTypeEntry.Empty).FirstOrDefault(t => t.Member.FullName == "System.String mdoc.Test2.InternalEIICalss::Getstring(System.Int32)");

            var testKeys = new string[] { "returns", "value", "related", "seealso" };

            for (int i = 0; i < testKeys.Length; i++)
            {
                Assert.IsTrue(DocUtils.CheckRemoveByImporter(nodeMember, testKeys[i], importers, setimporters));
            }
        }
예제 #3
0
        private void TestProperty(string propertyName)
        {
            TypeDefinition theclass = GetTypeDef <ConcreteClass> ();

            var members = DocumentationEnumerator.GetReflectionMembers(theclass, propertyName, "Property").ToArray();

            Assert.IsTrue(members.Any(), "no members found");
            Assert.AreEqual(1, members.Count(), "Different # of members found");
            Assert.AreEqual(propertyName, members.Single().Name);
        }
예제 #4
0
        public void DocMemberEnumerator2()
        {
            var context = InitContext <MyClass>(string.Format(typeFrameXml, multiFrameworkXml), 2, forceAlignment: true);

            FrameworkTypeEntry typeEntry = context.fx.Frameworks[2].Types.First();

            var enumerator = new DocumentationEnumerator();
            var matches    = enumerator.GetDocumentationMembers(context.doc, context.method.DeclaringType.Resolve(), typeEntry);

            Assert.IsTrue(matches.Any(m => m.Member == context.method && m.Node != null), "didn't match the member");
        }
예제 #5
0
        public void FindProperty_NonExistent()
        {
            string propertyName = "mdoc.Test.EnumeratorTests.IDontExist.AProperty";

            TypeDefinition theclass = GetTypeDef <ConcreteClass> ();

            var members = DocumentationEnumerator.GetReflectionMembers(theclass, propertyName, "Property").ToArray();


            Assert.IsFalse(members.Any(), "Invalid Member Matched");
        }
예제 #6
0
        private void TestMethodMember(string methodName, string theXml)
        {
            TypeDefinition theclass = GetTypeDef <ConcreteClass>();

            XmlDocument document = new XmlDocument();

            document.LoadXml(theXml);

            var member = DocumentationEnumerator.GetMember(theclass, new DocumentationMember(document.FirstChild, FrameworkTypeEntry.Empty));

            Assert.NotNull(member, "didn't find the node");
            Assert.AreEqual(methodName, member.Name);
        }
예제 #7
0
        private void testReturnType(string methName, string r)
        {
            TypeDefinition theclass = GetTypeDef <ConcreteClass>();

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(@"<Member MemberName=""" + methName + @""">
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>" + r + @"</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name=""value"" Type=""mdoc.Test.EnumeratorTests+ConcreteClass"" />
      </Parameters>
    </Member>");

            DocumentationMember docmember = new DocumentationMember(doc.DocumentElement, typeEntry: null);
            var result = DocumentationEnumerator.GetMember(theclass, docmember) as MethodReference;

            Assert.IsNotNull(result);
            Assert.AreEqual(methName, result.Name);
            Assert.AreEqual(r, result.ReturnType.FullName);
        }
예제 #8
0
        public void RemoveInvalidAssembliesInfo()
        {
            XmlDocument doc = new System.Xml.XmlDocument();

            doc.LoadXml(XmlConsts.internalEllXml);

            var type    = GetType(typeof(mdoc.Test2.InternalEIICalss));
            var docEnum = new DocumentationEnumerator();

            var delList = DocUtils.RemoveInvalidAssemblyInfo(doc.DocumentElement, false, "Type");

            Assert.IsTrue(delList.Count == 1);

            foreach (DocsNodeInfo info in docEnum.GetDocumentationMembers(doc, type, FrameworkTypeEntry.Empty))
            {
                delList.AddRange(DocUtils.RemoveInvalidAssemblyInfo(info.Node, false, "Member"));
            }

            Assert.IsTrue(delList.Count == 2);

            ///Note : (The following operation will not be carried out, just prompt)
            //   foreach (var delitem in delList)
            // delitem.ParentNode.RemoveChild(child);
        }