Skip to content

Commit ccf48ea

Browse files
committed
Check for C# extension dependendies at runtime
1 parent 026282a commit ccf48ea

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

release/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,8 +1831,12 @@
18311831
"engines": {
18321832
"vscode": "^0.10.0"
18331833
},
1834+
"extensionPack": [
1835+
"ms-dotnettools.csharp",
1836+
"anyshere.csharp",
1837+
"muhammad-sammy.csharp"
1838+
],
18341839
"extensionDependencies": [
1835-
"ms-dotnettools.csharp"
18361840
],
18371841
"homepage": "http://ionide.io",
18381842
"icon": "images/logo.png",

src/fsharp.fs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ open Node.ChildProcess
1313
let private logger =
1414
ConsoleAndOutputChannelLogger(Some "Main", Level.DEBUG, Some defaultOutputChannel, Some Level.DEBUG)
1515

16+
let private requiredExtensions =
17+
[ "ms-dotnettools.csharp" // VSCode C# extension
18+
"anysphere.csharp" // Cursor C# extension
19+
"muhammad-sammy.csharp" ] // Free/Libre C# extension
20+
21+
let private checkCSharpExtension () =
22+
requiredExtensions
23+
|> List.exists (fun extId -> extensions.getExtension extId |> Option.isSome)
24+
1625
type Api =
1726
{ ProjectLoadedEvent: Event<DTO.Project>
1827
BuildProject: DTO.Project -> JS.Promise<string>
@@ -33,7 +42,7 @@ let private activateLanguageServiceRestart (context: ExtensionContext) =
3342
commands.registerCommand ("fsharp.restartLanguageService", restart |> objfy2)
3443
|> context.Subscribe
3544

36-
let activate (context: ExtensionContext) : JS.Promise<Api> =
45+
let private doActivate (context: ExtensionContext) : JS.Promise<Api> =
3746
let solutionExplorer = "FSharp.enableTreeView" |> Configuration.get true
3847

3948
let showExplorer = "FSharp.showExplorerOnStartup" |> Configuration.get false
@@ -140,5 +149,24 @@ let activate (context: ExtensionContext) : JS.Promise<Api> =
140149
logger.Error $"Error activating features: %A{e}"
141150
Unchecked.defaultof<_>)
142151

152+
let activate (context: ExtensionContext) : JS.Promise<Api> =
153+
// Check for C# extension at runtime
154+
if not (checkCSharpExtension ()) then
155+
let extensionList =
156+
requiredExtensions
157+
|> List.rev
158+
|> function
159+
| [] -> ""
160+
| [ x ] -> x
161+
| last :: rest ->
162+
let restStr = rest |> List.rev |> String.concat ", "
163+
$"{restStr} or {last}"
164+
165+
window.showErrorMessage ($"Ionide requires one of the following C# extensions to be installed: {extensionList}")
166+
|> Promise.ofThenable
167+
|> Promise.map (fun _ -> Unchecked.defaultof<_>)
168+
else
169+
doActivate context
170+
143171

144172
let deactivate (disposables: Disposable[]) = LanguageService.stop ()

0 commit comments

Comments
 (0)