Example #1
0
        public static void Process(LinkerOptions options, out MonoMacLinkContext context, out List <string> assemblies)
        {
            var pipeline = CreatePipeline(options);

            pipeline.PrependStep(new ResolveFromAssemblyStep(options.MainAssembly));

            context = CreateLinkContext(options, pipeline);
            context.Resolver.AddSearchDirectory(options.OutputDirectory);
            context.KeepTypeForwarderOnlyAssemblies = (Profile.Current is XamarinMacProfile);
            options.Target.LinkContext = (context as MonoMacLinkContext);

            try {
                pipeline.Process(context);
            } catch (AssemblyResolutionException fnfe) {
                throw new MonoMacException(2002, true, fnfe, fnfe.Message);
            } catch (AggregateException) {
                throw;
            } catch (MonoMacException) {
                throw;
            } catch (ResolutionException re) {
                TypeReference  tr    = (re.Member as TypeReference);
                IMetadataScope scope = tr == null ? re.Member.DeclaringType.Scope : tr.Scope;
                throw new MonoMacException(2002, true, re, "Failed to resolve \"{0}\" reference from \"{1}\"", re.Member, scope);
            } catch (XmlResolutionException ex) {
                throw new MonoMacException(2017, true, ex, "Could not process XML description: {0}", ex?.InnerException?.Message ?? ex.Message);
            } catch (Exception e) {
                var message = new StringBuilder();
                if (e.Data.Count > 0)
                {
                    message.AppendLine();
                    var m = e.Data ["MethodDefinition"] as string;
                    if (m != null)
                    {
                        message.AppendLine($"\tMethod: `{m}`");
                    }
                    var t = e.Data ["TypeReference"] as string;
                    if (t != null)
                    {
                        message.AppendLine($"\tType: `{t}`");
                    }
                    var a = e.Data ["AssemblyDefinition"] as string;
                    if (a != null)
                    {
                        message.AppendLine($"\tAssembly: `{a}`");
                    }
                }
                message.Append($"Reason: {e.Message}");
                throw new MonoMacException(2001, true, e, "Could not link assemblies. {0}", message);
            }

            assemblies = ListAssemblies(context);
        }
Example #2
0
        static LinkContext CreateLinkContext(LinkerOptions options, Pipeline pipeline)
        {
            var context = new MonoMacLinkContext(pipeline, options.Resolver);

            context.CoreAction  = AssemblyAction.Link;
            context.LinkSymbols = options.LinkSymbols;
            if (options.LinkSymbols)
            {
                context.SymbolReaderProvider = new DefaultSymbolReaderProvider();
                context.SymbolWriterProvider = new DefaultSymbolWriterProvider();
            }
            context.OutputDirectory = options.OutputDirectory;
            return(context);
        }
Example #3
0
        public static void Process(LinkerOptions options, out MonoMacLinkContext context, out List <string> assemblies)
        {
            var pipeline = CreatePipeline(options);

            pipeline.PrependStep(new ResolveFromAssemblyStep(options.MainAssembly));

            context = CreateLinkContext(options, pipeline);
            context.Resolver.AddSearchDirectory(options.OutputDirectory);
            context.KeepTypeForwarderOnlyAssemblies = (Profile.Current is XamarinMacProfile);
            options.Target.LinkContext = (context as MonoMacLinkContext);

            Process(pipeline, context);

            assemblies = ListAssemblies(context);
        }
Example #4
0
 static LinkContext CreateLinkContext(LinkerOptions options, Pipeline pipeline)
 {
     var context = new MonoMacLinkContext (pipeline, options.Resolver);
     context.CoreAction = AssemblyAction.Link;
     context.LinkSymbols = options.LinkSymbols;
     if (options.LinkSymbols) {
         context.SymbolReaderProvider = new MdbReaderProvider ();
         context.SymbolWriterProvider = new MdbWriterProvider ();
     }
     context.OutputDirectory = options.OutputDirectory;
     return context;
 }