From b839ecb0b1aa79f12a6f7f2dfa96d38959a66df7 Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Tue, 16 Feb 2021 09:42:17 -0800 Subject: [PATCH 1/3] Fix tests --- src/client/activation/serviceRegistry.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/activation/serviceRegistry.ts b/src/client/activation/serviceRegistry.ts index 32fd42dd8da..f5f3f78e805 100644 --- a/src/client/activation/serviceRegistry.ts +++ b/src/client/activation/serviceRegistry.ts @@ -21,7 +21,8 @@ export function registerTypes(serviceManager: IServiceManager) { serviceManager.addSingleton( IExtensionSingleActivationService, DataScienceSurveyBanner, - BANNER_NAME_DS_SURVEY + BANNER_NAME_DS_SURVEY, + [IJupyterExtensionBanner] ); serviceManager.addSingleton( IJupyterExtensionBanner, From 8398404138bf2af671e0eb0f9ff112e0cd4e4785 Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Tue, 16 Feb 2021 10:21:34 -0800 Subject: [PATCH 2/3] Try to fix ambiguous binding error --- src/client/activation/serviceRegistry.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/activation/serviceRegistry.ts b/src/client/activation/serviceRegistry.ts index f5f3f78e805..9fccc33cdd3 100644 --- a/src/client/activation/serviceRegistry.ts +++ b/src/client/activation/serviceRegistry.ts @@ -18,12 +18,12 @@ export function registerTypes(serviceManager: IServiceManager) { IExtensionActivationService, MigrateDataScienceSettingsService ); - serviceManager.addSingleton( - IExtensionSingleActivationService, + serviceManager.addSingleton( + IJupyterExtensionBanner, DataScienceSurveyBanner, - BANNER_NAME_DS_SURVEY, - [IJupyterExtensionBanner] + BANNER_NAME_DS_SURVEY ); + serviceManager.addBinding(IJupyterExtensionBanner, IExtensionSingleActivationService); serviceManager.addSingleton( IJupyterExtensionBanner, InteractiveShiftEnterBanner, From 52576d488c2448a258a61f2484bb0eb9dd1fc93f Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Tue, 16 Feb 2021 10:53:59 -0800 Subject: [PATCH 3/3] Try a different approach --- src/client/activation/serviceRegistry.ts | 10 +++------- src/client/common/types.ts | 5 ++++- src/client/datascience/dataScienceSurveyBanner.ts | 11 +++++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/client/activation/serviceRegistry.ts b/src/client/activation/serviceRegistry.ts index 9fccc33cdd3..cc7276ed73f 100644 --- a/src/client/activation/serviceRegistry.ts +++ b/src/client/activation/serviceRegistry.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { BANNER_NAME_DS_SURVEY, BANNER_NAME_INTERACTIVE_SHIFTENTER, IJupyterExtensionBanner } from '../common/types'; +import { BANNER_NAME_INTERACTIVE_SHIFTENTER, IJupyterExtensionBanner, ISurveyBanner } from '../common/types'; import { DataScienceSurveyBanner } from '../datascience/dataScienceSurveyBanner'; import { RecommendPythonExtensionBanner } from '../datascience/recommendPythonExtensionBanner'; import { InteractiveShiftEnterBanner } from '../datascience/shiftEnterBanner'; @@ -18,12 +18,8 @@ export function registerTypes(serviceManager: IServiceManager) { IExtensionActivationService, MigrateDataScienceSettingsService ); - serviceManager.addSingleton( - IJupyterExtensionBanner, - DataScienceSurveyBanner, - BANNER_NAME_DS_SURVEY - ); - serviceManager.addBinding(IJupyterExtensionBanner, IExtensionSingleActivationService); + serviceManager.addSingleton(ISurveyBanner, DataScienceSurveyBanner); + serviceManager.addBinding(ISurveyBanner, IExtensionSingleActivationService); serviceManager.addSingleton( IJupyterExtensionBanner, InteractiveShiftEnterBanner, diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 41a533d21e0..02d7fd183dd 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -15,6 +15,7 @@ import { Uri, WorkspaceEdit } from 'vscode'; +import { IExtensionSingleActivationService } from '../activation/types'; import { BannerType } from '../datascience/dataScienceSurveyBanner'; import { LogLevel } from '../logging/levels'; import { CommandsWithoutArgs } from './application/commands'; @@ -329,9 +330,11 @@ export interface IJupyterExtensionBanner { isEnabled(type: BannerType): boolean; showBanner(type: BannerType): Promise; } -export const BANNER_NAME_DS_SURVEY: string = 'DSSurveyBanner'; export const BANNER_NAME_INTERACTIVE_SHIFTENTER: string = 'InteractiveShiftEnterBanner'; +export const ISurveyBanner = Symbol('ISurveyBanner'); +export interface ISurveyBanner extends IExtensionSingleActivationService, IJupyterExtensionBanner {} + export type DeprecatedSettingAndValue = { setting: string; values?: {}[]; diff --git a/src/client/datascience/dataScienceSurveyBanner.ts b/src/client/datascience/dataScienceSurveyBanner.ts index c02f3739d56..dd988d1dc82 100644 --- a/src/client/datascience/dataScienceSurveyBanner.ts +++ b/src/client/datascience/dataScienceSurveyBanner.ts @@ -3,7 +3,7 @@ 'use strict'; -import { inject, injectable, named } from 'inversify'; +import { inject, injectable } from 'inversify'; import { Event, EventEmitter, UIKind } from 'vscode'; import { IExtensionSingleActivationService } from '../activation/types'; import { IApplicationEnvironment, IApplicationShell, IVSCodeNotebook } from '../common/application/types'; @@ -12,13 +12,13 @@ import { Experiments } from '../common/experiments/groups'; import '../common/extensions'; import { traceError } from '../common/logger'; import { - BANNER_NAME_DS_SURVEY, IBrowserService, IDisposableRegistry, IExperimentService, IJupyterExtensionBanner, IPersistentState, - IPersistentStateFactory + IPersistentStateFactory, + ISurveyBanner } from '../common/types'; import * as localize from '../common/utils/localize'; import { noop } from '../common/utils/misc'; @@ -65,9 +65,8 @@ export class DataScienceSurveyBannerLogger implements IInteractiveWindowListener private postEmitter = new EventEmitter<{ message: string; payload: any }>(); constructor( @inject(IPersistentStateFactory) private persistentState: IPersistentStateFactory, - @inject(IJupyterExtensionBanner) - @named(BANNER_NAME_DS_SURVEY) - private readonly dataScienceSurveyBanner: IJupyterExtensionBanner + @inject(ISurveyBanner) + private readonly dataScienceSurveyBanner: ISurveyBanner ) {} // eslint-disable-next-line @typescript-eslint/no-explicit-any public get postMessage(): Event<{ message: string; payload: any }> {