Skip to content

Commit 3126fd6

Browse files
committed
Add Error Checking for unsupported platforms
This PR adds in a check to see what platform the extension is running on. If it is running via Remote SSH, we reccomend users to code on their host machine and debug remotely. If they are running VS Code somehow on an unsupported platform, we will mention that the C# extension is incompatiable with the current platform and arch.
1 parent 237da87 commit 3126fd6

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@
359359
}
360360
],
361361
"engines": {
362-
"vscode": "^1.31.0"
362+
"vscode": "^1.36.0"
363363
},
364364
"activationEvents": [
365365
"onDebugInitialConfigurations",

src/main.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,32 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
121121
eventStream.post(new ActivationFailure());
122122
}
123123

124+
if (!isSupportedPlatform(platformInfo)) {
125+
const platform: string = platformInfo.platform ? platformInfo.platform : "this platform";
126+
const architecture: string = platformInfo.architecture ? platformInfo.architecture : " and architecture";
127+
let errorMessage: string = `The C# extension for Visual Studio Code (powered by OmniSharp) is incompatiable on ${platform} ${architecture}`;
128+
const messageOptions: vscode.MessageOptions = {
129+
};
130+
131+
// Check to see if VS Code is running remotely
132+
if (extension.extensionKind === vscode.ExtensionKind.Workspace) {
133+
const setupButton: string = "How to setup Remote Debugging";
134+
errorMessage += ` with the VS Code Remote Extensions. To see avaliable workarounds, click on '${setupButton}'.`;
135+
136+
await vscode.window.showErrorMessage(errorMessage, messageOptions, setupButton).then((selectedItem: string) => {
137+
if (selectedItem === setupButton) {
138+
let remoteDebugInfoURL = 'https://github.com/OmniSharp/omnisharp-vscode/wiki/Remote-Debugging-On-Linux-Arm';
139+
vscode.env.openExternal(vscode.Uri.parse(remoteDebugInfoURL));
140+
}
141+
});
142+
} else {
143+
await vscode.window.showErrorMessage(errorMessage, messageOptions);
144+
}
145+
146+
// Unsupported platform
147+
return null;
148+
}
149+
124150
let telemetryObserver = new TelemetryObserver(platformInfo, () => reporter);
125151
eventStream.subscribe(telemetryObserver.post);
126152

@@ -171,6 +197,24 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
171197
};
172198
}
173199

200+
function isSupportedPlatform(platform: PlatformInformation): boolean {
201+
if (platform.isWindows()) {
202+
return platform.architecture === "x86" || platform.architecture === "x86_64";
203+
}
204+
205+
if (platform.isMacOS()) {
206+
return true;
207+
}
208+
209+
if (platform.isLinux()) {
210+
return platform.architecture === "x86_64" ||
211+
platform.architecture === "x86" ||
212+
platform.architecture === "i686";
213+
}
214+
215+
return false;
216+
}
217+
174218
async function ensureRuntimeDependencies(extension: vscode.Extension<CSharpExtensionExports>, eventStream: EventStream, platformInfo: PlatformInformation, installDependencies: IInstallDependencies): Promise<boolean> {
175219
return installRuntimeDependencies(extension.packageJSON, extension.extensionPath, installDependencies, eventStream, platformInfo);
176220
}

src/vscodeAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ export interface vscode {
943943
};
944944
extensions: {
945945
getExtension(extensionId: string): Extension<any> | undefined;
946-
all: Extension<any>[];
946+
all: ReadonlyArray<Extension<any>>;
947947
};
948948
Uri: {
949949
parse(value: string): Uri;

0 commit comments

Comments
 (0)