diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2018-02-26 20:22:21 +0300 |
---|---|---|
committer | Lluis Sanchez <llsan@microsoft.com> | 2018-02-26 20:22:21 +0300 |
commit | 8dc3e7af0ba110f9a1832e365d8aa08d1e77ffd8 (patch) | |
tree | d9ddc5495448dd5dbc6dafae50cfa2b652108ff8 /Mono.Addins/Mono.Addins.Database/AddinScanner.cs | |
parent | 3147dc5c2a2a147e95745a87d1a9d927f4fbf08d (diff) |
Complete implementation of addin scan data file generation
Refactored the code to allow generating scan data files
independently from the add-in database update process.
The new AddinFolderVisitor class can be used to visit
all the add-in folders. Split the functionality previously
in AddinScanner in two classes. AddinRegistryUpdater is
now in charge of locating the addins. AddinScanner now
only implements the actual add-in scanning code, and the
logic to setup a custom assembly resolver has moved there.
Diffstat (limited to 'Mono.Addins/Mono.Addins.Database/AddinScanner.cs')
-rw-r--r-- | Mono.Addins/Mono.Addins.Database/AddinScanner.cs | 440 |
1 files changed, 113 insertions, 327 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs index 480d2bb..6b505f6 100644 --- a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs +++ b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs @@ -1,4 +1,4 @@ -// +// // AddinScanner.cs // // Author: @@ -41,216 +41,103 @@ using Mono.Addins.Description; namespace Mono.Addins.Database { - class AddinScanner: MarshalByRefObject + class AddinScanner: IDisposable { AddinDatabase database; - AddinFileSystemExtension fs; Dictionary<IAssemblyReflector,object> coreAssemblies = new Dictionary<IAssemblyReflector, object> (); - - public AddinScanner (AddinDatabase database, AddinScanResult scanResult, IProgressStatus monitor) + IAssemblyLocator assemblyLocator; + + public AddinScanner (AddinDatabase database, IAssemblyLocator locator) { this.database = database; - fs = database.FileSystem; + assemblyLocator = locator; + SetupAssemblyResolver (); } - - public void ScanFolder (IProgressStatus monitor, string path, string domain, AddinScanResult scanResult) + + public void Dispose () { - path = Path.GetFullPath (path); - - // Avoid folders including each other - if (!scanResult.VisitFolder (path)) - return; - - AddinScanFolderInfo folderInfo; - if (!database.GetFolderInfoForPath (monitor, path, out folderInfo)) { - // folderInfo file was corrupt. - // Just in case, we are going to regenerate all relation data. - if (!fs.DirectoryExists (path)) - scanResult.RegenerateRelationData = true; - } else { - // Directory is included but it doesn't exist. Ignore it. - if (folderInfo == null && !fs.DirectoryExists (path)) - return; - } - - // if domain is null it means that a new domain has to be created. - - bool sharedFolder = domain == AddinDatabase.GlobalDomain; - bool isNewFolder = folderInfo == null; - - if (isNewFolder) { - // No folder info. It is the first time this folder is scanned. - // There is no need to store this object if the folder does not - // contain add-ins. - folderInfo = new AddinScanFolderInfo (path); - } - - if (!sharedFolder && (folderInfo.SharedFolder || folderInfo.Domain != domain)) { - // If the folder already has a domain, reuse it - if (domain == null && folderInfo.RootsDomain != null && folderInfo.RootsDomain != AddinDatabase.GlobalDomain) - domain = folderInfo.RootsDomain; - else if (domain == null) { - folderInfo.Domain = domain = database.GetUniqueDomainId (); - scanResult.RegenerateRelationData = true; - } - else { - folderInfo.Domain = domain; - if (!isNewFolder) { - // Domain has changed. Update the folder info and regenerate everything. - scanResult.RegenerateRelationData = true; - scanResult.RegisterModifiedFolderInfo (folderInfo); - } - } - } - else if (!folderInfo.SharedFolder && sharedFolder) { - scanResult.RegenerateRelationData = true; - } - - folderInfo.SharedFolder = sharedFolder; - - // If there is no domain assigned to the host, get one now - if (scanResult.Domain == AddinDatabase.UnknownDomain) - scanResult.Domain = domain; - - // Discard folders not belonging to the required domain - if (scanResult.Domain != null && domain != scanResult.Domain && domain != AddinDatabase.GlobalDomain) { - return; - } - - if (monitor.LogLevel > 1 && !scanResult.LocateAssembliesOnly) - monitor.Log ("Checking: " + path); - - if (fs.DirectoryExists (path)) - { - IEnumerable<string> files = fs.GetFiles (path); - - // First of all, look for .addin files. Addin files must be processed before - // assemblies, because they may add files to the ignore list (i.e., assemblies - // included in .addin files won't be scanned twice). - foreach (string file in files) { - if (file.EndsWith (".addin.xml") || file.EndsWith (".addin")) { - RegisterFileToScan (monitor, file, scanResult, folderInfo); - } - } - - // Now scan assemblies. They can also add files to the ignore list. - - foreach (string file in files) { - string ext = Path.GetExtension (file).ToLower (); - if (ext == ".dll" || ext == ".exe") { - RegisterFileToScan (monitor, file, scanResult, folderInfo); - scanResult.AddAssemblyLocation (file); - } - } - - // Finally scan .addins files - - foreach (string file in files) { - if (Path.GetExtension (file).EndsWith (".addins")) { - ScanAddinsFile (monitor, file, domain, scanResult); - } - } - } - else if (!scanResult.LocateAssembliesOnly) { - // The folder has been deleted. All add-ins defined in that folder should also be deleted. - scanResult.RegenerateRelationData = true; - scanResult.ChangesFound = true; - if (scanResult.CheckOnly) - return; - database.DeleteFolderInfo (monitor, folderInfo); - } - - if (scanResult.LocateAssembliesOnly) - return; - - // Look for deleted add-ins. - - UpdateDeletedAddins (monitor, folderInfo, scanResult); + TearDownAssemblyResolver (); + database.FileSystem.CleanupReflector (); } - - public void UpdateDeletedAddins (IProgressStatus monitor, AddinScanFolderInfo folderInfo, AddinScanResult scanResult) + + void SetupAssemblyResolver () { - ArrayList missing = folderInfo.GetMissingAddins (fs); - if (missing.Count > 0) { - if (fs.DirectoryExists (folderInfo.Folder)) - scanResult.RegisterModifiedFolderInfo (folderInfo); - scanResult.ChangesFound = true; - if (scanResult.CheckOnly) - return; - - foreach (AddinFileInfo info in missing) { - database.UninstallAddin (monitor, info.Domain, info.AddinId, info.File, scanResult); - } - } + ResolveEventHandler resolver = new ResolveEventHandler (OnResolveAddinAssembly); + AppDomain.CurrentDomain.AssemblyResolve += OnResolveAddinAssembly; + + EventInfo einfo = typeof (AppDomain).GetEvent ("ReflectionOnlyAssemblyResolve"); + if (einfo != null) + einfo.AddEventHandler (AppDomain.CurrentDomain, resolver); } - - void RegisterFileToScan (IProgressStatus monitor, string file, AddinScanResult scanResult, AddinScanFolderInfo folderInfo) + + void TearDownAssemblyResolver () { - if (scanResult.LocateAssembliesOnly) - return; + ResolveEventHandler resolver = new ResolveEventHandler (OnResolveAddinAssembly); + AppDomain.CurrentDomain.AssemblyResolve -= resolver; - AddinFileInfo finfo = folderInfo.GetAddinFileInfo (file); - bool added = false; - - if (finfo != null && (!finfo.IsAddin || finfo.Domain == folderInfo.GetDomain (finfo.IsRoot)) && fs.GetLastWriteTime (file) == finfo.LastScan && !scanResult.RegenerateAllData) { - if (finfo.ScanError) { - // Always schedule the file for scan if there was an error in a previous scan. - // However, don't set ChangesFound=true, in this way if there isn't any other - // change in the registry, the file won't be scanned again. - scanResult.AddFileToScan (file, folderInfo); - added = true; - } - - if (!finfo.IsAddin) - return; - - if (database.AddinDescriptionExists (finfo.Domain, finfo.AddinId)) { - // It is an add-in and it has not changed. Paths in the ignore list - // are still valid, so they can be used. - if (finfo.IgnorePaths != null) - scanResult.AddPathsToIgnore (finfo.IgnorePaths); - return; - } + EventInfo einfo = typeof (AppDomain).GetEvent ("ReflectionOnlyAssemblyResolve"); + if (einfo != null) + einfo.RemoveEventHandler (AppDomain.CurrentDomain, resolver); + assemblyLocator = null; + } + + Assembly OnResolveAddinAssembly (object s, ResolveEventArgs args) + { + string file = assemblyLocator != null ? assemblyLocator.GetAssemblyLocation (args.Name) : null; + if (file != null) + return Util.LoadAssemblyForReflection (file); + else { + if (!args.Name.StartsWith ("Mono.Addins.CecilReflector", StringComparison.Ordinal)) + Console.WriteLine ("Assembly not found: " + args.Name); + return null; } - - scanResult.ChangesFound = true; - - if (!scanResult.CheckOnly && !added) - scanResult.AddFileToScan (file, folderInfo); } - - public void ScanFile (IProgressStatus monitor, string file, AddinScanFolderInfo folderInfo, AddinScanResult scanResult) + + public void ScanFile (IProgressStatus monitor, FileToScan fileToScan, AddinScanResult scanResult, bool cleanPreScanFile) { - if (scanResult.IgnorePath (file)) { + var file = fileToScan.File; + var folderInfo = fileToScan.AddinScanFolderInfo; + + if (scanResult.ScanContext.IgnorePath (file)) { // The file must be ignored. Maybe it caused a crash in a previous scan, or it // might be included by a .addin file (in which case it will be scanned when processing // the .addin file). - folderInfo.SetLastScanTime (file, null, false, fs.GetLastWriteTime (file), true); + folderInfo.SetLastScanTime (file, null, false, database.FileSystem.GetLastWriteTime (file), true); return; } string scannedAddinId = null; bool scannedIsRoot = false; bool scanSuccessful = false; - bool loadedFromCacheFile = false; + bool loadedFromScanDataFile = false; AddinDescription config = null; string ext = Path.GetExtension (file).ToLower (); + bool isAssembly = ext == ".dll" || ext == ".exe"; + + string addinScanDataFileMD5 = null; + var scanDataFile = file + ".addindata"; - var cachedDataFile = Path.Combine (file, ".addindata"); - if (File.Exists (cachedDataFile)) { - if (database.ReadAddinDescription (monitor, cachedDataFile, out config)) { - scanSuccessful = true; - loadedFromCacheFile = true; - if (monitor.LogLevel > 1) - monitor.Log ("Loading cached add-in data file: " + file); - } else if (monitor.LogLevel > 1) - monitor.Log ("Cached add-in data file could not be loaded, ignoring: " + file); + if (File.Exists (scanDataFile)) { + if (cleanPreScanFile) + File.Delete (scanDataFile); + else { + if (database.ReadAddinDescription (monitor, scanDataFile, out config)) { + config.SetBasePath (Path.GetDirectoryName (file)); + config.AddinFile = file; + scanSuccessful = true; + loadedFromScanDataFile = true; + addinScanDataFileMD5 = fileToScan.ScanDataMD5; // The md5 for this scan data file should be in the index + if (monitor.LogLevel > 1) + monitor.Log ("Loading add-in scan data file: " + file); + } else if (monitor.LogLevel > 1) + monitor.Log ("Add-in scan data file could not be loaded, ignoring: " + file); + } } - if (!loadedFromCacheFile) { - if ((ext == ".dll" || ext == ".exe") && !Util.IsManagedAssembly (file)) { + if (!loadedFromScanDataFile) { + if (isAssembly && !Util.IsManagedAssembly (file)) { // Ignore dlls and exes which are not managed assemblies - folderInfo.SetLastScanTime (file, null, false, fs.GetLastWriteTime (file), true); + folderInfo.SetLastScanTime (file, null, false, database.FileSystem.GetLastWriteTime (file), true); return; } @@ -261,22 +148,23 @@ namespace Mono.Addins.Database // Log the file to be scanned, so in case of a process crash the main process // will know what crashed monitor.Log ("plog:scan:" + file); - + try { - if (!loadedFromCacheFile) { - if (ext == ".dll" || ext == ".exe") - scanSuccessful = ScanAssembly (monitor, file, scanResult, out config); + if (!loadedFromScanDataFile) { + if (isAssembly) + scanSuccessful = ScanAssembly (monitor, file, scanResult.ScanContext, out config); else - scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config); - - if (scanSuccessful && scanResult.ShouldGenerateAddinCacheDataFile (file)) { - // Save a binary data file next to the scanned file - database.SaveDescription (monitor, config, cachedDataFile); - } + scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult.ScanContext, out config); } if (config != null) { + if (scanSuccessful) { + // Clean host data from the index. New data will be added. + if (scanResult.HostIndex != null) + scanResult.HostIndex.RemoveHostData (config.AddinId, config.AddinFile); + } + AddinFileInfo fi = folderInfo.GetAddinFileInfo (file); // If version is not specified, make up one @@ -291,7 +179,7 @@ namespace Mono.Addins.Database } // Check errors in the description - StringCollection errors = config.Verify (fs); + StringCollection errors = config.Verify (database.FileSystem); if (database.IsGlobalRegistry && config.AddinId.IndexOf ('.') == -1) { errors.Add ("Add-ins registered in the global registry must have a namespace."); @@ -378,7 +266,7 @@ namespace Mono.Addins.Database monitor.ReportError ("Unexpected error while scanning file: " + file, ex); } finally { - AddinFileInfo ainfo = folderInfo.SetLastScanTime (file, scannedAddinId, scannedIsRoot, fs.GetLastWriteTime (file), !scanSuccessful); + AddinFileInfo ainfo = folderInfo.SetLastScanTime (file, scannedAddinId, scannedIsRoot, database.FileSystem.GetLastWriteTime (file), !scanSuccessful, addinScanDataFileMD5); if (scanSuccessful && config != null) { // Update the ignore list in the folder info object. To be used in the next scan @@ -406,9 +294,9 @@ namespace Mono.Addins.Database bool scanSuccessful; if (ext == ".dll" || ext == ".exe") - scanSuccessful = ScanAssembly (monitor, file, scanResult, out config); + scanSuccessful = ScanAssembly (monitor, file, scanResult.ScanContext, out config); else - scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config); + scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult.ScanContext, out config); if (scanSuccessful && config != null) { @@ -429,117 +317,25 @@ namespace Mono.Addins.Database } return config; } - - public void ScanAddinsFile (IProgressStatus monitor, string file, string domain, AddinScanResult scanResult) - { - XmlTextReader r = null; - ArrayList directories = new ArrayList (); - ArrayList directoriesWithSubdirs = new ArrayList (); - string basePath = Path.GetDirectoryName (file); - - try { - r = new XmlTextReader (fs.OpenTextFile (file)); - r.MoveToContent (); - if (r.IsEmptyElement) - return; - r.ReadStartElement (); - r.MoveToContent (); - while (r.NodeType != XmlNodeType.EndElement) { - if (r.NodeType == XmlNodeType.Element && r.LocalName == "Directory") { - string subs = r.GetAttribute ("include-subdirs"); - string sdom; - string share = r.GetAttribute ("shared"); - if (share == "true") - sdom = AddinDatabase.GlobalDomain; - else if (share == "false") - sdom = null; - else - sdom = domain; // Inherit the domain - - string path = r.ReadElementString ().Trim (); - if (path.Length > 0) { - path = Util.NormalizePath (path); - if (subs == "true") - directoriesWithSubdirs.Add (new string[] {path, sdom}); - else - directories.Add (new string[] {path, sdom}); - } - } - else if (r.NodeType == XmlNodeType.Element && r.LocalName == "GacAssembly") { - string aname = r.ReadElementString ().Trim (); - if (aname.Length > 0) { - aname = Util.NormalizePath (aname); - aname = Util.GetGacPath (aname); - if (aname != null) { - // Gac assemblies always use the global domain - directories.Add (new string[] {aname, AddinDatabase.GlobalDomain}); - } - } - } - else if (r.NodeType == XmlNodeType.Element && r.LocalName == "Exclude") { - string path = r.ReadElementString ().Trim (); - if (path.Length > 0) { - path = Util.NormalizePath (path); - if (!Path.IsPathRooted (path)) - path = Path.Combine (basePath, path); - scanResult.AddPathToIgnore (Path.GetFullPath (path)); - } - } - else - r.Skip (); - r.MoveToContent (); - } - } catch (Exception ex) { - monitor.ReportError ("Could not process addins file: " + file, ex); - return; - } finally { - if (r != null) - r.Close (); - } - - foreach (string[] d in directories) { - string dir = d[0]; - if (!Path.IsPathRooted (dir)) - dir = Path.Combine (basePath, dir); - ScanFolder (monitor, dir, d[1], scanResult); - } - foreach (string[] d in directoriesWithSubdirs) { - string dir = d[0]; - if (!Path.IsPathRooted (dir)) - dir = Path.Combine (basePath, dir); - ScanFolderRec (monitor, dir, d[1], scanResult); - } - } - - public void ScanFolderRec (IProgressStatus monitor, string dir, string domain, AddinScanResult scanResult) - { - ScanFolder (monitor, dir, domain, scanResult); - - if (!fs.DirectoryExists (dir)) - return; - - foreach (string sd in fs.GetDirectories (dir)) - ScanFolderRec (monitor, sd, domain, scanResult); - } - - bool ScanConfigAssemblies (IProgressStatus monitor, string filePath, AddinScanResult scanResult, out AddinDescription config) + + public bool ScanConfigAssemblies (IProgressStatus monitor, string filePath, ScanContext scanContext, out AddinDescription config) { config = null; IAssemblyReflector reflector = null; try { - reflector = GetReflector (monitor, scanResult, filePath); + reflector = GetReflector (monitor, assemblyLocator, filePath); string basePath = Path.GetDirectoryName (filePath); - using (var s = fs.OpenFile (filePath)) { + using (var s = database.FileSystem.OpenFile (filePath)) { config = AddinDescription.Read (s, basePath); } config.FileName = filePath; config.SetBasePath (basePath); config.AddinFile = filePath; - return ScanDescription (monitor, reflector, config, null, scanResult); + return ScanDescription (monitor, reflector, config, null, scanContext); } catch (Exception ex) { // Something went wrong while scanning the assembly. We'll ignore it for now. @@ -548,9 +344,9 @@ namespace Mono.Addins.Database } } - IAssemblyReflector GetReflector (IProgressStatus monitor, AddinScanResult scanResult, string filePath) + IAssemblyReflector GetReflector (IProgressStatus monitor, IAssemblyLocator locator, string filePath) { - IAssemblyReflector reflector = fs.GetReflectorForFile (scanResult, filePath); + IAssemblyReflector reflector = database.FileSystem.GetReflectorForFile (locator, filePath); object coreAssembly; if (!coreAssemblies.TryGetValue (reflector, out coreAssembly)) { if (monitor.LogLevel > 1) @@ -560,14 +356,14 @@ namespace Mono.Addins.Database return reflector; } - bool ScanAssembly (IProgressStatus monitor, string filePath, AddinScanResult scanResult, out AddinDescription config) + public bool ScanAssembly (IProgressStatus monitor, string filePath, ScanContext scanContext, out AddinDescription config) { config = null; IAssemblyReflector reflector = null; object asm = null; try { - reflector = GetReflector (monitor, scanResult, filePath); + reflector = GetReflector (monitor, assemblyLocator, filePath); asm = reflector.LoadAssembly (filePath); if (asm == null) throw new Exception ("Could not load assembly: " + filePath); @@ -597,7 +393,7 @@ namespace Mono.Addins.Database if (!config.MainModule.Assemblies.Contains (rasmFile)) config.MainModule.Assemblies.Add (rasmFile); - bool res = ScanDescription (monitor, reflector, config, asm, scanResult); + bool res = ScanDescription (monitor, reflector, config, asm, scanContext); if (!res) reflector.UnloadAssembly (asm); return res; @@ -615,7 +411,7 @@ namespace Mono.Addins.Database { config = null; foreach (string res in reflector.GetResourceNames (asm)) { - if (res.EndsWith (".addin") || res.EndsWith (".addin.xml")) { + if (res.EndsWith (".addin", StringComparison.Ordinal) || res.EndsWith (".addin.xml", StringComparison.Ordinal)) { using (Stream s = reflector.GetResourceStream (asm, res)) { AddinDescription ad = AddinDescription.Read (s, Path.GetDirectoryName (filePath)); if (config != null) { @@ -634,7 +430,7 @@ namespace Mono.Addins.Database return true; } - bool ScanDescription (IProgressStatus monitor, IAssemblyReflector reflector, AddinDescription config, object rootAssembly, AddinScanResult scanResult) + bool ScanDescription (IProgressStatus monitor, IAssemblyReflector reflector, AddinDescription config, object rootAssembly, ScanContext scanContext) { // First of all scan the main module @@ -644,7 +440,7 @@ namespace Mono.Addins.Database string rootAsmFile = null; if (rootAssembly != null) { - ScanAssemblyAddinHeaders (reflector, config, rootAssembly, scanResult); + ScanAssemblyAddinHeaders (reflector, config, rootAssembly); ScanAssemblyImports (reflector, config.MainModule, rootAssembly); assemblies.Add (rootAssembly); rootAsmFile = Path.GetFileName (config.AddinFile); @@ -655,12 +451,12 @@ namespace Mono.Addins.Database for (int n=0; n<config.MainModule.Assemblies.Count; n++) { string s = config.MainModule.Assemblies [n]; string asmFile = Path.GetFullPath (Path.Combine (config.BasePath, Util.NormalizePath (s))); - scanResult.AddPathToIgnore (asmFile); + scanContext.AddPathToIgnore (asmFile); if (s == rootAsmFile || config.MainModule.IgnorePaths.Contains (s)) continue; object asm = reflector.LoadAssembly (asmFile); assemblies.Add (asm); - ScanAssemblyAddinHeaders (reflector, config, asm, scanResult); + ScanAssemblyAddinHeaders (reflector, config, asm); ScanAssemblyImports (reflector, config.MainModule, asm); } @@ -668,24 +464,20 @@ namespace Mono.Addins.Database // which are included as 'data' in an add-in. foreach (string df in config.MainModule.DataFiles) { string file = Path.Combine (config.BasePath, Util.NormalizePath (df)); - scanResult.AddPathToIgnore (Path.GetFullPath (file)); + scanContext.AddPathToIgnore (Path.GetFullPath (file)); } foreach (string df in config.MainModule.IgnorePaths) { string path = Path.Combine (config.BasePath, Util.NormalizePath (df)); - scanResult.AddPathToIgnore (Path.GetFullPath (path)); + scanContext.AddPathToIgnore (Path.GetFullPath (path)); } // The add-in id and version must be already assigned at this point - // Clean host data from the index. New data will be added. - if (scanResult.HostIndex != null) - scanResult.HostIndex.RemoveHostData (config.AddinId, config.AddinFile); - foreach (object asm in assemblies) - ScanAssemblyContents (reflector, config, config.MainModule, asm, scanResult); + ScanAssemblyContents (reflector, config, config.MainModule, asm); } catch (Exception ex) { - ReportReflectionException (monitor, ex, config, scanResult); + ReportReflectionException (monitor, ex, config); return false; } @@ -715,25 +507,25 @@ namespace Mono.Addins.Database string asmFile = Path.Combine (config.BasePath, Util.NormalizePath (s)); object asm = reflector.LoadAssembly (asmFile); asmList.Add (new Tuple<string,object> (asmFile,asm)); - scanResult.AddPathToIgnore (Path.GetFullPath (asmFile)); + scanContext.AddPathToIgnore (Path.GetFullPath (asmFile)); ScanAssemblyImports (reflector, mod, asm); } // Add all data files to the ignore file list. It avoids scanning assemblies // which are included as 'data' in an add-in. foreach (string df in mod.DataFiles) { string file = Path.Combine (config.BasePath, Util.NormalizePath (df)); - scanResult.AddPathToIgnore (Path.GetFullPath (file)); + scanContext.AddPathToIgnore (Path.GetFullPath (file)); } foreach (string df in mod.IgnorePaths) { string path = Path.Combine (config.BasePath, Util.NormalizePath (df)); - scanResult.AddPathToIgnore (Path.GetFullPath (path)); + scanContext.AddPathToIgnore (Path.GetFullPath (path)); } foreach (var asm in asmList) - ScanSubmodule (monitor, mod, reflector, config, scanResult, asm.Item1, asm.Item2); + ScanSubmodule (monitor, mod, reflector, config, asm.Item1, asm.Item2); } catch (Exception ex) { - ReportReflectionException (monitor, ex, config, scanResult); + ReportReflectionException (monitor, ex, config); } } } @@ -742,7 +534,7 @@ namespace Mono.Addins.Database return true; } - bool ScanSubmodule (IProgressStatus monitor, ModuleDescription mod, IAssemblyReflector reflector, AddinDescription config, AddinScanResult scanResult, string assemblyName, object asm) + bool ScanSubmodule (IProgressStatus monitor, ModuleDescription mod, IAssemblyReflector reflector, AddinDescription config, string assemblyName, object asm) { AddinDescription mconfig; ScanEmbeddedDescription (monitor, assemblyName, reflector, asm, out mconfig); @@ -769,13 +561,12 @@ namespace Mono.Addins.Database } mod.MergeWith (mconfig.MainModule); } - ScanAssemblyContents (reflector, config, mod, asm, scanResult); + ScanAssemblyContents (reflector, config, mod, asm); return true; } - void ReportReflectionException (IProgressStatus monitor, Exception ex, AddinDescription config, AddinScanResult scanResult) + void ReportReflectionException (IProgressStatus monitor, Exception ex, AddinDescription config) { - scanResult.AddFileToWithFailure (config.AddinFile); monitor.ReportWarning ("[" + config.AddinId + "] Could not load some add-in assemblies: " + ex.Message); if (monitor.LogLevel <= 1) return; @@ -787,7 +578,7 @@ namespace Mono.Addins.Database } } - void ScanAssemblyAddinHeaders (IAssemblyReflector reflector, AddinDescription config, object asm, AddinScanResult scanResult) + void ScanAssemblyAddinHeaders (IAssemblyReflector reflector, AddinDescription config, object asm) { // Get basic add-in information AddinAttribute att = (AddinAttribute) reflector.GetCustomAttribute (asm, typeof(AddinAttribute), false); @@ -916,7 +707,7 @@ namespace Mono.Addins.Database } } - void ScanAssemblyContents (IAssemblyReflector reflector, AddinDescription config, ModuleDescription module, object asm, AddinScanResult scanResult) + void ScanAssemblyContents (IAssemblyReflector reflector, AddinDescription config, ModuleDescription module, object asm) { bool isMainModule = module == config.MainModule; @@ -1303,14 +1094,9 @@ namespace Mono.Addins.Database elem.SetAttribute ("insertbefore", eatt.InsertBefore); } - internal string GetDefaultTypeExtensionPath (AddinDescription desc, string typeFullName) + string GetDefaultTypeExtensionPath (AddinDescription desc, string typeFullName) { return "/" + Addin.GetIdName (desc.AddinId) + "/TypeExtensions/" + typeFullName; } - - internal void CleanupReflector() - { - fs.CleanupReflector (); - } } } |