Esempio n. 1
0
        /// <summary>
        /// Loads plugin assemblies into the application domain and populates the collection of plugins.
        /// </summary>
        /// <param name="pluginDir"></param>
        public void Init(string pluginDir)
        {
            UnInit();

            PluginDir = pluginDir;

            foreach (var dllFile in Directory.GetFiles(PluginDir, "*.dll"))
            {
                try {
                    var asm = Assembly.LoadFile(dllFile);
                    Log.WriteLine("Loaded assembly {0}.", asm.GetName().Name);

                    // TODO: restrict assemblies loaded based on digital signature,
                    // implementing a required interface, DRM, etc

                    Assemblies.Add(asm);
                }
                catch (ReflectionTypeLoadException rex) {
                    Log.WriteLine("Plugin {0} failed to load.", Path.GetFileName(dllFile));
                    foreach (var ex in rex.LoaderExceptions)
                    {
                        Log.WriteLine("\t{0}: {1}", ex.GetType().Name, ex.Message);
                    }
                }
                catch (BadImageFormatException) {
                    // ignore, this simply means the DLL was not a .NET assembly
                    Log.WriteLine("Plugin {0} is not a valid assembly.", Path.GetFileName(dllFile));
                }
                catch (Exception ex) {
                    Log.WriteLine("Plugin {0} failed to load.", Path.GetFileName(dllFile));
                    Log.WriteLine("\t{0}: {1}", ex.GetType().Name, ex.Message);
                }
            }
        }
        private void AddDllFile(string filename)
        {
            try
            {
                Assembly assem;

                // we're not sure if this is a managed assembly or not
                // we try to load it, if it fails - we add it as an additional file
                var result = PackageLoader.TryLoadFrom(filename, out assem);
                if (result)
                {
                    Assemblies.Add(new PackageAssembly()
                    {
                        Assembly      = assem,
                        IsNodeLibrary = true // assume is node library when first added
                    });
                    RaisePropertyChanged("PackageContents");
                }
                else
                {
                    AddAdditionalFile(filename);
                }
            }
            catch (Exception e)
            {
                dynamoViewModel.Model.Logger.Log(e);
            }
        }
Esempio n. 3
0
        /// <inheritdoc />
        public async override Task Extract()
        {
            var packageUnzipPath = await NuGetPackageHelper.InstallPackages(_packageNames, Platform).ConfigureAwait(false);

            Log.Debug($"Package unzip path is {packageUnzipPath}");

            var xamarinForms =
                Directory.GetFiles(
                    packageUnzipPath,
                    "Xamarin.Forms.Core.dll",
                    SearchOption.AllDirectories);

            var latestVersion = xamarinForms.Last();

            Assemblies.Add(latestVersion);

            if (PlatformHelper.IsRunningOnMono())
            {
                CecilSearchDirectories.Add(
                    @"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks/.NETPortable/v4.5/Profile/Profile111");
                CecilSearchDirectories.Add(@"/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Facades");
            }
            else
            {
                CecilSearchDirectories.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades");
            }
        }
Esempio n. 4
0
 public void FromConfuserProject(ConfuserProject prj)
 {
     output = prj.OutputPath;
     snKey  = prj.SNKeyPath;
     seed   = prj.Seed;
     dbg    = prj.Debug;
     foreach (var i in prj.Plugins)
     {
         LoadAssembly(Assembly.LoadFrom(i), false);
     }
     if (prj.Packer != null)
     {
         this.packer = new PrjConfig <Packer>(Packers.Single(_ => _.ID == prj.Packer.Id), this);
         foreach (var j in prj.Packer.AllKeys)
         {
             this.packer.Add(new PrjArgument(this)
             {
                 Name = j, Value = prj.Packer[j]
             });
         }
     }
     foreach (var i in prj)
     {
         PrjAssembly asm = new PrjAssembly(this);
         asm.FromCrAssembly(this, i);
         Assemblies.Add(asm);
     }
     foreach (var i in prj.Rules)
     {
         PrjRule rule = new PrjRule(this);
         rule.FromCrRule(this, i);
         Rules.Add(rule);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Loads plugin assemblies into the application domain and populates the collection of plugins.
 /// </summary>
 /// <param name="pluginDir"></param>
 /// <param name="disabledPlugins"></param>
 public void Init(string pluginDir)
 {
     Uninit();
     PluginDir = pluginDir;
     foreach (string dllFile in Directory.GetFiles(PluginDir, "*.dll"))
     {
         try {
             Assembly asm = Assembly.LoadFile(dllFile);
             Log.WriteLine("Loaded assembly {0}.", asm.GetName().Name);
             Assemblies.Add(asm);
         }
         catch (ReflectionTypeLoadException rex) {
             Log.WriteLine("Plugin {0} failed to load.", Path.GetFileName(dllFile));
             foreach (Exception ex in rex.LoaderExceptions)
             {
                 Log.WriteLine("\t{0}: {1}", ex.GetType().Name, ex.Message);
             }
         }
         catch (BadImageFormatException) {
             // ignore, this simply means the DLL was not a .NET assembly
             Log.WriteLine("Plugin {0} is not a valid assembly.", Path.GetFileName(dllFile));
         }
         catch (Exception ex) {
             Log.WriteLine("Plugin {0} failed to load.", Path.GetFileName(dllFile));
             Log.WriteLine("\t{0}: {1}", ex.GetType().Name, ex.Message);
         }
     }
 }
Esempio n. 6
0
        public void Load(Type baseclass)
        {
            CreateDomain();

            var classes = new List <RemoteClass>(Classes);

            foreach (var file in DLLs)
            {
                var aname = AssemblyName.GetAssemblyName(file.FullName);
                if (Assemblies.TryGetValue(file.FullName, out string cached_aname))
                {
                    if (!aname.FullName.Equals(cached_aname))
                    {
                        Unload();
                        Load(baseclass);
                        return;
                    }
                }
                else
                {
                    classes.AddRange(Loader.LoadAssemblyClasses(aname));
                    Assemblies.Add(file.FullName, aname.FullName);
                }
            }

            if (baseclass == null)
            {
                Classes = classes.ToArray();
            }
            else
            {
                Classes = Loader.FilterClasses(classes.ToArray(), baseclass.FullName);
            }
        }
Esempio n. 7
0
        /// <inheritdoc />
        public override Task Extract()
        {
            var sdks = new List <string>();

            if (PlatformHelper.IsRunningOnMono())
            {
                CecilSearchDirectories.Add(
                    "/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild-frameworks/MonoAndroid/v1.0");

                sdks.AddRange(Directory.GetFiles(
                                  "/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild-frameworks/MonoAndroid",
                                  "Mono.Android.dll",
                                  SearchOption.AllDirectories));
            }
            else
            {
                CecilSearchDirectories.Add(Path.Combine(_referenceAssembliesLocation, "MonoAndroid", "v1.0"));
                sdks.AddRange(Directory.GetFiles(
                                  Path.Combine(_referenceAssembliesLocation, "MonoAndroid"),
                                  "Mono.Android.dll",
                                  SearchOption.AllDirectories));
            }

            // Pin to a particular framework version https://github.com/reactiveui/ReactiveUI/issues/1517
            var latestVersion = sdks.Last(x => x.Contains(DesiredVersion, StringComparison.InvariantCulture));

            Assemblies.Add(latestVersion);
            CecilSearchDirectories.Add(Path.GetDirectoryName(latestVersion));

            return(Task.CompletedTask);
        }
Esempio n. 8
0
        /// <summary>
        /// Performs the RefreshAssemblies command.
        /// </summary>
        /// <param name="parameter">The RefreshAssemblies command parameter.</param>
        private void DoRefreshAssembliesCommand(object parameter)
        {
            //  Clear the assemblies.
            Assemblies.Clear();

            //  Set the status text.
            RefreshAssembliesCommand.ReportProgress(
                () =>
            {
                StatusInfo = Resources.Msg_RefreshAssemblies_Progress;
            });

            //  Start the enumeration.
            var timeTaken = ApexBroker.GetModel <IGACManagerModel>().EnumerateAssemblies(
                assemblyDetails =>
            {
                //  Create an assembly view model from the detials.
                var viewModel = new GACAssemblyViewModel();
                viewModel.FromModel(assemblyDetails);

                //  Add it to the collection.
                Assemblies.Add(viewModel);
            });

            //  Set the resulting status info.
            RefreshAssembliesCommand.ReportProgress(
                () =>
            {
                AssembliesCollectionView = new ListCollectionView(Assemblies.ToList());

                AssembliesCollectionView.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
                AssembliesCollectionView.Filter += Filter;
                StatusInfo = string.Format(Resources.Msg_RefreshAssemblies_Success, Assemblies.Count, timeTaken.TotalMilliseconds);
            });
        }
Esempio n. 9
0
 public void Add(Result result)
 {
     lock (this)
     {
         var lv1 = Assemblies.SingleOrDefault(it => it.UniqueName == result.Test.Fixture.Assembly.UniqueName);
         if (lv1 == null)
         {
             lv1 = result.Test.Fixture.Assembly;
             Assemblies.Add(lv1);
         }
         var lv2 = lv1.Fixtures.SingleOrDefault(it => it.UniqueName == result.Test.Fixture.UniqueName);
         if (lv2 == null)
         {
             lv2 = result.Test.Fixture;
             lv1.Fixtures.Add(lv2);
         }
         var lv3 = lv2.Tests.SingleOrDefault(it => it.UniqueName == result.Test.UniqueName);
         if (lv3 == null)
         {
             lv3 = result.Test;
             lv2.Tests.Add(lv3);
         }
         var lv4 = lv3.Results.SingleOrDefault(it => it.Platform == result.Platform);
         if (lv4 == null)
         {
             lv4 = result;
             lv3.Results.Add(lv4);
         }
     }
 }
        void ModuleLoaded(object sender, ModuleEventArgs e)
        {
            DebuggerModuleModel model = new DebuggerModuleModel(e.Module);

            moduleModels.Add(model);
            Assemblies.Add(model.AssemblyModel);
        }
Esempio n. 11
0
        private void AssembliesLoader_DoWork(object sender, DoWorkEventArgs e)
        {
            Assemblies.Clear();

            // Add default assembly
            Assemblies.Add(new AssemblyInfo(typeof(Node).Assembly, true, false));

            // Load domain assemblies
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                AnalyzeAssembly(assembly, true);
            }

            // Load local plugins
            foreach (string path in Directory.GetFiles(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FlowTomator.*.dll"))
            {
                FileInfo fileInfo = new FileInfo(path);

                if (!fileInfo.Exists || Assemblies.Any(a => a.Path == fileInfo.FullName))
                {
                    continue;
                }

                try
                {
                    Assembly assembly = Assembly.ReflectionOnlyLoadFrom(path);
                    AnalyzeAssembly(assembly, false);
                }
                catch
                {
                    continue;
                }
            }
        }
Esempio n. 12
0
        /// <inheritdoc />
        public override Task Extract()
        {
            if (PlatformHelper.IsRunningOnMono())
            {
                var assembly =
                    @"/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll";
                Assemblies.Add(assembly);

                CecilSearchDirectories.Add(Path.GetDirectoryName(assembly));
            }
            else
            {
                var assemblies =
                    Directory.GetFiles(
                        Path.Combine(_referenceAssembliesLocation, "Xamarin.Mac"),
                        "Xamarin.Mac.dll",
                        SearchOption.AllDirectories);

                var latestVersion = assemblies.Last();
                Assemblies.Add(latestVersion);

                CecilSearchDirectories.Add(Path.GetDirectoryName(latestVersion));
            }

            return(Task.CompletedTask);
        }
Esempio n. 13
0
 public static void RegisterAssembly(Assembly assembly, string prefix = "")
 {
     if (!Assemblies.Keys.Contains(assembly))
     {
         Assemblies.Add(assembly, prefix);
     }
 }
 public void ScanAssembly(Assembly assembly)
 {
     if (!Assemblies.Contains(assembly))
     {
         Assemblies.Add(assembly);
     }
 }
Esempio n. 15
0
        public Android()
        {
            if (PlatformHelper.IsRunningOnMono())
            {
                var sdks =
                    Directory.GetFiles(
                        @"/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild-frameworks/MonoAndroid",
                        "Mono.Android.dll", SearchOption.AllDirectories);

                var latestVersion = sdks.Last();
                Assemblies.Add(latestVersion);

                CecilSearchDirectories.Add(Path.GetDirectoryName(latestVersion));
                CecilSearchDirectories.Add(
                    "/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild-frameworks/MonoAndroid/v1.0");
            }
            else
            {
                var assemblies =
                    Directory.GetFiles(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid",
                                       "Mono.Android.dll", SearchOption.AllDirectories);

                var latestVersion = assemblies.Last();
                Assemblies.Add(latestVersion);

                CecilSearchDirectories.Add(Path.GetDirectoryName(latestVersion));
                CecilSearchDirectories.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0");
            }
        }
 protected override OptionSet OnCreateOptions() => new OptionSet
 {
     { "a|assembly=", "One or more assemblies to merge", v => Assemblies.Add(v) },
     { "o|output=", "The output path to use for the merged assembly", v => SetOutputPath(v) },
     { "s|search=", "One or more search directories", v => SearchDirectories.Add(v) },
     { "inject-assemblyname", "Add the assembly names to the types", _ => InjectAssemblyNames = true },
 };
Esempio n. 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Android" /> class.
        /// </summary>
        /// <param name="referenceAssembliesLocation">The reference assemblies location.</param>
        public Android(string referenceAssembliesLocation)
        {
            if (PlatformHelper.IsRunningOnMono())
            {
                var sdks =
                    Directory.GetFiles(
                        @"/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild-frameworks/MonoAndroid",
                        "Mono.Android.dll",
                        SearchOption.AllDirectories);

                var latestVersion = sdks.Last();
                Assemblies.Add(latestVersion);

                CecilSearchDirectories.Add(Path.GetDirectoryName(latestVersion));
                CecilSearchDirectories.Add(
                    "/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild-frameworks/MonoAndroid/v1.0");
            }
            else
            {
                var assemblies =
                    Directory.GetFiles(
                        Path.Combine(referenceAssembliesLocation, "MonoAndroid"),
                        "Mono.Android.dll",
                        SearchOption.AllDirectories);

                // Pin to a particular framework version https://github.com/reactiveui/ReactiveUI/issues/1517
                var latestVersion = assemblies.Last(x => x.Contains("v8"));
                Assemblies.Add(latestVersion);

                CecilSearchDirectories.Add(Path.GetDirectoryName(latestVersion));
                CecilSearchDirectories.Add(Path.Combine(referenceAssembliesLocation, "MonoAndroid", "v1.0"));
            }
        }
 /// <summary>
 /// Adds the assembly to the list of required assemblies.
 /// </summary>
 public void AddAssembly(string assemblyName)
 {
     if (!Assemblies.Contains(assemblyName))
     {
         Assemblies.Add(assemblyName);
     }
 }
Esempio n. 19
0
        public void AddI18nAssemblies()
        {
            Assemblies.Add(LoadI18nAssembly("I18N"));

            if (IncludeI18nAssembly(Mono.Linker.I18nAssemblies.CJK))
            {
                Assemblies.Add(LoadI18nAssembly("I18N.CJK"));
            }

            if (IncludeI18nAssembly(Mono.Linker.I18nAssemblies.MidEast))
            {
                Assemblies.Add(LoadI18nAssembly("I18N.MidEast"));
            }

            if (IncludeI18nAssembly(Mono.Linker.I18nAssemblies.Other))
            {
                Assemblies.Add(LoadI18nAssembly("I18N.Other"));
            }

            if (IncludeI18nAssembly(Mono.Linker.I18nAssemblies.Rare))
            {
                Assemblies.Add(LoadI18nAssembly("I18N.Rare"));
            }

            if (IncludeI18nAssembly(Mono.Linker.I18nAssemblies.West))
            {
                Assemblies.Add(LoadI18nAssembly("I18N.West"));
            }
        }
Esempio n. 20
0
        public IEnumerable <AssemblyDefinition> LoadAssemblies(string path, string mask = defaultMask)
        {
            var resolver = new DefaultAssemblyResolver();

            resolver.AddSearchDirectory(path);

            var readerParameters = new ReaderParameters
            {
                AssemblyResolver = resolver,
                ReadingMode      = ReadingMode.Deferred
            };

            var newAssemblies = new List <AssemblyDefinition>();

            foreach (var file in ScanDirectory(path, mask))
            {
                var asm = LoadAssemblyImpl(file, readerParameters);
                if (asm != null && Assemblies.Add(asm))
                {
                    newAssemblies.Add(asm);
                }
            }

            RefreshTypes(newAssemblies);
            return(newAssemblies);
        }
Esempio n. 21
0
        /// <summary>
        /// load dll which is in root path,and not kooboo dll
        /// </summary>
        /// <param name="extensiondlls"></param>
        public void LoadSpecificDlls(string extensiondlls)
        {
            var path = AppDomain.CurrentDomain.BaseDirectory;

            if (!string.IsNullOrEmpty(extensiondlls))
            {
                var extensionList = extensiondlls.Split(',').Distinct().ToList();
                foreach (var dll in extensionList)
                {
                    try
                    {
                        var filename = dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
                            ? dll
                            : string.Format("{0}.dll", dll);

                        var filepath = Path.Combine(path, filename);
                        if (File.Exists(filepath))
                        {
                            var assembly = Assembly.Load(File.ReadAllBytes(filepath));

                            if (assembly != null && !Assemblies.Exists(ass => ass.FullName.Equals(assembly.FullName)))
                            {
                                Assemblies.Add(assembly);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 22
0
        public IDapperConfiguration FromAssembly(string name)
        {
            string path = Directory
                          .GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll", SearchOption.AllDirectories)
                          .SingleOrDefault(s =>
            {
                var fileName = Path.GetFileNameWithoutExtension(s);
                return(fileName != null && fileName.Equals(name, StringComparison.OrdinalIgnoreCase));
            });

            if (string.IsNullOrEmpty(path))
            {
                throw new NullReferenceException(string.Format("Assembly '{0}' could not be found.", name));
            }

            string assemblyName = Path.GetFileNameWithoutExtension(path);
            var    assembly     = Assembly.Load(assemblyName);

            if (assembly == null)
            {
                throw new NullReferenceException(string.Format("Assembly '{0}' could not be loaded.", name));
            }

            Assemblies.Add(assembly);

            return(this);
        }
Esempio n. 23
0
        /// <inheritdoc />
        public async override Task Extract()
        {
            var packageUnzipPath = await NuGetPackageHelper.InstallPackages(_packageNames, Platform).ConfigureAwait(false);

            Log.Debug($"Package unzip path is {packageUnzipPath}");

            var xamarinForms =
                Directory.GetFiles(
                    packageUnzipPath,
                    "Xamarin.Essentials.dll",
                    SearchOption.AllDirectories);

            var latestVersion = xamarinForms.First(x => x.Contains("netstandard1.0", StringComparison.InvariantCulture));

            Assemblies.Add(latestVersion);

            if (PlatformHelper.IsRunningOnMono())
            {
                CecilSearchDirectories.Add(
                    @"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks/.NETPortable/v4.5/Profile/Profile111");
            }
            else
            {
                CecilSearchDirectories.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile111");
            }
        }
Esempio n. 24
0
        bool HandleAssemblyParsed(ParserResult <IKVM.Reflection.Assembly> result)
        {
            HandleParserResult(result);

            if (result.Output.GetReferencedAssemblies().Any(ass => ass.Name == "Mono.Android") &&
                Options.Compilation.Platform != TargetPlatform.Android)
            {
                Console.Error.WriteLine("Assembly references Mono.Android.dll, plase specify target platform as Android.");

                result.Kind = ParserResultKind.Error;
                return(false);
            }

            if (result.Kind != ParserResultKind.Success)
            {
                return(false);
            }

            //NOTE: this can happen if multiple generators are running
            if (!Assemblies.Contains(result.Output))
            {
                Assemblies.Add(result.Output);
            }

            return(true);
        }
Esempio n. 25
0
 //This method allows a single dll to be added to the assemblies list that is referenced in the source code that is being compiled.
 //The method makes sure the assemblies are unique in the list.
 public void AddAssemblyLocation(string assembly)
 {
     if (Assemblies.Contains(assembly))
     {
         Assemblies.Remove(assembly);
     }
     Assemblies.Add(assembly);
 }
Esempio n. 26
0
 public UWP()
 {
     if (PlatformHelper.IsRunningOnMono())
     {
         throw new NotSupportedException("Building events for UWP on Mac is not implemented yet.");
     }
     Assemblies.Add(@"C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd");
 }
Esempio n. 27
0
 public static void Add(string @namespace, Assembly assembly, Func <DbContext> contextAccessor)
 {
     if (Assemblies.ContainsKey(@namespace))
     {
         throw new DuplicateKeyException(@namespace, "Already exists an Assembly for specified namespace.");
     }
     Assemblies.Add(@namespace, assembly);
     Contexts.Add(@namespace, contextAccessor);
 }
Esempio n. 28
0
        public IAssemblyDescriptor Assembly(Assembly assembly)
        {
            if (this.Patterns.Any(p => assembly.FullName.StartsWith(p)))
            {
                Assemblies.Add(assembly);
            }

            return(this);
        }
        private void AddAssembly(Assembly asm)
        {
            if (Assemblies.Contains(asm))
            {
                return;
            }

            Assemblies.Add(asm);
        }
Esempio n. 30
0
        public AssemblyCallProvider AddAssembly(params string[] assemblies)
        {
            foreach (var assembly in assemblies)
            {
                Assemblies.Add(Assembly.Load(assembly));
            }

            return(this);
        }