Пример #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> (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();
            StripDescriptors          = true;
            StripSubstitutions        = true;
            PInvokes                  = new List <PInvokeInfo> ();
            Suppressions              = new UnconditionalSuppressMessageAttributeState(this);

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

            Optimizations = new CodeOptimizationsSettings(defaultOptimizations);
        }
Пример #2
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);
        }