Пример #1
0
		public void Process (LinkContext context)
		{
			annotations = context.Annotations;

			ProcessCorlib (context);
			ProcessSystemCore (context);
		}
Пример #2
0
        public LinkContext(Pipeline pipeline, AssemblyResolver resolver, ReaderParameters readerParameters, UnintializedContextFactory factory)
        {
            _pipeline         = pipeline;
            _resolver         = resolver;
            _resolver.Context = this;
            _actions          = new Dictionary <string, AssemblyAction> ();
            _parameters       = new Dictionary <string, string> ();
            _readerParameters = readerParameters;

            SymbolReaderProvider = new DefaultSymbolReaderProvider(false);

            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            _annotations       = factory.CreateAnnotationStore(this);
            MarkingHelpers     = factory.CreateMarkingHelpers(this);
            Tracer             = factory.CreateTracer(this);
            MarkedKnownMembers = new KnownMembers();
            StripResources     = true;
        }
Пример #3
0
        public static IEnumerable <InterfaceImplementation> GetReferencedInterfaces(AnnotationStore annotations, MethodBody body)
        {
            var possibleStackTypes = AllPossibleStackTypes(body.Method);

            if (possibleStackTypes.Count == 0)
            {
                return(null);
            }

            var interfaceTypes = possibleStackTypes.Where(t => t.IsInterface).ToArray();

            if (interfaceTypes.Length == 0)
            {
                return(null);
            }

            var interfaceImplementations = new HashSet <InterfaceImplementation> ();

            // If a type could be on the stack in the body and an interface it implements could be on the stack on the body
            // then we need to mark that interface implementation.  When this occurs it is not safe to remove the interface implementation from the type
            // even if the type is never instantiated
            foreach (var type in possibleStackTypes)
            {
                // We only sweep interfaces on classes so that's why we only care about classes
                if (!type.IsClass)
                {
                    continue;
                }

                AddMatchingInterfaces(interfaceImplementations, type, interfaceTypes);
                var bases = annotations.GetClassHierarchy(type);
                foreach (var @base in bases)
                {
                    AddMatchingInterfaces(interfaceImplementations, @base, interfaceTypes);
                }
            }

            return(interfaceImplementations);
        }
Пример #4
0
		public LinkContext (Pipeline pipeline, AssemblyResolver resolver)
		{
			_pipeline = pipeline;
			_resolver = resolver;
			_actions = new Hashtable ();
			_parameters = new Hashtable ();
			_annotations = new AnnotationStore ();
			_readerParameters = new ReaderParameters {
				AssemblyResolver = _resolver,
			};
		}
Пример #5
0
        public static IEnumerable <(InterfaceImplementation, TypeDefinition)> GetReferencedInterfaces(AnnotationStore annotations, MethodBody body)
        {
            var possibleStackTypes = AllPossibleStackTypes(body.Method);

            if (possibleStackTypes.Count == 0)
            {
                return(null);
            }

            var interfaceTypes = possibleStackTypes.Where(t => t.IsInterface).ToArray();

            if (interfaceTypes.Length == 0)
            {
                return(null);
            }

            var interfaceImplementations = new HashSet <(InterfaceImplementation, TypeDefinition)> ();

            // If a type could be on the stack in the body and an interface it implements could be on the stack on the body
            // then we need to mark that interface implementation.  When this occurs it is not safe to remove the interface implementation from the type
            // even if the type is never instantiated
            foreach (var type in possibleStackTypes)
            {
                // We only sweep interfaces on classes so that's why we only care about classes
                if (!type.IsClass)
                {
                    continue;
                }

                TypeDefinition currentType = type;
                while (currentType?.BaseType != null)                 // Checking BaseType != null to skip System.Object
                {
                    AddMatchingInterfaces(interfaceImplementations, currentType, interfaceTypes);
                    currentType = currentType.BaseType.Resolve();
                }
            }

            return(interfaceImplementations);
        }
Пример #6
0
 public LinkContext(Pipeline pipeline, AssemblyResolver resolver, ReaderParameters readerParameters, AnnotationStore annotations)
 {
     _pipeline         = pipeline;
     _resolver         = resolver;
     _actions          = new Dictionary <string, AssemblyAction> ();
     _parameters       = new Dictionary <string, string> ();
     _annotations      = annotations;
     _readerParameters = readerParameters;
 }
Пример #7
0
        public static Dictionary <IMetadataTokenProvider, object> GetCustomAnnotations(this AnnotationStore self, string name)
        {
            var store = custom_annotations.GetOrCreateValue(self);

            if (!store.TryGetValue(name, out var dict))
            {
                store [name] = dict = new Dictionary <IMetadataTokenProvider, object> ();
            }
            return(dict);
        }