private void OnSolutionBuilding()
{
var dte = this.serviceProvider.GetService(typeof(DTE)) as DTE;
string fullSolutionPath = dte.Solution?.FullName;
if (string.IsNullOrWhiteSpace(fullSolutionPath))
{
Debug.Fail("Solution expected since building...");
return;
}
string expectedSonarQubeDirectory = Path.Combine(Path.GetDirectoryName(fullSolutionPath), SonarQubeFilesFolder);
if (!Directory.Exists(expectedSonarQubeDirectory))
{
return; //Bail out no need to analyze the projects
}
string[] existingFiles = Directory.GetFiles(expectedSonarQubeDirectory, SonarQubeSolutionBindingConfigurationSearchPattern, SearchOption.TopDirectoryOnly);
if (existingFiles.Length > 0)
{
var componentModel = this.serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
var telemetryLogger = componentModel?.GetExtensions<ITelemetryLogger>().SingleOrDefault();
if (telemetryLogger == null)
{
Debug.Fail("Failed to find ITelemetryLogger");
return;
}
telemetryLogger.ReportEvent(TelemetryEvent.BoundSolutionDetected);
}
}