private void ProjectStarted(object sender, ProjectStartedEventArgs e) { // If we're not using an analyzer (I.e., from a binary log) and this is the first project file path we've seen, then it's the primary if (_projectFilePath == null) { _projectFilePath = AnalyzerManager.NormalizePath(e.ProjectFile); } // Make sure this is the same project, nested MSBuild tasks may have spawned additional builds of other projects if (AnalyzerManager.NormalizePath(e.ProjectFile) == _projectFilePath) { // Get the TFM for this project string tfm = e.Properties?.Cast <DictionaryEntry>() .FirstOrDefault(x => string.Equals(x.Key.ToString(), "TargetFrameworkMoniker", StringComparison.OrdinalIgnoreCase)).Value as string; if (!string.IsNullOrWhiteSpace(tfm)) { if (!_results.TryGetValue(tfm, out AnalyzerResult result)) { result = new AnalyzerResult(_projectFilePath, _manager, _analyzer); _results[tfm] = result; } result.ProcessProject(e); _currentResult.Push(result); return; } // Push a null result so the stack is balanced on project finish _currentResult.Push(null); } }
public void CanParseInstalledSdksPath(string output, string sdksPath) { // Given List <string> lines = output.Split("\n").Select(x => x.Trim('\r')).ToList(); // When string result = DotnetPathResolver.ParseInstalledSdksPath(lines); // Then AnalyzerManager.NormalizePath(result).ShouldBe(AnalyzerManager.NormalizePath(sdksPath)); }
private void ProjectFinished(object sender, ProjectFinishedEventArgs e) { // Make sure this is the same project, nested MSBuild tasks may have spawned additional builds of other projects if (AnalyzerManager.NormalizePath(e.ProjectFile) == _projectFilePath) { AnalyzerResult result = _currentResult.Pop(); if (result != null) { result.Succeeded = e.Succeeded; } } }
private void ProjectVisitor(Project project, Dictionary <string, TreeNode> projects) { // Make sure this is the same project, nested MSBuild tasks may have spawned additional builds of other projects if (AnalyzerManager.NormalizePath(project.ProjectFile) != _projectFilePath) { return; } // Get the TFM for this project string tfm = project.GetProperty("TargetFrameworkMoniker"); if (!string.IsNullOrWhiteSpace(tfm)) { // Add this project to the tree for this TFM TreeNode tree = null; if (!projects.TryGetValue(tfm, out tree)) { tree = new NamedNode(); projects.Add(tfm, tree); } tree.AddChild(project); } }