Exemplo n.º 1
0
        void ProcessType(TypeDefinition type, XPathNavigator nav)
        {
            TypePreserve preserve = GetTypePreserve(nav);

            if (!IsRequired(nav))
            {
                Annotations.SetPreserve(type, preserve);
                return;
            }

            Annotations.Mark(type);

            if (type.IsNested)
            {
                var parent = type;
                while (parent.IsNested)
                {
                    parent = parent.DeclaringType;
                    Annotations.Mark(parent);
                }
            }

            if (preserve != TypePreserve.Nothing)
            {
                Annotations.SetPreserve(type, preserve);
            }

            if (nav.HasChildren)
            {
                MarkSelectedFields(nav, type);
                MarkSelectedMethods(nav, type);
            }
        }
Exemplo n.º 2
0
        void ProcessType(TypeDefinition type, XPathNavigator nav)
        {
            TypePreserve preserve = GetTypePreserve(nav);

            if (!IsRequired(nav))
            {
                Annotations.SetPreserve(type, preserve);
                return;
            }

            Annotations.Mark(type);

            switch (preserve)
            {
            case TypePreserve.Nothing:
                if (!nav.HasChildren)
                {
                    Annotations.SetPreserve(type, TypePreserve.All);
                }
                break;

            default:
                Annotations.SetPreserve(type, preserve);
                break;
            }

            if (nav.HasChildren)
            {
                MarkSelectedFields(nav, type);
                MarkSelectedMethods(nav, type);
            }
        }
Exemplo n.º 3
0
        public static TypePreserve ChoosePreserveActionWhichPreservesTheMost(TypePreserve leftPreserveAction, TypePreserve rightPreserveAction)
        {
            if (leftPreserveAction == rightPreserveAction)
            {
                return(leftPreserveAction);
            }

            if (leftPreserveAction == TypePreserve.All || rightPreserveAction == TypePreserve.All)
            {
                return(TypePreserve.All);
            }

            if (leftPreserveAction == TypePreserve.Nothing)
            {
                return(rightPreserveAction);
            }

            if (rightPreserveAction == TypePreserve.Nothing)
            {
                return(leftPreserveAction);
            }

            if ((leftPreserveAction == TypePreserve.Methods && rightPreserveAction == TypePreserve.Fields) ||
                (leftPreserveAction == TypePreserve.Fields && rightPreserveAction == TypePreserve.Methods))
            {
                return(TypePreserve.All);
            }

            return(rightPreserveAction);
        }
Exemplo n.º 4
0
        public static void SetPreserve(TypeDefinition type, TypePreserve preserve)
        {
            TypePreserve effectivePreserve = IsPreserved(type)
                                ? Merge(preserve, GetPreserve(type))
                                : preserve;

            AsProvider(type).Annotations [_preservedKey] = effectivePreserve;
        }
Exemplo n.º 5
0
        public void SetPreserve(TypeDefinition type, TypePreserve preserve)
        {
            TypePreserve existing;

            if (preserved_types.TryGetValue(type, out existing))
            {
                preserved_types [type] = ChoosePreserveActionWhichPreservesTheMost(existing, preserve);
            }
            else
            {
                preserved_types.Add(type, preserve);
            }
        }
        protected virtual void ProcessType(TypeDefinition type, XPathNavigator nav)
        {
            if (IsExcluded(nav))
            {
                return;
            }

            TypePreserve preserve = GetTypePreserve(nav);

            if (!IsRequired(nav))
            {
                Annotations.SetPreserve(type, preserve);
                return;
            }

            if (Annotations.IsMarked(type))
            {
                var existingLevel  = Annotations.IsPreserved(type) ? Annotations.GetPreserve(type) : TypePreserve.Nothing;
                var duplicateLevel = preserve != TypePreserve.Nothing ? preserve : nav.HasChildren ? TypePreserve.Nothing : TypePreserve.All;
                Context.LogMessage($"Duplicate preserve in {_xmlDocumentLocation} of {type.FullName} ({existingLevel}).  Duplicate uses ({duplicateLevel})");
            }

            Annotations.MarkAndPush(type);
            Tracer.AddDirectDependency(this, type);

            if (type.IsNested)
            {
                var parent = type;
                while (parent.IsNested)
                {
                    parent = parent.DeclaringType;
                    Annotations.Mark(parent);
                }
            }

            if (preserve != TypePreserve.Nothing)
            {
                Annotations.SetPreserve(type, preserve);
            }

            if (nav.HasChildren)
            {
                MarkSelectedFields(nav, type);
                MarkSelectedMethods(nav, type);
                MarkSelectedEvents(nav, type);
                MarkSelectedProperties(nav, type);
            }
            Tracer.Pop();
        }
Exemplo n.º 7
0
 private static TypePreserve Merge(TypePreserve x, TypePreserve y)
 {
     if (x == y)
     {
         return(x);
     }
     if (x == TypePreserve.Nothing)
     {
         return(y);
     }
     if (y == TypePreserve.Nothing)
     {
         return(x);
     }
     return(TypePreserve.All);
 }
Exemplo n.º 8
0
        protected override void ProcessType(TypeDefinition type, XPathNavigator nav)
        {
            Debug.Assert(ShouldProcessElement(nav));

#if !FEATURE_ILLINK
            if (IsExcluded(nav))
            {
                return;
            }
#endif

            TypePreserve preserve = GetTypePreserve(nav);
            if (preserve != TypePreserve.Nothing)
            {
                Annotations.SetPreserve(type, preserve);
            }

            bool required = IsRequired(nav);
            ProcessTypeChildren(type, nav, required);

            if (!required)
            {
                return;
            }

            if (Annotations.IsMarked(type))
            {
                var duplicateLevel = preserve != TypePreserve.Nothing ? preserve : nav.HasChildren ? TypePreserve.Nothing : TypePreserve.All;
            }

            Annotations.Mark(type, new DependencyInfo(DependencyKind.XmlDescriptor, _xmlDocumentLocation));

            if (type.IsNested)
            {
                var currentType = type;
                while (currentType.IsNested)
                {
                    var parent = currentType.DeclaringType;
                    Context.Annotations.Mark(parent, new DependencyInfo(DependencyKind.DeclaringType, currentType));
                    currentType = parent;
                }
            }
        }
Exemplo n.º 9
0
        protected virtual void ProcessType(TypeDefinition type, XPathNavigator nav)
        {
#if !FEATURE_ILLINK
            if (IsExcluded(nav))
            {
                return;
            }
#endif

            TypePreserve preserve = GetTypePreserve(nav);
            if (preserve != TypePreserve.Nothing)
            {
                Annotations.SetPreserve(type, preserve);
            }

            bool required = IsRequired(nav);
            MarkChildren(type, nav, required);

            if (!required)
            {
                return;
            }

            if (Annotations.IsMarked(type))
            {
                var existingLevel  = Annotations.TryGetPreserve(type, out TypePreserve existingPreserve) ? existingPreserve : TypePreserve.Nothing;
                var duplicateLevel = preserve != TypePreserve.Nothing ? preserve : nav.HasChildren ? TypePreserve.Nothing : TypePreserve.All;
                Context.LogMessage($"Duplicate preserve in {_xmlDocumentLocation} of {type.FullName} ({existingLevel}).  Duplicate uses ({duplicateLevel})");
            }

            Annotations.Mark(type, new DependencyInfo(DependencyKind.XmlDescriptor, _xmlDocumentLocation));

            if (type.IsNested)
            {
                var currentType = type;
                while (currentType.IsNested)
                {
                    var parent = currentType.DeclaringType;
                    Context.Annotations.Mark(parent, new DependencyInfo(DependencyKind.DeclaringType, currentType));
                    currentType = parent;
                }
            }
        }
Exemplo n.º 10
0
        void ProcessType(TypeDefinition type, XPathNavigator nav)
        {
            TypePreserve preserve = GetTypePreserve(nav);

            if (!IsRequired(nav))
            {
                Annotations.SetPreserve(type, preserve);
                return;
            }

            Annotations.MarkAndPush(type);
            Tracer.AddDirectDependency(this, type);

            if (type.IsNested)
            {
                var parent = type;
                while (parent.IsNested)
                {
                    parent = parent.DeclaringType;
                    Annotations.Mark(parent);
                }
            }

            if (preserve != TypePreserve.Nothing)
            {
                Annotations.SetPreserve(type, preserve);
            }

            if (nav.HasChildren)
            {
                MarkSelectedFields(nav, type);
                MarkSelectedMethods(nav, type);
                MarkSelectedEvents(nav, type);
                MarkSelectedProperties(nav, type);
            }
            Tracer.Pop();
        }
Exemplo n.º 11
0
		public static void SetPreserve (TypeDefinition type, TypePreserve preserve)
		{
			AsProvider (type).Annotations [_preservedKey] = preserve;
		}
Exemplo n.º 12
0
 public void SetPreserve(TypeDefinition type, TypePreserve preserve)
 {
     preserved_types [type] = preserve;
 }
Exemplo n.º 13
0
 public void SetPreserve(TypeDefinition type, TypePreserve preserve)
 {
     throw null;
 }
Exemplo n.º 14
0
 public static void SetPreserve(TypeDefinition type, TypePreserve preserve)
 {
     TypePreserve effectivePreserve = IsPreserved(type)
         ? Merge(preserve, GetPreserve(type))
         : preserve;
     AsProvider (type).Annotations [_preservedKey] = effectivePreserve;
 }
Exemplo n.º 15
0
		public void SetPreserve (TypeDefinition type, TypePreserve preserve)
		{
			preserved_types [type] = preserve;
		}
Exemplo n.º 16
0
 private static TypePreserve Merge(TypePreserve x, TypePreserve y)
 {
     if (x == y) return x;
     if (x == TypePreserve.Nothing) return y;
     if (y == TypePreserve.Nothing) return x;
     return TypePreserve.All;
 }
Exemplo n.º 17
0
 public static void SetPreserve(TypeDefinition type, TypePreserve preserve)
 {
     AsProvider(type).Annotations [_preservedKey] = preserve;
 }
Exemplo n.º 18
0
 public void VerifyBehaviorOfChoosePreserveActionWhichPreservesTheMost(TypePreserve left, TypePreserve right, TypePreserve expected)
 {
     Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(left, right)));
     Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(right, left)));
 }