Beispiel #1
0
        public override object TrackedVisitTypeReference(TypeReference typeReference, object data)
        {
            if (GetFullName(typeReference) == "java.lang.Object" && typeReference.Parent is TypeDeclaration)
            {
                return(null);
            }
            string type = GetFullName(typeReference);

            string ns = null;

            if (type.LastIndexOf('.') != -1)
            {
                ns = type.Substring(0, type.LastIndexOf('.'));
            }
            if (CodeBase.Mappings.Contains(type) && !IsInvocationTarget(typeReference))
            {
                TypeReference dotNetType = typeReference;
                dotNetType.Type = CodeBase.Mappings[type].Target;
                if (!(Removeables.Contains(type) || Removeables.Contains(ns)))
                {
                    Removeables.Add(type);
                    Removeables.Add(ns);
                }

                if (!UsedTypes.Contains(dotNetType.Type))
                {
                    UsedTypes.Add(dotNetType.Type);
                }

                ReplaceCurrentNode(dotNetType);
            }
            else
            {
                if (type.IndexOf('$') != -1)
                {
                    type = type.Substring(0, type.IndexOf('$'));
                }
                if (!UsedTypes.Contains(type))
                {
                    UsedTypes.Add(type);
                }
                if (ns != null && !UsedTypes.Contains(ns))
                {
                    UsedTypes.Add(ns);
                }
            }

            return(null);
        }
Beispiel #2
0
 public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
 {
     if (Mode == "DotNet")
     {
         string testCaseClass = "NUnit.Framework.TestCase";
         int    index         = GetBaseTypeIndex(typeDeclaration, testCaseClass);
         if (index != -1)
         {
             Removeables.Add(testCaseClass);
             TypeDeclaration replacedType = RemoveBaseTypeFrom(typeDeclaration, (TypeReference)typeDeclaration.BaseTypes[index]);
             ReplaceCurrentNode(replacedType);
         }
     }
     return(base.TrackedVisitTypeDeclaration(typeDeclaration, data));
 }
Beispiel #3
0
        public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            int index = GetBaseTypeIndex(typeDeclaration, serializableType);

            if (index != -1)
            {
                Removeables.Add(serializableType);
                if (typeDeclaration.Type == ClassType.Class)
                {
                    List <Attribute> attributes = new List <Attribute>();
                    Attribute        attribute  = new Attribute("System.SerializableAttribute", null, null);
                    attributes.Add(attribute);
                    AttributeSection attributeSection = new AttributeSection("", attributes);

                    typeDeclaration.Attributes.Add(attributeSection);
                    attributeSection.Parent = typeDeclaration;
                }
                typeDeclaration = RemoveBaseTypeFrom(typeDeclaration, (TypeReference)typeDeclaration.BaseTypes[index]);
            }
            return(base.TrackedVisitTypeDeclaration(typeDeclaration, data));
        }