/// <summary> /// Get the failure message from the LogFile.txt file /// </summary> /// <returns></returns> public string GetFailureMessage() { string file = getResultDirectory() + "\\LogFile.txt"; DiagnosticLog.WriteLine("Getting failure reason from file : " + file); string line; string previous = ""; using (var reader = new StreamReader(file)) { line = reader.ReadLine(); while (line != null) { if (line.Contains("Error")) { var error = new StringBuilder(); error.AppendLine(previous); error.AppendLine(line); error.AppendLine(reader.ReadToEnd()); return(error.ToString()); } previous = line; line = reader.ReadLine(); } return(""); } }
public static void WebOp(string webUrl, Action <SPWeb> op) { SiteOp(webUrl, site => { using (SPWeb web = site.OpenWeb()) { bool auuOrig = false; try { auuOrig = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; op(web); } catch (Exception ex) { DiagnosticLog.Error(op.Method.Name, ex + (ex.InnerException != null ? "::" + ex.InnerException : string.Empty)); throw; } finally { web.AllowUnsafeUpdates = auuOrig; } } }); }
/// <summary> /// Verify the script that ran was successful. Load the results files and parse them for errors. /// </summary> private void VerifySuccess() { DiagnosticLog.WriteLine("Verifying Test : " + scriptName); var resultsFile = new XmlDocument(); string file = getResultDirectory() + "\\LogFile.xml"; DiagnosticLog.WriteLine("Checking results file : " + file); resultsFile.Load(file); string result = resultsFile.SelectSingleNode("//property[@name='Status']/@value").Value; if (result != "Success") { DiagnosticLog.WriteLine("Test Failure Detected : " + scriptName); TestContext.CurrentContext.IncrementAssertCount(); TestLog.Failures.BeginSection("EggPlant Error"); TestLog.Failures.WriteLine(GetFailureMessage()); if (File.Exists(getResultDirectory() + "\\Screen_Error.png")) { TestLog.Failures.EmbedImage(null, Common.ScaleImage(Image.FromFile(getResultDirectory() + "\\Screen_Error.png"))); } TestLog.Failures.End(); Assert.TerminateSilently(TestOutcome.Failed); } }
public static void Put <T>(string key, T value, TimeSpan timeSpan) { try { if (Equals(value, default(T))) { return; } DiagnosticLog.Info("CacheManager.Put", typeof(T).ToString()); if (Equals(Get <T>(key), default(T))) { DefaultCache.Add(key, value, timeSpan); } else { DefaultCache.Remove(key); DefaultCache.Put(key, value, timeSpan); } } catch (Exception dce) { DiagnosticLog.Error("CacheManager.Put", dce.ToString()); } }
private ProjectFileInfo( bool isEmpty, string language, string?filePath, string?outputFilePath, string?outputRefFilePath, string?defaultNamespace, string?targetFramework, ImmutableArray <string> commandLineArgs, ImmutableArray <DocumentFileInfo> documents, ImmutableArray <DocumentFileInfo> additionalDocuments, ImmutableArray <DocumentFileInfo> analyzerConfigDocuments, ImmutableArray <ProjectFileReference> projectReferences, DiagnosticLog log ) { RoslynDebug.Assert(filePath != null); this.IsEmpty = isEmpty; this.Language = language; this.FilePath = filePath; this.OutputFilePath = outputFilePath; this.OutputRefFilePath = outputRefFilePath; this.DefaultNamespace = defaultNamespace; this.TargetFramework = targetFramework; this.CommandLineArgs = commandLineArgs; this.Documents = documents; this.AdditionalDocuments = additionalDocuments; this.AnalyzerConfigDocuments = analyzerConfigDocuments; this.ProjectReferences = projectReferences; this.Log = log; }
public void StartFiddler() { Common.Log("Starting Fiddler Proxy on port " + proxyPort); string sSAZInfo = "NoSAZ"; if (!FiddlerApplication.oTranscoders.ImportTranscoders(Assembly.GetExecutingAssembly())) { DiagnosticLog.WriteLine("This assembly was not compiled with a SAZ-exporter"); } else { sSAZInfo = SAZFormat.GetZipLibraryInfo(); } CONFIG.IgnoreServerCertErrors = true; FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true); FiddlerCoreStartupFlags oFCSF = (FiddlerCoreStartupFlags.AllowRemoteClients | FiddlerCoreStartupFlags.DecryptSSL | FiddlerCoreStartupFlags.MonitorAllConnections | // FiddlerCoreStartupFlags.RegisterAsSystemProxy | FiddlerCoreStartupFlags.ChainToUpstreamGateway | FiddlerCoreStartupFlags.CaptureLocalhostTraffic); FiddlerApplication.Startup(proxyPort, false, true, true); oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname); }
public static ProjectFileInfo Create( string language, string filePath, string outputFilePath, string outputRefFilePath, string defaultNamespace, string targetFramework, ImmutableArray <string> commandLineArgs, ImmutableArray <DocumentFileInfo> documents, ImmutableArray <DocumentFileInfo> additionalDocuments, ImmutableArray <DocumentFileInfo> analyzerConfigDocuments, ImmutableArray <ProjectFileReference> projectReferences, DiagnosticLog log) => new ProjectFileInfo( isEmpty: false, language, filePath, outputFilePath, outputRefFilePath, defaultNamespace, targetFramework, commandLineArgs, documents, additionalDocuments, analyzerConfigDocuments, projectReferences, log);
private void ConnectToTarget() { DiagnosticLog.Information("Connecting to FFX..."); try { Game = Process.GetProcessesByName(TARGET_NAME).OrderByDescending(x => x.StartTime) .FirstOrDefault(x => !x.HasExited); } catch (Win32Exception e) { DiagnosticLog.Information("Exception: " + e.Message); } if (Game == null || Game.HasExited) { Game = null; DiagnosticLog.Information("FFX not found! Waiting for 10 seconds."); Thread.Sleep(10 * 1000); } else { DiagnosticLog.Information("Connected to FFX!"); } }
private async Task <MSB.Execution.ProjectInstance> BuildProjectAsync( MSB.Evaluation.Project project, string[] targets, DiagnosticLog log, CancellationToken cancellationToken) { // create a project instance to be executed by build engine. // The executed project will hold the final model of the project after execution via msbuild. var projectInstance = project.CreateProjectInstance(); // Verify targets foreach (var target in targets) { if (!projectInstance.Targets.ContainsKey(target)) { log.Add(string.Format(WorkspaceMSBuildResources.Project_does_not_contain_0_target, target), projectInstance.FullPath); return(projectInstance); } } _batchBuildLogger?.SetProjectAndLog(projectInstance.FullPath, log); var buildRequestData = new MSB.Execution.BuildRequestData(projectInstance, targets); var result = await BuildAsync(buildRequestData, cancellationToken).ConfigureAwait(false); if (result.OverallResult == MSB.Execution.BuildResultCode.Failure) { if (result.Exception != null) { log.Add(result.Exception, projectInstance.FullPath); } } return(projectInstance); }
private static async Task <(MSB.Evaluation.Project?project, DiagnosticLog log)> LoadProjectAsync( string path, MSB.Evaluation.ProjectCollection?projectCollection, CancellationToken cancellationToken) { var log = new DiagnosticLog(); try { var loadedProjects = projectCollection?.GetLoadedProjects(path); if (loadedProjects != null && loadedProjects.Count > 0) { Debug.Assert(loadedProjects.Count == 1); return(loadedProjects.First(), log); } using var stream = FileUtilities.OpenAsyncRead(path); using var readStream = await SerializableBytes.CreateReadableStreamAsync(stream, cancellationToken).ConfigureAwait(false); using var xmlReader = XmlReader.Create(readStream, s_xmlReaderSettings); var xml = MSB.Construction.ProjectRootElement.Create(xmlReader, projectCollection); // When constructing a project from an XmlReader, MSBuild cannot determine the project file path. Setting the // path explicitly is necessary so that the reserved properties like $(MSBuildProjectDirectory) will work. xml.FullPath = path; var project = new MSB.Evaluation.Project(xml, globalProperties: null, toolsVersion: null, projectCollection); return(project, log); } catch (Exception e) { log.Add(e, path); return(project : null, log); } }
public void Report(DiagnosticLog log) { foreach (var logItem in log) { Report(DiagnosticReportingMode.Log, GetMSBuildFailedMessage(logItem.ProjectFilePath, logItem.ToString())); } }
public static Process ExecuteDosCommand(string command, bool waitToFinish = true) { DiagnosticLog.WriteLine("Executing DOS Command: " + command); var CMDprocess = new Process(); var StartInfo = new ProcessStartInfo(); StartInfo.FileName = "cmd"; //starts cmd window StartInfo.Arguments = "/c \"" + command + "\""; //StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // StartInfo.CreateNoWindow = true; StartInfo.RedirectStandardInput = true; StartInfo.RedirectStandardOutput = true; StartInfo.UseShellExecute = false; //required to redirect CMDprocess.StartInfo = StartInfo; CMDprocess.Start(); var SR = CMDprocess.StandardOutput; var SW = CMDprocess.StandardInput; CMDprocess.Start(); var line = ""; while ((line != null) && (waitToFinish)) { line = SR.ReadLine(); DiagnosticLog.WriteLine(line); } SW.Close(); SR.Close(); return(CMDprocess); }
//[Test] public void TestScreenRectangle() { ConnectToHost1(); var rect = Driver.GetScreenRectangle(); DiagnosticLog.WriteLine("The rect is : " + rect.width + " x " + rect.height); }
private static async Task <(ErgonProject project, DiagnosticLog log)> LoadProjectAsync( string path, ErgonProjectCollection projectCollection, CancellationToken cancellationToken) { var log = new DiagnosticLog(); try { var loadedProjects = projectCollection.GetLoadedProjects(path); if (loadedProjects != null && loadedProjects.Count > 0) { Debug.Assert(loadedProjects.Count == 1); return(loadedProjects.First(), log); } using (var stream = FileUtilities.OpenAsyncRead(path)) using (var readStream = await SerializableBytes.CreateReadableStreamAsync(stream, cancellationToken).ConfigureAwait(false)) using (var reader = new StreamReader(readStream)) { var project = ErgonProject.FromString(await reader.ReadToEndAsync(), path); projectCollection.Add(project); // todo: assign project.path = path return(project, log); } } catch (Exception e) { log.Add(e, path); return(project : null, log); } }
public async Task <(MSB.Evaluation.Project project, DiagnosticLog log)> LoadProjectAsync( string path, IDictionary <string, string> globalProperties, CancellationToken cancellationToken) { var log = new DiagnosticLog(); try { var projectCollection = _projectCollection ?? new MSB.Evaluation.ProjectCollection(s_defaultGlobalProperties); var project = FindProject(path, globalProperties, projectCollection, cancellationToken); if (project == null) { using (var stream = FileUtilities.OpenAsyncRead(path)) using (var readStream = await SerializableBytes.CreateReadableStreamAsync(stream, cancellationToken).ConfigureAwait(false)) using (var xmlReader = XmlReader.Create(readStream, s_xmlReaderSettings)) { var xml = MSB.Construction.ProjectRootElement.Create(xmlReader, projectCollection); // When constructing a project from an XmlReader, MSBuild cannot determine the project file path. Setting the // path explicitly is necessary so that the reserved properties like $(MSBuildProjectDirectory) will work. xml.FullPath = path; project = new MSB.Evaluation.Project(xml, globalProperties, toolsVersion: null, projectCollection); } } return(project, log); } catch (Exception e) { log.Add(e, path); return(project : null, log); } }
//[Test] public void TestConnectionInfo() { ConnectToHost1(); var info = Driver.GetConnectionInfo(); DiagnosticLog.WriteLine(info); }
protected override ProjectFile CreateProjectFile( MSB.Evaluation.Project?project, ProjectBuildManager buildManager, DiagnosticLog log ) { return(new VisualBasicProjectFile(this, project, buildManager, log)); }
public CSharpProjectFile( CSharpProjectFileLoader loader, MSB.Evaluation.Project?project, ProjectBuildManager buildManager, DiagnosticLog log ) : base(loader, project, buildManager, log) { }
public static void Log(string message) { var msg = "(" + DateTime.Now.ToString("HH:mm:ss::ffff") + ") : " + message; DiagnosticLog.WriteLine(msg); TestLog.WriteLine(msg); overlay.Text = msg; }
public VisualBasicProjectFile( VisualBasicProjectFileLoader loader, MSB.Evaluation.Project?loadedProject, ProjectBuildManager buildManager, DiagnosticLog log ) : base(loader, loadedProject, buildManager, log) { }
/// <summary> /// Deletes all files in the results directory for the suitePath parameter /// </summary> /// <param name="suitePath"></param> public static void DeleteResultsDirectory(string suitePath) { if (Directory.Exists(suitePath + "\\Results")) { DiagnosticLog.WriteLine("Old results found, deleting Eggplant results directory"); Directory.Delete(suitePath + "\\Results", true); } }
public void Test() { using (TestLog.BeginSection("Section *\n*")) { TestLog.WriteLine("Text *\0* Content"); } DiagnosticLog.WriteLine("Diagnostic *\0* Log"); }
public Task <MSB.Execution.ProjectInstance> BuildProjectAsync( MSB.Evaluation.Project project, DiagnosticLog log, CancellationToken cancellationToken) { Debug.Assert(_batchBuildStarted); var targets = new[] { TargetNames.Compile, TargetNames.CoreCompile }; return(BuildProjectAsync(project, targets, log, cancellationToken)); }
public void ForgetfulStreaming() { bool bForgetful = !FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.ForgetStreamedData", false); FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", bForgetful); DiagnosticLog.WriteLine(bForgetful ? "FiddlerCore will immediately dump streaming response data." : "FiddlerCore will keep a copy of streamed response data."); }
protected ProjectFile(ProjectFileLoader loader, MSB.Evaluation.Project?loadedProject, ProjectBuildManager buildManager, DiagnosticLog log) { _loader = loader; _loadedProject = loadedProject; _buildManager = buildManager; var directory = loadedProject?.DirectoryPath ?? string.Empty; _projectDirectory = PathUtilities.EnsureTrailingSeparator(directory); Log = log; }
private static void LogError(string message) { //if (Config.LogStepsDiagnosticOutput) //{ DiagnosticLog.WriteLine(message); //} //if (Config.LogStepsTestReport) //{ TestLog.WriteHighlighted(message + "\r\n"); //} }
public static void Remove(string key) { try { DiagnosticLog.Info("CacheManager.Remove", key); DefaultCache.Remove(key); } catch (Exception dce) { DiagnosticLog.Error("CacheManager.Remove", dce.ToString()); } }
protected ProjectFile(ProjectFileLoader loader, MSB.Evaluation.Project loadedProject, ProjectBuildManager buildManager, DiagnosticLog log) { _loader = loader; _loadedProject = loadedProject; _buildManager = buildManager; _projectDirectory = loadedProject != null ? PathUtilities.EnsureTrailingSeparator(loadedProject.DirectoryPath) : null; Log = log; }
private static void OnReturn() { DateTime now = DateTime.Now; if (now > nextSample) { nextSample = now.AddSeconds(5); DiagnosticLog.WriteLine( "Memoizer<{0}>: Hits = {1}, Misses = {2}", typeof(T).Name, hits, misses); } }
private static void OnReturn() { DateTime now = DateTime.Now; if (now > nextSample) { nextSample = now.AddSeconds(5); DiagnosticLog.WriteLine( "KeyedMemoizer<{0}, {1}>: # Small = {2}, # Large = {3}, Max Size = {4}, Hits = {5}, Misses = {6}", typeof(TKey).Name, typeof(TValue).Name, numSmallCaches, numLargeCaches, maxSize, hits, misses); } }