private static void LogTipClosed(object sender, DependencyPropertyChangedEventArgs e) { FrameworkElement context = sender as FrameworkElement; if ((context != null) && !context.IsVisible) { context.IsVisibleChanged -= LogTipClosed; DateTime now = DateTime.UtcNow; StructureMarginElement.s_elapsedTime += (now - StructureMarginElement.s_lastTimeChanged); StructureMarginElement.s_lastTimeChanged = now; if ((!StructureMarginElement.s_logged) && (StructureMarginElement.s_elapsedTime > StructureMarginElement.s_tipReportingDelay)) { if (StructureMarginElement.s_telemetrySession == null) { StructureMarginElement.s_telemetrySession = TelemetrySessionForPPT.Create(typeof(StructureMarginElement).Assembly); } StructureMarginElement.s_telemetrySession.PostEvent(StructureMarginElement.s_lastKey); StructureMarginElement.s_elapsedTime = TimeSpan.Zero; StructureMarginElement.s_logged = true; } } }
public GoToDefMouseHandler(IWpfTextView view, IOleCommandTarget commandTarget, ITelemetrySession telemetrySession, IClassifier aggregator, ITextStructureNavigator navigator, CtrlKeyState state) { _view = view; _commandTarget = commandTarget; _telemetrySession = telemetrySession; _state = state; _aggregator = aggregator; _navigator = navigator; _state.CtrlKeyStateChanged += (sender, args) => { if (_state.Enabled) { this.TryHighlightItemUnderMouse(RelativeToView(Mouse.PrimaryDevice.GetPosition(_view.VisualElement))); } else { this.SetHighlightSpan(null); } }; // Some other points to clear the highlight span. _view.LostAggregateFocus += (sender, args) => this.SetHighlightSpan(null); _view.VisualElement.MouseLeave += (sender, args) => this.SetHighlightSpan(null); }
public IMouseProcessor GetAssociatedProcessor(IWpfTextView view) { var buffer = view.TextBuffer; IOleCommandTarget shellCommandDispatcher = GetShellCommandDispatcher(view); if (shellCommandDispatcher == null) { return(null); } ITelemetrySession telemetrySession = TelemetrySessionForPPT.Create(typeof(GoToDefMouseHandler).Assembly); IVsExtensionManager manager = _globalServiceProvider.GetService(typeof(SVsExtensionManager)) as IVsExtensionManager; if (manager == null) { return(null); } IInstalledExtension extension; manager.TryGetInstalledExtension("GoToDef", out extension); if (extension != null) { return(null); } return(new GoToDefMouseHandler(view, shellCommandDispatcher, telemetrySession, _aggregatorFactory.GetClassifier(buffer), _navigatorService.GetTextStructureNavigator(buffer), CtrlKeyState.GetStateForView(view))); }
/// <summary> /// Adds <c>ETW</c> in-process telemetry session services to the service collection. /// </summary> /// <param name="services">A <see cref="IServiceCollection"/> instance.</param> /// <param name="configuration">A <see cref="IConfiguration"/> instance.</param> /// <returns>The provided <see cref="IServiceCollection"/> instance.</returns> public static IServiceCollection AddInProcessTelemetrySession( this IServiceCollection services, IConfiguration configuration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } return(services .AddTracingCore(configuration) .Configure <SessionConfiguration>(configuration.GetSection("Tracing")) .AddSingleton <IProvidersDescriptor, SessionConfigurationProvidersDescriptor>() .AddSingleton(p => { SessionConfiguration config = p .GetRequiredService <IOptions <SessionConfiguration> >()?.Value; IEnumerable <ITelemetryEventTransmitter> eventTransmitters = p.GetServices <ITelemetryEventTransmitter>(); ITelemetrySession session = InProcessTelemetrySession .Create(config, p.GetServices <IProvidersDescriptor>()); foreach (ITelemetryEventTransmitter transmitter in eventTransmitters) { session.Attach(transmitter); } return session; })); }
public void VsTextViewCreated(IVsTextView textViewAdapter) { IWpfTextView textView = editorAdaptersFactoryService.GetWpfTextView(textViewAdapter); ITextUndoHistory undoHistory = undoHistoryRegistry.RegisterHistory(textView.TextBuffer); IEditorOperations editorOperations = editorOperationsFactoryService.GetEditorOperations(textView); IEditorOptions editorOptions = editorOptionsFactoryService.GetOptions(textView); IViewPrimitives viewPrimitives = editorPrimitivesFactoryService.GetViewPrimitives(textView); if (_telemetrySession == null) { _telemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly); } // Object will survive since it adds itself to the view's command filter chain new CommandFilter( textViewAdapter, textView, htmlBuilderService, rtfBuilderService, editorOperations, undoHistory, editorOptions, viewPrimitives, _telemetrySession); }
public InformationBarMargin(IWpfTextView textView, ITextDocument document, IEditorOperations editorOperations, ITextUndoHistory undoHistory) { _textView = textView; _document = document; _operations = editorOperations; _undoHistory = undoHistory; _telemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly); var informationBar = new InformationBarControl(); informationBar.Tabify.Click += Tabify; informationBar.Untabify.Click += Untabify; informationBar.Hide.Click += Hide; informationBar.DontShowAgain.Click += DontShowAgain; this.Height = 0; this.Content = informationBar; this.Name = MarginName; document.FileActionOccurred += FileActionOccurred; // Delay the initial check until the view gets focus. textView.GotAggregateFocus += GotAggregateFocus; }
public NuGetProjectTelemetryService(ITelemetrySession telemetryService) { if (telemetryService == null) { throw new ArgumentNullException(nameof(telemetryService)); } telemetrySession = telemetryService; }
public NuGetTelemetryService(ITelemetrySession telemetrySession) { if (telemetrySession == null) { throw new ArgumentNullException(nameof(telemetrySession)); } _telemetrySession = telemetrySession; }
public ActionsTelemetryBase(ITelemetrySession telemetrySession) { if (telemetrySession == null) { throw new ArgumentNullException(nameof(telemetrySession)); } _telemetrySession = telemetrySession; }
private MiddleClickScroll(IWpfTextView view, ITelemetrySession telemetrySession) { _view = view; _telemetrySession = telemetrySession; _layer = view.GetAdornmentLayer("MiddleClickScrollLayer"); _view.Closed += OnClosed; _view.VisualElement.IsVisibleChanged += OnIsVisibleChanged; }
public IMouseProcessor GetAssociatedProcessor(IWpfTextView textView) { if (_telemetrySession == null) { _telemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly); } return(MiddleClickScroll.Create(textView, _telemetrySession)); }
public ToolsOptionsPage() { _telemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly); BeforeCodeSnippet = _beforeCodeSnippetDefault; AfterCodeSnippet = _afterCodeSnippetDefault; Space = _spaceDefault; ReplaceLineBreaksWithBR = _replaceLineBreaksWithBRDefault; ReplaceTabsWithSpaces = _replaceTabsWithSpacesDefault; UnindentToRemoveExtraLeadingWhitespace = _unindentToRemoveExtraLeadingWhitespaceDefault; EmitSpanClass = _emitSpanClassDefault; EmitSpanStyle = _emitSpanStyleDefault; Instance = this; }
// do not override, use SessionChanged public virtual void SessionChangedHandler(object sender, ITelemetrySession session) { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(() => { SessionChanged(session); })); } else { SessionChanged(session); Session = session; } }
public void SetTransmitter_NoException() { using (ITelemetrySession session = InProcessTelemetrySession.Create(1)) { // arrange ITelemetryEventTransmitter transmitter = new ProbeTransmitter(); // act Action verify = () => session.Attach(transmitter); // assert Assert.Null(Record.Exception(verify)); } }
public void EnableProvider_TransmitterNull() { using (ITelemetrySession session = InProcessTelemetrySession.Create(1)) { // arrange string name = null; // act Action verify = () => session.EnableProvider(name, EventLevel.Critical); // assert Assert.Throws <ArgumentNullException>("name", verify); } }
public void SetTransmitter_TransmitterNull() { using (ITelemetrySession session = InProcessTelemetrySession.Create(1)) { // arrange ITelemetryEventTransmitter transmitter = null; // act Action verify = () => session.Attach(transmitter); // assert Assert.Throws <ArgumentNullException>("transmitter", verify); } }
public void EnableProvider_NoException() { using (ITelemetrySession session = InProcessTelemetrySession.Create(1)) { // arrange string name = "Valid-Name"; // act Action verify = () => session.EnableProvider(name, EventLevel.Critical); // assert Assert.Null(Record.Exception(verify)); } }
public HostTelemetryInitializer( IHostApplicationLifetime applicationLifetime, ITelemetrySession session, IAttachmentTransmissionInitializer initializer, TracingConfiguration options) { _applicationLifetime = applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime)); _session = session ?? throw new ArgumentNullException(nameof(session)); _initializer = initializer ?? throw new ArgumentNullException(nameof(initializer)); _options = options ?? throw new ArgumentNullException(nameof(options)); RegisterForUnhandledExceptions(); }
public HostTelemetryInitializer( IApplicationLifetime applicationLifetime, ITelemetrySession session, IAttachmentTransmissionInitializer initializer, IOptions <TracingConfiguration> configurationAccessor) { _applicationLifetime = applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime)); _session = session ?? throw new ArgumentNullException(nameof(session)); _initializer = initializer ?? throw new ArgumentNullException(nameof(initializer)); _configurationAccessor = configurationAccessor ?? throw new ArgumentNullException(nameof(configurationAccessor)); RegisterForUnhandledExceptions(); }
/// <summary> /// Initializes a new instance of the <see cref="TracingStartupFilter"/> class. /// </summary> /// <param name="applicationLifetime">A application lifetime object instance.</param> /// <param name="configurationAccessor">A configuration accessor instance.</param> /// <param name="initializer">An attachment transmission initializer.</param> /// <param name="session">An optional telemetry event session.</param> public TracingStartupFilter(IApplicationLifetime applicationLifetime, IOptions <TracingConfiguration> configurationAccessor, IAttachmentTransmissionInitializer initializer, ITelemetrySession session) { if (applicationLifetime == null) { throw new ArgumentNullException(nameof(applicationLifetime)); } _configurationAccessor = configurationAccessor ?? throw new ArgumentNullException(nameof(configurationAccessor)); _initializer = initializer ?? throw new ArgumentNullException(nameof(initializer)); _session = session; Start(); applicationLifetime.ApplicationStopping.Register(Stop); }
protected override void Initialize() { base.Initialize(); // Log telemetry on the initial settings values OptionsPagePackage.TelemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly); IEditorOptions globalOptions = (Common.GetMefService<IEditorOptionsFactoryService>()).GlobalOptions; foreach (object option in OptionsPage.Options) { var definition = option as LabeledOptionDefinition; if (definition != null) { if (globalOptions.IsOptionDefined(definition.Name, localScopeOnly: true)) { var value = globalOptions.GetOptionValue<bool>(definition.Name); OptionsPagePackage.TelemetrySession.PostEvent("VS/PPT-Options/OptionInitialValue", definition.Name, value); } } } }
public void VsTextViewCreated(IVsTextView textViewAdapter) { IWpfTextView textView = _editorFactory.GetWpfTextView(textViewAdapter); if (textView == null) { return; } if (_telemetrySession == null) { _telemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly); } IOleCommandTarget next; var commandFilter = new CommandFilter(textView, _peekBroker, _telemetrySession); int hr = textViewAdapter.AddCommandFilter(commandFilter, out next); if (next != null) { commandFilter.Next = next; } }
public CommandFilter(ITextView textView, IPeekBroker peekBroker, ITelemetrySession telemetrySession) { if (textView == null) { throw new ArgumentNullException("textView"); } if (peekBroker == null) { throw new ArgumentNullException("peekBroker"); } if (telemetrySession == null) { throw new ArgumentNullException("telemetrySession"); } _textView = textView; _peekBroker = peekBroker; _telemetrySession = telemetrySession; }
protected override void Initialize() { base.Initialize(); // Log telemetry on the initial settings values OptionsPagePackage.TelemetrySession = TelemetrySessionForPPT.Create(this.GetType().Assembly); IEditorOptions globalOptions = (Common.GetMefService <IEditorOptionsFactoryService>()).GlobalOptions; foreach (object option in OptionsPage.Options) { var definition = option as LabeledOptionDefinition; if (definition != null) { if (globalOptions.IsOptionDefined(definition.Name, localScopeOnly: true)) { var value = globalOptions.GetOptionValue <bool>(definition.Name); OptionsPagePackage.TelemetrySession.PostEvent("VS/PPT-Options/OptionInitialValue", definition.Name, value); } } } }
public CommandFilter( IVsTextView textView, IWpfTextView wpfTextView, IHtmlBuilderService htmlBuilderService, IRtfBuilderService rtfBuilderService, IEditorOperations editorOperations, ITextUndoHistory undoHistory, IEditorOptions editorOptions, IViewPrimitives viewPrimitives, ITelemetrySession telemetrySession) { _htmlBuilderService = htmlBuilderService; _rtfBuilderService = rtfBuilderService; _undoHistory = undoHistory; _textView = wpfTextView; _editorOperations = editorOperations; _editorOptions = editorOptions; _viewPrimitives = viewPrimitives; _telemetrySession = telemetrySession; textView.AddCommandFilter(this, out _nextCommandTargetInChain); }
public void Create_VerifyDefaultAndAllowedProviders() { // arrange int applicationId = 1; ProbeTransmitter transmitter = new ProbeTransmitter(); // act int telemetryCount = 0; using (ITelemetrySession session = InProcessTelemetrySession .Create(applicationId, EventLevel.Verbose, new[] { new TestProviderDescriptor() })) { session.Attach(transmitter); Application.Start(applicationId); Custom.EventSources.TestEventSource.Log.RunProcess(1234); Application.Stop(); telemetryCount = transmitter.Count; } // assert Assert.Equal(1, telemetryCount); }
protected virtual void SessionChanged(ITelemetrySession session) { }
public NuGetVSTelemetryService(ITelemetrySession telemetrySession) { _telemetrySession = telemetrySession ?? throw new ArgumentNullException(nameof(telemetrySession)); }
public NuGetVSActionTelemetryService(ITelemetrySession telemetrySession) { _telemetrySession = telemetrySession ?? throw new ArgumentNullException(nameof(telemetrySession)); OperationId = Guid.NewGuid().ToString(); }
public ActionsTelemetryService(ITelemetrySession telemetrySession) : base(telemetrySession) { }
public RestoreTelemetryService(ITelemetrySession telemetryService) : base(telemetryService) { }