Exemplo n.º 1
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);
            ReflectionPatternRecorder = new LoggingReflectionPatternRecorder(this);
            MarkedKnownMembers        = new KnownMembers();
            StripResources            = true;

            // See https://github.com/mono/linker/issues/612
            DisabledOptimizations |= CodeOptimizations.UnreachableBodies;
            DisabledOptimizations |= CodeOptimizations.ClearInitLocals;
            DisabledOptimizations |= CodeOptimizations.IPConstantPropagation;
        }
Exemplo n.º 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> (StringComparer.Ordinal);
            _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);
            ReflectionPatternRecorder = new LoggingReflectionPatternRecorder(this);
            MarkedKnownMembers        = new KnownMembers();
            StripResources            = true;
            PInvokes                  = new List <PInvokeInfo> ();

            // See https://github.com/mono/linker/issues/612
            const CodeOptimizations defaultOptimizations =
                CodeOptimizations.BeforeFieldInit |
                CodeOptimizations.OverrideRemoval |
                CodeOptimizations.UnusedInterfaces |
                CodeOptimizations.IPConstantPropagation;

            Optimizations = new CodeOptimizationsSettings(defaultOptimizations);
        }
Exemplo n.º 3
0
        public LinkContext(Pipeline pipeline, ILogger logger)
        {
            _pipeline = pipeline;
            _logger   = logger ?? throw new ArgumentNullException(nameof(logger));

            _resolver = new AssemblyResolver()
            {
                Context = this
            };
            _typeNameResolver = new TypeNameResolver(this);
            _actions          = new Dictionary <string, AssemblyAction> ();
            _parameters       = new Dictionary <string, string> (StringComparer.Ordinal);
            _readerParameters = new ReaderParameters {
                AssemblyResolver = _resolver
            };
            _customAttributes = new CustomAttributeSource(this);
            _cachedWarningMessageContainers = new List <MessageContainer> ();

            SymbolReaderProvider = new DefaultSymbolReaderProvider(false);

            var factory = new UnintializedContextFactory();

            _annotations              = factory.CreateAnnotationStore(this);
            MarkingHelpers            = factory.CreateMarkingHelpers(this);
            Tracer                    = factory.CreateTracer(this);
            ReflectionPatternRecorder = new LoggingReflectionPatternRecorder(this);
            MarkedKnownMembers        = new KnownMembers();
            PInvokes                  = new List <PInvokeInfo> ();
            Suppressions              = new UnconditionalSuppressMessageAttributeState(this);
            NoWarn                    = new HashSet <int> ();
            GeneralWarnAsError        = false;
            WarnAsError               = new Dictionary <int, bool> ();
            WarnVersion               = WarnVersion.Latest;

            const CodeOptimizations defaultOptimizations =
                CodeOptimizations.BeforeFieldInit |
                CodeOptimizations.OverrideRemoval |
                CodeOptimizations.UnusedInterfaces |
                CodeOptimizations.UnusedTypeChecks |
                CodeOptimizations.IPConstantPropagation |
                CodeOptimizations.UnreachableBodies |
                CodeOptimizations.RemoveDescriptors |
                CodeOptimizations.RemoveLinkAttributes |
                CodeOptimizations.RemoveSubstitutions |
                CodeOptimizations.RemoveDynamicDependencyAttribute;

            Optimizations = new CodeOptimizationsSettings(defaultOptimizations);
        }
Exemplo n.º 4
0
        public LinkContext(Pipeline pipeline, AssemblyResolver resolver, ReaderParameters readerParameters, UnintializedContextFactory factory)
        {
            _pipeline         = pipeline;
            _resolver         = resolver;
            _resolver.Context = this;
            _typeNameResolver = new TypeNameResolver(this);
            _actions          = new Dictionary <string, AssemblyAction> ();
            _parameters       = new Dictionary <string, string> (StringComparer.Ordinal);
            _readerParameters = readerParameters;
            _customAttributes = new CustomAttributeSource();
            _cachedWarningMessageContainers = new List <MessageContainer> ();

            SymbolReaderProvider = new DefaultSymbolReaderProvider(false);
            Logger = new ConsoleLogger();

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

            _annotations              = factory.CreateAnnotationStore(this);
            MarkingHelpers            = factory.CreateMarkingHelpers(this);
            Tracer                    = factory.CreateTracer(this);
            ReflectionPatternRecorder = new LoggingReflectionPatternRecorder(this);
            MarkedKnownMembers        = new KnownMembers();
            StripDescriptors          = true;
            StripSubstitutions        = true;
            StripLinkAttributes       = true;
            PInvokes                  = new List <PInvokeInfo> ();
            Suppressions              = new UnconditionalSuppressMessageAttributeState(this);
            NoWarn                    = new HashSet <int> ();
            GeneralWarnAsError        = false;
            WarnAsError               = new Dictionary <int, bool> ();
            WarnVersion               = WarnVersion.Latest;

            // See https://github.com/mono/linker/issues/612
            const CodeOptimizations defaultOptimizations =
                CodeOptimizations.BeforeFieldInit |
                CodeOptimizations.OverrideRemoval |
                CodeOptimizations.UnusedInterfaces |
                CodeOptimizations.UnusedTypeChecks |
                CodeOptimizations.IPConstantPropagation;

            Optimizations = new CodeOptimizationsSettings(defaultOptimizations);
        }