private static IEnumerable <T> Assmeble <T>(AssemblySource <YASM> assemblySource, Format format, Func <byte[], T> TConstructor) where T : ObjectFile, new() { List <T> objectFiles = new List <T>(); using (new TemporaryContext()) { foreach (var sourceFile in assemblySource.SourceFiles) { System.IO.File.WriteAllBytes(sourceFile.Filename, sourceFile.Bytes); } foreach (var sourceFile in assemblySource.SourceFiles.Where(sf => sf.Type == AssemblySourceFileType.Asm)) { var arguments = String.Format("-f {0} -o object.obj {1}", format.ToString(), sourceFile.Filename); Process.Start("yasm", arguments).WaitForExit(); if (!System.IO.File.Exists("object.obj")) { throw new Exception("yasm error. Object file not found."); } var objectFileBytes = System.IO.File.ReadAllBytes("object.obj"); objectFiles.Add(TConstructor(objectFileBytes)); } } return(objectFiles); }
public static ILoggingBuilder AddFluentMigratorFileLogger( this ILoggingBuilder loggingBuilder, LogFileFluentMigratorLoggerOptions options, bool clearProviders = false) { if (clearProviders) { loggingBuilder.ClearProviders(); } var assembly = loggingBuilder.Services .GetFirstServiceDescriptor <IMigrationSourceItem>() .GetImplementation <IMigrationSourceItem>() ?.MigrationTypeCandidates?.FirstOrDefault()?.Assembly; var assemblySourceItem = assembly == null ? new AssemblySourceItem() : new AssemblySourceItem(assembly); var optionsManager = new OptionsManager <AssemblySourceOptions>( new OptionsFactory <AssemblySourceOptions>( Enumerable.Empty <IConfigureOptions <AssemblySourceOptions> >(), Enumerable.Empty <IPostConfigureOptions <AssemblySourceOptions> >())); var assemblySource = new AssemblySource(optionsManager, new List <IAssemblyLoadEngine>(), new[] { assemblySourceItem }); return(loggingBuilder.AddProvider(new LogFileFluentMigratorLoggerProvider(assemblySource, new OptionsWrapper <LogFileFluentMigratorLoggerOptions>(options)))); }
private IEnumerable <T> Assmeble <T>(AssemblySource <MASM> assemblySource, TargetArch targetArch, Func <byte[], T> TConstructor) where T : ObjectFile, new() { List <T> objectFiles = new List <T>(); using (new TemporaryContext()) { foreach (var sourceFile in assemblySource.SourceFiles) { System.IO.File.WriteAllBytes(sourceFile.Filename, sourceFile.Bytes); } foreach (var sourceFile in assemblySource.SourceFiles.Where(sf => sf.Type == AssemblySourceFileType.Asm)) { var program = targetArch == TargetArch.x64 ? "ml64.exe" : "ml.exe"; var arguments = String.Format("/nologo /Fo object.obj /c /Cx {0}", sourceFile.Filename); var assembleCommand = program + " " + arguments; var msvcVersion = version.ToString().Replace("v", "").Replace("_", "."); var assembleBatFile = @"call ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\VCVARSALL.bat"" {0} -vcvars_ver=" + msvcVersion + "\r\n" + assembleCommand; assembleBatFile = String.Format(assembleBatFile, targetArch.ToString()); File.WriteAllText("assemble.bat", assembleBatFile); var proc = Process.Start("cmd.exe", "/c " + "assemble.bat"); proc.WaitForExit(); if (!System.IO.File.Exists("object.obj")) { throw new Exception("Masm error. Object file not found."); } var objectFileBytes = System.IO.File.ReadAllBytes("object.obj"); objectFiles.Add(TConstructor(objectFileBytes)); } } return(objectFiles); }
public void Run(Options parameter, Action <Options> next) { var source = File.ReadAllText(parameter.Input); var parsed = AssemblySource.Parse(source); parameter.Tags.Add("AST", parsed); next(parameter); }
protected virtual Page CreatePage(object viewModel) { var viewModelType = viewModel.GetType(); var pageTypeName = viewModel is RootFrameNavigationViewModelBase ? BuildRootFrameNavigationPageTypeName(viewModelType.FullName) : BuildPageTypeName(viewModelType.FullName); var pageType = Type.GetType(pageTypeName) ?? AssemblySource.FindTypeByNames(new[] { pageTypeName }); return((Page)Activator.CreateInstance(pageType)); }
public async Task RunAsync() { _Log.Info("(+) => included references"); _Log.Info("(-) => ignored references"); _Log.Info("(~) => identified package rerferences"); _Log.Info(""); _Log.Info($"analyzing assemblies in"); foreach (var path in _Config.Assemblies.SourcePaths) { _Log.Info($" {path}"); } var folder = new AssemblySource(_Config.Assemblies.Sources, _Config.Assemblies.ExcludePatterns); var assemblies = await folder.GetAssembliesAsync(); var orderedByLeastReferences = assemblies.OrderBy(x => x.KnownReferences.Count()); _Log.Info(""); Echo(orderedByLeastReferences); _Log.Info(""); _Log.Info("deriving bundles / pacakges"); _Log.Info(""); var bundler = new Bundler(_Config); var bundles = bundler.GetBundles(orderedByLeastReferences); Echo(bundles); _Config.NuSpecDirectory.Create(); var writer = new NuSpecWriter(_Config); _Log.Info($"writing nuspec files to : {_Config.NuSpecDirectory}"); foreach (var bundle in bundles) { var target = new FileInfo(Path.Combine(_Config.NuSpecDirectory.FullName, $"{bundle.PackageFullName}.nuspec")); var nuspecContent = writer.GetNuSpec(bundle); _Log.Info($" {target.Name}"); File.WriteAllText(target.FullName, nuspecContent); } _Log.Info($"created {bundles.Count()} nuspec(s)"); }
public FakeDependencyResolverWpf() { _logger = new DebugLogger(); _container = new Dictionary <Type, object>(); var callingAssembly = Assembly.GetCallingAssembly(); var assemblySource = new AssemblySource(callingAssembly); _container.Add(typeof(ILogger), _logger); _container.Add(typeof(IViewLocator), new ViewLocator(this, assemblySource, _logger)); _container.Add(typeof(IViewModelBinder), new ViewModelBinder(_logger)); InitializeReactiveComponents(); }
private void LoadSourceButton_Click(object sender, EventArgs e) { StreamReader file; openFileDialog1.Filter = "Assembly Files (*.asm)|*.asm|All Files (*.*)|*.*"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { file = new StreamReader(openFileDialog1.FileName); AssemblySource.Clear(); while (!file.EndOfStream) { AssemblySource.AppendText(file.ReadLine() + "\r\n"); } file.Close(); } }
/// <summary> /// Loads assemblies according scanPatterns. /// </summary> /// <param name="scanDirectory">Directory to scan.</param> /// <param name="assemblyScanPatterns">Assembly wildcard scan patterns.</param> /// <returns>Assemblies.</returns> public static IEnumerable <Assembly> LoadAssemblies(string scanDirectory, params string[] assemblyScanPatterns) { List <string> messagesList = new List <string>(); AssemblySource assemblySource = new AssemblySource( loadFromDomain: true, loadFromDirectory: scanDirectory, searchPatterns: assemblyScanPatterns, assemblyFilters: new AssemblyFilters(assemblyScanPatterns)); IEnumerable <Assembly> assemblies = TypeLoader .LoadAssemblies(assemblySource, messagesList) .ToArrayDebug(); return(assemblies); }
// TODO YP: export to base, looks the same as Android impl. protected virtual Type GetTargetViewType(Type viewModelType) { if (_viewModelToViewMap.TryGetValue(viewModelType, out var targetViewType)) { return(targetViewType); } var targetTypeName = BuildViewTypeName(viewModelType); targetViewType = Type.GetType(targetTypeName) ! ?? AssemblySource.FindTypeByNames(new[] { targetTypeName }) !; if (targetViewType == null) { throw new InvalidOperationException($"Can't find target view type: {targetTypeName}"); } return(targetViewType); }
internal void UpdateAssemblies(AssemblySource assemblyLocation, string appFolder) { List <AssemblyInformation> asms; Logger.Debug(DebugString.Format(Messages.UpdatingAssembly, assemblyLocation)); if (assemblyLocation == AssemblySource.Core) { asms = InitializeCoreAssemblies(appFolder); } else { asms = InitializeAddInAssemblies(appFolder); } foreach (var asm in asms) { UpdateAppDataFolder(asm, appFolder); } }
private ConsoleColor SelectConsoleColor(AssemblySource assemblySource) { switch (assemblySource) { case AssemblySource.NotFound: return(AssemblyNotFoundColor); case AssemblySource.Local: return(AssemblyLocalColor); case AssemblySource.GlobalAssemblyCache: return(AssemblyGlobalAssemblyCacheColor); case AssemblySource.Unknown: return(AssemblyUnknownColor); default: throw new InvalidOperationException("Unknown AssemblySource value."); } }
StaticLibrary <Win64ObjectFile> IAssembler <MASM, Win64ObjectFile> .Assemble(AssemblySource <MASM> assemblySource) { return(new StaticLibrary <Win64ObjectFile>(Assmeble <Win64ObjectFile>(assemblySource, TargetArch.x64, x => new Win64ObjectFile(x)))); }
StaticLibrary <Win64ObjectFile> IAssembler <YASM, Win64ObjectFile> .Assemble(AssemblySource <YASM> assemblySource) { return(new StaticLibrary <Win64ObjectFile>(Assmeble <Win64ObjectFile>(assemblySource, Format.win64, x => new Win64ObjectFile(x)))); }
private bool UpdateNeeded() { return(_previousViewExtensionsAssemblies.Any(assembly => !AssemblySource.ContainsAssembly(assembly))); }
public void Run() { ReadLine.HistoryEnabled = true; ReadLine.AutoCompletionHandler = new AutoCompletionHandler(); bool ishexMode = false; while (true) { string prefix = ishexMode ? "hex" : "asm"; var input = ReadLine.Read(prefix + "> "); if (ReplCommand.IsCommand(input)) { var cmd = ReplCommand.Parse(input); switch (cmd.Name) { case "mode": var arg = cmd.Args.First(); if (arg == "asm") { ishexMode = false; } else if (arg == "hex") { ishexMode = true; } else { Console.WriteLine($"mode '{arg}' not recognized"); } break; case "register": Utils.PrintRegisters(vm.Register); break; case "clear": Console.Clear(); break; case "explain": if (cmd.Args.Length == 1) { var errorcodeStr = cmd.Args.First(); Console.WriteLine(ErrorTable.GetExplanation(int.Parse(errorcodeStr))); } else { Console.WriteLine("Please specifiy an errorcode"); } break; default: Console.WriteLine($"Command '{cmd.Name}' not found"); break; } } else { if (ishexMode) { var prog = ParseHex(input); var reader = new VmReader(prog, vm); vm.RunInstructionLine(reader); } else { var src = AssemblySource.Parse(input); var writer = new VmWriter(); foreach (var line in src.Lines) { writer.Write(line.Opcode); foreach (var operand in line.Operands) { writer.Write(operand); } } vm.Run(writer); vm.Register[Registers.IPR] = 0; } } } }
public override int GetHashCode() { return(AssemblySource.GetHashCode() | Type.GetHashCode() | hCode); }
public ReferencedAssembly(string name, AssemblySource source) { _name = name; _source = source; }
private void AssemblerNewButton_Click(object sender, EventArgs e) { AssemblySource.Clear(); }
private void AddReferences(AssemblySource targetAssembly, string[] additionalReferences) { targetAssembly.RegisteredReferences = targetAssembly.RegisteredReferences.Concat(additionalReferences).ToList(); }