Skip to content

Commit f611c8a

Browse files
CopilotJoeRobich
andcommitted
Refactor isOptional to be part of ComponentInfo interface
Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
1 parent 9c0d446 commit f611c8a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/lsptoolshost/extensions/builtInComponents.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface ComponentInfo {
1111
defaultFolderName: string;
1212
optionName: string;
1313
componentDllPaths: string[];
14+
isOptional?: boolean;
1415
}
1516

1617
export const componentInfo: { [key: string]: ComponentInfo } = {
@@ -26,11 +27,13 @@ export const componentInfo: { [key: string]: ComponentInfo } = {
2627
'Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll',
2728
'Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll',
2829
],
30+
isOptional: true,
2931
},
3032
razorDevKit: {
3133
defaultFolderName: '.razorDevKit',
3234
optionName: 'razorDevKit',
3335
componentDllPaths: ['Microsoft.VisualStudio.DevKit.Razor.dll'],
36+
isOptional: true,
3437
},
3538
razorExtension: {
3639
defaultFolderName: '.razorExtension',
@@ -41,20 +44,17 @@ export const componentInfo: { [key: string]: ComponentInfo } = {
4144
defaultFolderName: '.roslynCopilot',
4245
optionName: 'roslynCopilot',
4346
componentDllPaths: ['Microsoft.VisualStudio.Copilot.Roslyn.LanguageServer.dll'],
47+
isOptional: true,
4448
},
4549
};
4650

47-
export function getComponentPaths(
48-
componentName: string,
49-
options: LanguageServerOptions | undefined,
50-
isOptional = false
51-
): string[] {
51+
export function getComponentPaths(componentName: string, options: LanguageServerOptions | undefined): string[] {
5252
const component = componentInfo[componentName];
5353
const baseFolder = getComponentFolderPath(component, options);
5454
const paths = component.componentDllPaths.map((dllPath) => path.join(baseFolder, dllPath));
5555
for (const dllPath of paths) {
5656
if (!fs.existsSync(dllPath)) {
57-
if (isOptional) {
57+
if (component.isOptional) {
5858
// Component is optional and doesn't exist - return empty array
5959
return [];
6060
}

src/lsptoolshost/server/roslynLanguageServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ export class RoslynLanguageServer {
10261026

10271027
// Also include the Xaml Dev Kit extensions, if enabled.
10281028
if (languageServerOptions.enableXamlTools) {
1029-
getComponentPaths('xamlTools', languageServerOptions, true).forEach((path) =>
1029+
getComponentPaths('xamlTools', languageServerOptions).forEach((path) =>
10301030
additionalExtensionPaths.push(path)
10311031
);
10321032
}
@@ -1096,7 +1096,7 @@ export class RoslynLanguageServer {
10961096
await exports.setupTelemetryEnvironmentAsync(env);
10971097
}
10981098

1099-
getComponentPaths('roslynCopilot', languageServerOptions, true).forEach((extPath) => {
1099+
getComponentPaths('roslynCopilot', languageServerOptions).forEach((extPath) => {
11001100
additionalExtensionPaths.push(extPath);
11011101
});
11021102
}

src/razor/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export async function activate(
104104
await setupDevKitEnvironment(dotnetInfo.env, csharpDevkitExtension, logger);
105105

106106
if (vscode.env.isTelemetryEnabled) {
107-
const razorComponentPaths = getComponentPaths('razorDevKit', undefined, true);
107+
const razorComponentPaths = getComponentPaths('razorDevKit', undefined);
108108
if (razorComponentPaths.length !== 1) {
109109
logger.logError('Failed to find Razor DevKit telemetry extension path.', undefined);
110110
} else {

0 commit comments

Comments
 (0)