public void SetUp() { mockTask = Substitute.For <ICancelable>(); mockPlatformFileSpec = Substitute.For <SbFileSpec>(); mockPlatformFileSpec.GetDirectory().Returns(PLATFORM_DIRECTORY); mockPlatformFileSpec.GetFilename().Returns(BINARY_FILENAME); fakeModuleFileLoadRecorder = new FakeModuleFileLoadRecorder(); mockSymbolLoader = Substitute.For <ISymbolLoader>(); mockSymbolLoader .LoadSymbolsAsync(Arg.Any <SbModule>(), Arg.Any <TextWriter>(), Arg.Any <bool>()) .Returns(Task.FromResult(false)); mockBinaryLoader = Substitute.For <IBinaryLoader>(); var anyModule = Arg.Any <SbModule>(); mockBinaryLoader .LoadBinaryAsync(anyModule, Arg.Any <TextWriter>()) .Returns((anyModule, false)); mockModuleSearchLogHolder = new ModuleSearchLogHolder(); moduleFileLoader = new ModuleFileLoader(mockSymbolLoader, mockBinaryLoader, mockModuleSearchLogHolder); }
public async Task <int> LoadModuleFilesAsync( IList <SbModule> modules, SymbolInclusionSettings symbolSettings, bool useSymbolStores, ICancelable task, IModuleFileLoadMetricsRecorder moduleFileLoadRecorder) { if (modules == null) { throw new ArgumentNullException(nameof(modules)); } if (task == null) { throw new ArgumentNullException(nameof(task)); } if (moduleFileLoadRecorder == null) { throw new ArgumentNullException(nameof(moduleFileLoadRecorder)); } // Add some metrics to the event proto before attempting to load symbols, so that they // are still recorded if the task is aborted or cancelled. moduleFileLoadRecorder.RecordBeforeLoad(modules); int result = VSConstants.S_OK; for (int i = 0; i < modules.Count; ++i) { SbModule module = modules[i]; TextWriter searchLog = new StringWriter(); string name = module.GetPlatformFileSpec()?.GetFilename() ?? "<unknown>"; try { task.ThrowIfCancellationRequested(); if (SkipModule(name, symbolSettings)) { await searchLog.WriteLineAsync( SymbolInclusionSettings.ModuleExcludedMessage); continue; } task.Progress.Report($"Loading binary for {name} ({i}/{modules.Count})"); (SbModule newModule, bool ok) = await _binaryLoader.LoadBinaryAsync(module, searchLog); if (!ok) { result = VSConstants.E_FAIL; continue; } module = newModule; task.ThrowIfCancellationRequested(); task.Progress.Report($"Loading symbols for {name} ({i}/{modules.Count})"); var loaded = await _symbolLoader.LoadSymbolsAsync(module, searchLog, useSymbolStores); if (!loaded) { result = VSConstants.E_FAIL; continue; } } finally { _moduleSearchLogHolder.SetSearchLog(module, searchLog.ToString()); modules[i] = module; } } moduleFileLoadRecorder.RecordAfterLoad(modules); return(result); }