/// <summary> /// Parse command line options and returns an ILGarbageCollector object on sucess. /// On error, this method prints help information and returns null /// </summary> /// <param name="args">The array of command line arguments</param> /// <returns>On success: a populated ILGarbageCollector. On failure: null.</returns> private static ILGarbageCollectorOptions ParseOptions(string[] args) { var options = new ILGarbageCollectorOptions(); options.Parse(args); if (options.HelpRequested) { options.PrintOptions(""); return null; } if (options.HasErrors) { options.PrintErrorsAndExit(Console.Out); return null; } return options; }
private static ISet <IAssembly> GetRootAssembliesFromOptions(ILGarbageCollectorOptions options, IMetadataReaderHost host) { ISet <IAssembly> rootAssemblies = new HashSet <IAssembly>(); foreach (var pathToAssembly in GetRootAssemblyPathsFromOptions(options)) { var assembly = host.LoadUnitFrom(pathToAssembly) as IAssembly; if (assembly == null) { throw new FileNotFoundException("Couldn't load assembly " + pathToAssembly); } rootAssemblies.Add(assembly); } return(rootAssemblies); }
private static MetadataReaderHost GetHostFromOptions(ILGarbageCollectorOptions options) { MetadataReaderHost host; switch (options.profile) { case TargetProfile.Phone: host = new PhoneMetadataHost(GetRootAssemblyParentDirectoriesFromOptions(options)); break; default: host = new PeReader.DefaultHost(); break; } return(host); }
/// <summary> /// Parse command line options and returns an ILGarbageCollector object on sucess. /// On error, this method prints help information and returns null /// </summary> /// <param name="args">The array of command line arguments</param> /// <returns>On success: a populated ILGarbageCollector. On failure: null.</returns> private static ILGarbageCollectorOptions ParseOptions(string[] args) { var options = new ILGarbageCollectorOptions(); options.Parse(args); if (options.HelpRequested) { options.PrintOptions(""); return(null); } if (options.HasErrors) { options.PrintErrorsAndExit(Console.Out); return(null); } return(options); }
private static IEnumerable <IMethodReference> GetEntryPointsFromOptions(ILGarbageCollectorOptions options, WholeProgram wholeProgram) { ISet <IEntryPointDetector> entryPointDetectors = new HashSet <IEntryPointDetector>(); bool ignoreMainEntryPoints = false; if (options.entrypoints != null) { entryPointDetectors.Add(new DocCommentFileEntryPointDetector(options.entrypoints)); ignoreMainEntryPoints = true; } if (options.entryattributes != null) { entryPointDetectors.Add(new AttributeFileEntryPointDetector(options.entryattributes)); } // If no entrypoints were directly specified are used, we'll just get the entry points // from the main assemblies. if (!ignoreMainEntryPoints) { entryPointDetectors.Add(new RootAssembliesEntryPointDetector()); } ISet <IMethodReference> entryPoints = new HashSet <IMethodReference>(); foreach (IEntryPointDetector entryPointDetector in entryPointDetectors) { entryPoints.UnionWith(entryPointDetector.GetEntryPoints(wholeProgram)); } if (entryPoints.Count() == 0) { Console.WriteLine("Error: Could not find any entry points."); System.Environment.Exit(-1); } return(entryPoints); }
private static IEnumerable<IMethodSummarizer> GetReflectionSummarizersFromOptions(ILGarbageCollectorOptions options, WholeProgram wholeProgram) { ISet<IMethodSummarizer> summarizers = DefaultReflectionSummarizers(); string textSummariesPath = options.summaries; if (textSummariesPath != null) { TextFileMethodSummarizer textFileSummarizer = TextFileMethodSummarizer.CreateSummarizerFromPath(textSummariesPath, wholeProgram); summarizers.Add(textFileSummarizer); } return summarizers; }
private static IEnumerable<IMethodReference> GetEntryPointsFromOptions(ILGarbageCollectorOptions options, WholeProgram wholeProgram) { ISet<IEntryPointDetector> entryPointDetectors = new HashSet<IEntryPointDetector>(); bool ignoreMainEntryPoints = false; if (options.entrypoints != null) { entryPointDetectors.Add(new DocCommentFileEntryPointDetector(options.entrypoints)); ignoreMainEntryPoints = true; } if (options.entryattributes != null) { entryPointDetectors.Add(new AttributeFileEntryPointDetector(options.entryattributes)); } // If no entrypoints were directly specified are used, we'll just get the entry points // from the main assemblies. if (!ignoreMainEntryPoints) { entryPointDetectors.Add(new RootAssembliesEntryPointDetector()); } ISet<IMethodReference> entryPoints = new HashSet<IMethodReference>(); foreach (IEntryPointDetector entryPointDetector in entryPointDetectors) { entryPoints.UnionWith(entryPointDetector.GetEntryPoints(wholeProgram)); } if (entryPoints.Count() == 0) { Console.WriteLine("Error: Could not find any entry points."); System.Environment.Exit(-1); } return entryPoints; }
private static ISet<IAssembly> GetRootAssembliesFromOptions(ILGarbageCollectorOptions options, IMetadataReaderHost host) { ISet<IAssembly> rootAssemblies = new HashSet<IAssembly>(); foreach (var pathToAssembly in GetRootAssemblyPathsFromOptions(options)) { var assembly = host.LoadUnitFrom(pathToAssembly) as IAssembly; if (assembly == null) { throw new FileNotFoundException("Couldn't load assembly " + pathToAssembly); } rootAssemblies.Add(assembly); } return rootAssemblies; }
private static ISet<string> GetRootAssemblyParentDirectoriesFromOptions(ILGarbageCollectorOptions options) { return new HashSet<string>(GetRootAssemblyPathsFromOptions(options).Select(assemblyPath => Path.GetDirectoryName(assemblyPath))); }
private static ISet<string> GetRootAssemblyPathsFromOptions(ILGarbageCollectorOptions options) { return new HashSet<string>(options.GeneralArguments); }
private static MetadataReaderHost GetHostFromOptions(ILGarbageCollectorOptions options) { MetadataReaderHost host; switch (options.profile) { case TargetProfile.Phone: host = new PhoneMetadataHost(GetRootAssemblyParentDirectoriesFromOptions(options)); break; default: host = new PeReader.DefaultHost(); break; } return host; }
private static IEnumerable <IMethodSummarizer> GetReflectionSummarizersFromOptions(ILGarbageCollectorOptions options, WholeProgram wholeProgram) { ISet <IMethodSummarizer> summarizers = DefaultReflectionSummarizers(); string textSummariesPath = options.summaries; if (textSummariesPath != null) { TextFileMethodSummarizer textFileSummarizer = TextFileMethodSummarizer.CreateSummarizerFromPath(textSummariesPath, wholeProgram); summarizers.Add(textFileSummarizer); } return(summarizers); }
private static ISet <string> GetRootAssemblyParentDirectoriesFromOptions(ILGarbageCollectorOptions options) { return(new HashSet <string>(GetRootAssemblyPathsFromOptions(options).Select(assemblyPath => Path.GetDirectoryName(assemblyPath)))); }
private static ISet <string> GetRootAssemblyPathsFromOptions(ILGarbageCollectorOptions options) { return(new HashSet <string>(options.GeneralArguments)); }