示例#1
0
        private void AssertChange(string from, string name, ChangeType change)
        {
            RootDetail r1 = ExtractEvent(Subjects.One, from, name);
            RootDetail r2 = ExtractEvent(Subjects.Two, from, name);

            Assert.AreEqual(change, r1.PerformCompare(r2));
        }
示例#2
0
		public TypeDetail(RootDetail parent, Type type)
			: base(parent, type)
		{
			CodeStringBuilder csb = new CodeStringBuilder(AppendMode.Text);
			csb.AppendType(type, false);
			_name = csb.ToString();
		}
示例#3
0
        protected void CheckForAttribute(RootDetail rd)
        {
            IEnumerator <AttributeDetail> ie = rd.FilterChildren <AttributeDetail>().GetEnumerator();

            Assert.IsTrue(ie.MoveNext());
            Log.Verbose("An attribute extracted: {0}", ie.Current.ToString());
            Assert.IsFalse(ie.MoveNext());
        }
示例#4
0
        public MemberDetail(RootDetail parent, MemberInfo mi)
            : base(parent, "")
        {
            IList<CustomAttributeData> cads = CustomAttributeData.GetCustomAttributes(mi);

            foreach (CustomAttributeData cad in cads)
            {
                _children.Add(new AttributeDetail(this, cad));
            }
        }
示例#5
0
        private void AssertChange(string name, ChangeType change)
        {
            RootDetail r1 = ExtractEnum(Subjects.One, name);
            RootDetail r2 = ExtractEnum(Subjects.Two, name);

            Align(r1, r2);

            Assert.AreEqual(Status.Present, r1.Status);
            Assert.AreEqual(Status.Present, r2.Status);

            Assert.AreEqual(change, r2.PerformCompare(r1));
        }
示例#6
0
        protected void Align(RootDetail t1, RootDetail t2)
        {
            List <List <ICanAlign> > lists = new List <List <ICanAlign> >();

            lists.Add(new List <ICanAlign>());
            lists.Add(new List <ICanAlign>());

            lists[0].Add(t1);
            lists[1].Add(t2);

            ListOperations.AlignListsNoParent(lists.ToArray());
        }
示例#7
0
        public EnumDetail(RootDetail parent, Type type)
            : base(parent, type)
        {
            _visibility = VisibilityUtil.GetVisibilityFor(type);
            _category = "enum";

            foreach (string name in Enum.GetNames(type))
            {
                _children.Add(
                    new EnumItemDetail(
                        this,
                        name,
                        Convert.ToInt64(
                            type.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
                                .GetRawConstantValue()),
                        _visibility));
            }

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.Mode = AppendMode.Html;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.Both;

            csb.AppendKeyword("enum ");
            csb.AppendText(type.Name);

            csb.Mode = AppendMode.Html;
            csb.AppendNewline();
            csb.AppendText("{");
            csb.AppendNewline();

            foreach (EnumItemDetail eid in FilterChildren<EnumItemDetail>())
            {
                csb.AppendIndent();
                csb.AppendText(eid.GetHtmlDeclaration());
                csb.AppendText(",");
                csb.AppendNewline();
            }

            csb.RemoveCharsFromEnd("<br>".Length);
            csb.RemoveCharsFromEnd(",".Length);
            csb.AppendNewline();
            csb.AppendText("}");
            csb.Mode = AppendMode.Both;

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }
示例#8
0
        public ReferenceDetail(RootDetail parent, AssemblyName name)
        {
            _assemblyName = name.FullName;
            _parent = parent;

            if (name.FullName.IndexOf(',') > 0)
            {
                _name = name.FullName.Substring(0, name.FullName.IndexOf(','));
            }
            else
            {
                _name = name.FullName;
            }
        }
示例#9
0
        public FieldDetail(RootDetail parent, FieldInfo fi)
            : base(parent, fi)
        {
            _name = fi.Name;
            _visibility = VisibilityUtil.GetVisibilityFor(fi);
            _category = "field";

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.Mode = AppendMode.Html;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.Both;

            if (fi.IsLiteral)
            {
                csb.AppendKeyword("const ");
            }
            else if (fi.IsStatic)
            {
                csb.AppendKeyword("static ");
            }

            if (fi.IsInitOnly)
            {
                csb.AppendKeyword("readonly ");
            }

            csb.AppendType(fi.FieldType);
            csb.AppendText(" ");
            csb.AppendText(fi.Name);

            if (fi.IsLiteral)
            {
                csb.AppendParameterValue(fi.GetRawConstantValue());
            }

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }
示例#10
0
        public AttributeDetail(RootDetail parent, CustomAttributeData cad)
            : base(parent, cad.Constructor.DeclaringType.FullName)
        {
            _declaration = cad.ToString();

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.AppendType(cad.Constructor.DeclaringType);

            if (cad.ConstructorArguments.Count > 0)
            {
                csb.AppendText("(");
                csb.AppendQuotedValue(cad.ConstructorArguments[0].Value);
                csb.AppendText(")");
            }

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }
示例#11
0
		public ClassDetail(RootDetail parent, Type type)
			: base(parent, type, false)
		{
			BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			Type[] types = type.GetNestedTypes(flags);

			_category = "class";

			foreach (Type nested in types)
			{
				if (nested.IsEnum)
				{
					_children.Add(new EnumDetail(this, nested));
				}
				else if (nested.IsInterface)
				{
					_children.Add(new InterfaceDetail(this, nested));
				}
				else if (nested.IsClass)
				{
					_children.Add(new ClassDetail(this, nested));
				}
			}
		}
示例#12
0
		public EventDetail(RootDetail parent, EventInfo ei)
			: base(parent, ei)
		{
			_name = ei.Name;
			_visibility = VisibilityUtil.GetVisibilityFor(ei.GetAddMethod(true));
			_category = "event";

			CodeStringBuilder csb = new CodeStringBuilder();

			AppendAttributesDeclaration(csb);

			csb.Mode = AppendMode.Html;
			csb.AppendVisibility(_visibility);
			csb.AppendText(" ");
			csb.Mode = AppendMode.Both;

			csb.AppendKeyword("event ");
			csb.AppendType(ei.EventHandlerType);
			csb.AppendText(" ");
			csb.AppendText(ei.Name);

			_declaration = csb.ToString();
			_declarationHtml = csb.ToHtmlString();
		}
示例#13
0
		public ResourcesDetail(RootDetail parent)
			: base(parent, "Resources")
		{
		}
示例#14
0
        public EntityDetail(RootDetail parent, Type type, bool takeVisibilityFromParent)
            : base(parent, type)
        {
            _visibility = VisibilityUtil.GetVisibilityFor(type);

            BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

            List<MethodBase> methods = FilterMethods(type.GetMethods(flags), type, false);
            foreach (MethodBase mi in methods)
            {
                MethodDetail md = new MethodDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    md.Visibility = _visibility;
                }

                _children.Add(md);
            }

            List<MethodBase> constructors = FilterMethods(type.GetConstructors(flags), type, false);
            foreach (MethodBase mi in constructors)
            {
                MethodDetail md = new MethodDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    md.Visibility = _visibility;
                }

                _children.Add(md);
            }

            List<MethodBase> operators = FilterMethods(type.GetMethods(flags), type, true);
            foreach (MethodBase mi in operators)
            {
                OperatorDetail od = new OperatorDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    od.Visibility = _visibility;
                }

                _children.Add(od);
            }

            List<PropertyInfo> props = FilterProperties(type.GetProperties(flags), type);
            foreach (PropertyInfo pi in props)
            {
                PropertyDetail pd = new PropertyDetail(this, pi);

                if (takeVisibilityFromParent)
                {
                    pd.Visibility = _visibility;
                }

                _children.Add(pd);
            }

            List<EventInfo> events = FilterEvents(type.GetEvents(flags), type);
            foreach (EventInfo ei in events)
            {
                EventDetail ed = new EventDetail(this, ei);

                if (takeVisibilityFromParent)
                {
                    ed.Visibility = _visibility;
                }

                _children.Add(ed);
            }

            List<FieldInfo> fields = FilterFields(type.GetFields(flags), type);
            foreach (FieldInfo fi in fields)
            {
                FieldDetail fd = new FieldDetail(this, fi);

                if (takeVisibilityFromParent)
                {
                    fd.Visibility = _visibility;
                }

                _children.Add(fd);
            }

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.Mode = AppendMode.Html;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.Both;

            if (type.IsAbstract && type.IsSealed)
            {
                csb.AppendKeyword("static ");
            }
            else if (type.IsInterface)
            {
                csb.AppendKeyword("interface ");
            }
            else if (type.IsAbstract)
            {
                csb.AppendKeyword("abstract ");
            }
            else if (type.IsSealed)
            {
                csb.AppendKeyword("sealed ");
            }

            if (type.IsClass)
            {
                csb.AppendKeyword("class ");
            }

            csb.AppendText(_name);

            csb.AppendBaseClasses(type);

            csb.AppendGenericRestrictions(type);

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }
示例#15
0
 public CodeDetail(RootDetail parent, MemberInfo mi)
     : base(parent, mi)
 {
 }
示例#16
0
 public static string GetVisibilityChangeText(RootDetail from, RootDetail to)
 {
     return(GetVisibilityChangeText((IHaveVisibility)from, (IHaveVisibility)to));
 }
示例#17
0
 public TraitDetail(RootDetail parent, string name, string value)
     : base(parent, name)
 {
     _value = value;
 }
示例#18
0
 public ResourceDetail(RootDetail parent, string name, byte[] content)
     : base(parent, name)
 {
     _contentHash = GenericUtility.GetHashText(content);
 }
示例#19
0
        public MethodDetail(RootDetail parent, MethodBase mi)
            : base(parent, mi)
        {
            CodeStringBuilder csb = new CodeStringBuilder(AppendMode.Text);
            csb.AppendMethodName(mi);
            _name = csb.ToString();

            _visibility = VisibilityUtil.GetVisibilityFor(mi);
            _category = "method";

            MethodBody body = null;

            try
            {
                body = mi.GetMethodBody();
            }
            catch (VerificationException)
            {
                // "Operation could destabilize the runtime" on .NET 3.0 WPF PresentationCore.dll
            }

            if (body != null)
            {
                _body = GenericUtility.GetILAsHashedText(mi);
            }

            csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            MethodInfo bi = null;
            if (mi is MethodInfo)
            {
                bi = ((MethodInfo)mi).GetBaseDefinition();
            }

            csb.Mode = AppendMode.Html;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.Both;

            if (mi.IsAbstract)
            {
                if (!mi.DeclaringType.IsInterface)
                {
                    csb.AppendKeyword("abstract ");
                }
            }
            else if (mi.IsVirtual && !mi.IsFinal)
            {
                if (!object.ReferenceEquals(mi, bi))
                {
                    csb.AppendKeyword("override ");
                }
                else
                {
                    csb.AppendKeyword("virtual ");
                }
            }
            else if (mi.IsStatic)
            {
                csb.AppendKeyword("static ");
            }

            if (mi is MethodInfo)
            {
                csb.AppendParameter(((MethodInfo)mi).ReturnParameter);
            }

            csb.AppendText(" ");
            csb.AppendText(_name);
            csb.AppendText("(");

            CodeStringBuilder csbParameters = new CodeStringBuilder(AppendMode.Text);

            foreach (ParameterInfo pi in mi.GetParameters())
            {
                csb.AppendParameter(pi);
                csb.AppendText(", ");

                csbParameters.AppendParameterType(pi);
                csbParameters.AppendText(", ");

                _parameterCount++;
            }

            if (mi.GetParameters().Length > 0)
            {
                csb.RemoveCharsFromEnd(2);
                csbParameters.RemoveCharsFromEnd(2);
            }

            csb.AppendText(")");

            if (mi is MethodInfo)
            {
                csb.AppendGenericRestrictions(mi);
            }

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
            _parameterTypesList = csbParameters.ToString();
        }
示例#20
0
		public ReferencesDetail(RootDetail parent)
			: base(parent, "References")
		{
		}
示例#21
0
		public NamespaceDetail(RootDetail parent, string name)
			: base(parent, name)
		{
		}
示例#22
0
        public PropertyDetail(RootDetail parent, PropertyInfo pi)
            : base(parent, pi)
        {
            _name = pi.Name;
            _category = "property";

            MethodInfo[] methods = pi.GetAccessors(true);
            foreach (MethodInfo mi in methods)
            {
                MethodDetail m = new MethodDetail(this, mi);

                if ((m.Name.Length > 3) && (mi.IsSpecialName))
                {
                    m.Name = m.Name.Substring(0, 3);
                }

                m.Declaration = null;
                _children.Add(m);
            }

            if (pi.GetIndexParameters().Length > 0)
            {
                CodeStringBuilder csbParameters = new CodeStringBuilder(AppendMode.Text);

                foreach (ParameterInfo ip in pi.GetIndexParameters())
                {
                    csbParameters.AppendParameterType(ip);
                    csbParameters.AppendText(", ");

                    _parameterCount++;
                }

                csbParameters.RemoveCharsFromEnd(2);

                _parameterTypesList = csbParameters.ToString();
            }

            _visibility = VisibilityUtil.GetMostVisible(FilterChildren<MethodDetail>());

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.Mode = AppendMode.Html;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.Both;

            csb.AppendType(pi.PropertyType);
            csb.AppendText(" ");
            csb.AppendText(pi.Name);

            if (this.ParameterCount > 0)
            {
                csb.AppendText("[");
                csb.AppendText(this.ParameterTypesList);
                csb.AppendText("]");
            }

            csb.Mode = AppendMode.Html;

            csb.AppendNewline();
            csb.AppendText("{");
            csb.AppendNewline();
            csb.AppendIndent();

            foreach (MethodDetail mi in FilterChildren<MethodDetail>())
            {
                if (mi.Visibility != _visibility)
                {
                    csb.AppendVisibility(mi.Visibility);
                    csb.AppendText(" ");
                }

                csb.AppendText(mi.Name);
                csb.AppendText("; ");
            }

            csb.AppendNewline();
            csb.AppendText("}");

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }
示例#23
0
 public MemberDetail(RootDetail parent, string name)
     : base(parent, name)
 {
 }
示例#24
0
		public OperatorDetail(RootDetail parent, MethodBase mi)
			: base(parent, mi)
		{
			_category = "operator";
		}
示例#25
0
		public ParentDetail(RootDetail parent, string name)
			: base(parent, name)
		{
		}
示例#26
0
		public AttributesDetail(RootDetail parent)
			: base(parent, "Attributes")
		{
		}
示例#27
0
		public InterfaceDetail(RootDetail parent, Type type)
			: base(parent, type, true)
		{
			_category = "interface";
		}