/// <summary> /// Initialize /// </summary> /// <param name="configurationElement">Configuration element</param> /// <param name="dataSink">Data sink</param> /// <param name="logger">Logger</param> public virtual void Initialize( XmlElement configurationElement, IDataCollectionSink dataSink, IDataCollectionLogger logger) { EqtTrace.Info("DynamicCoverageDataCollectorImpl.Initialize: Initialize configuration. "); if (string.IsNullOrEmpty(configurationElement?.InnerXml)) { configurationElement = DynamicCoverageDataCollectorImpl.GetDefaultConfiguration(); } this.logger = logger; this.dataSink = dataSink; this.dataSink.SendFileCompleted += this.OnSendFileCompletedEvent; this.SessionName = Guid.NewGuid().ToString(); this.sessionDirectory = Path.Combine(Path.GetTempPath(), this.SessionName); this.directoryHelper.CreateDirectory(this.sessionDirectory); this.SetCoverageFileName(configurationElement); this.PrepareVanguardProcess(configurationElement); }
/// <summary> /// Initialize /// </summary> /// <param name="configurationElement">Configuration element</param> /// <param name="dataSink">Data sink</param> /// <param name="logger">Logger</param> public virtual void Initialize( XmlElement configurationElement, IDataCollectionSink dataSink, IDataCollectionLogger logger) { EqtTrace.Info("DynamicCoverageDataCollectorImpl.Initialize: Initialize configuration. "); if (string.IsNullOrEmpty(configurationElement?.InnerXml)) { // Add default configuration specific to CodeCoverage. https://msdn.microsoft.com/en-us/library/jj635153.aspx var doc = new XmlDocument(); Assembly a = typeof(DynamicCoverageDataCollectorImpl).GetTypeInfo().Assembly; using (Stream s = a.GetManifestResourceStream( "Microsoft.VisualStudio.TraceDataCollector.VanguardCollector.DefaultCodeCoverageConfig.xml")) { doc.Load(s); } configurationElement = doc.DocumentElement; } this.logger = logger; this.dataSink = dataSink; this.dataSink.SendFileCompleted += this.OnSendFileCompletedEvent; this.SessionName = Guid.NewGuid().ToString(); this.sessionDirectory = Path.Combine(Path.GetTempPath(), this.SessionName); this.directoryHelper.CreateDirectory(this.sessionDirectory); this.SetCoverageFileName(configurationElement); this.PrepareVanguardProcess(configurationElement); }
/// <summary> /// Initialize /// </summary> /// <param name="configurationElement">Configuration element</param> /// <param name="dataSink">Data sink</param> /// <param name="logger">Logger</param> public virtual void Initialize( XmlElement configurationElement, IDataCollectionSink dataSink, IDataCollectionLogger logger) { var defaultConfigurationElement = DynamicCoverageDataCollectorImpl.GetDefaultConfiguration(); try { // WARNING: Do NOT remove this function call !!! // // Due to a dependency we took on Microsoft.TestPlatform.Utilities.dll, an // exception may be thrown if we cannot resolve CodeCoverageRunSettingsProcessor. // If such an exception is thrown we cannot catch it in this try-catch block // because all method dependencies must be resolved before the method call, thus // we introduced an additional layer of indirection. configurationElement = this.AddDefaultExclusions(configurationElement, defaultConfigurationElement); } catch (Exception ex) { EqtTrace.Warning( string.Format( CultureInfo.CurrentCulture, string.Join( " ", "DynamicCoverageDataCollectorImpl.Initialize: Exception encountered while processing the configuration element.", "Keeping the configuration element unaltered. More info about the exception: {0}"), ex.Message)); } EqtTrace.Info("DynamicCoverageDataCollectorImpl.Initialize: Initialize configuration. "); if (string.IsNullOrEmpty(configurationElement?.InnerXml)) { configurationElement = defaultConfigurationElement; } this.logger = logger; this.dataSink = dataSink; this.dataSink.SendFileCompleted += this.OnSendFileCompletedEvent; this.SessionName = Guid.NewGuid().ToString(); this.sessionDirectory = Path.Combine(Path.GetTempPath(), this.SessionName); this.directoryHelper.CreateDirectory(this.sessionDirectory); this.SetCoverageFileName(configurationElement); this.PrepareVanguardProcess(configurationElement); }
/// <summary> /// Initialize /// </summary> /// <param name="configurationElement">Configuration element</param> /// <param name="dataSink">Data sink</param> /// <param name="logger">Logger</param> public virtual void Initialize( XmlElement configurationElement, IDataCollectionSink dataSink, IDataCollectionLogger logger) { var defaultConfigurationElement = DynamicCoverageDataCollectorImpl.GetDefaultConfiguration(); try { var processor = new CodeCoverageRunSettingsProcessor(defaultConfigurationElement); configurationElement = (XmlElement)processor.Process(configurationElement); } catch (Exception ex) { EqtTrace.Warning( string.Format( CultureInfo.CurrentCulture, string.Join( " ", "DynamicCoverageDataCollectorImpl.Initialize: Exception encountered while processing the configuration element.", "Keeping the configuration element unaltered. More info about the exception: {0}"), ex.Message)); } EqtTrace.Info("DynamicCoverageDataCollectorImpl.Initialize: Initialize configuration. "); if (string.IsNullOrEmpty(configurationElement?.InnerXml)) { configurationElement = defaultConfigurationElement; } this.logger = logger; this.dataSink = dataSink; this.dataSink.SendFileCompleted += this.OnSendFileCompletedEvent; this.SessionName = Guid.NewGuid().ToString(); this.sessionDirectory = Path.Combine(Path.GetTempPath(), this.SessionName); this.directoryHelper.CreateDirectory(this.sessionDirectory); this.SetCoverageFileName(configurationElement); this.PrepareVanguardProcess(configurationElement); }