diff --git a/.gitignore b/.gitignore index 2b086d4f..9f94a9a7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ obj .idea/ .config/ nupkg/ +publish_output/ \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index 4a830265..93e94784 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -18,8 +18,8 @@ - - + + diff --git a/README.md b/README.md index 1493a0bf..8e2373f8 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,8 @@ See [CHANGELOG.md](CHANGELOG.md) for the list of recent improvements/fixes. - vb-ls uses [ILSpy/ICSharpCode.Decompiler](https://github.com/icsharpcode/ILSpy) to decompile types in assemblies to C# source. # Installation -`dotnet tool install --global vb-ls` -See [vb-ls nuget page](https://www.nuget.org/packages/vb-ls/) +To install, run the python build script found in the root directory of the source once you have cloned the project. # Settings diff --git a/build.py b/build.py new file mode 100644 index 00000000..77c56971 --- /dev/null +++ b/build.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +import subprocess +import shutil +import sys +from pathlib import Path + +PROJECT = Path(__file__).parent / "src" / "VisualBasicLanguageServer" / "VisualBasicLanguageServer.fsproj" +PUBLISH_DIR = Path(__file__).parent / "publish_output" +INSTALL_DIR = Path.home() / ".dotnet" / "tools" / "vb-ls-patched" +EXE_NAME = "VisualBasicLanguageServer" + (".exe" if sys.platform == "win32" else "") + + +def run(*cmd): + print(f"$ {' '.join(str(c) for c in cmd)}") + subprocess.run([str(c) for c in cmd], check=True) + + +def main(): + # Clean previous publish output + if PUBLISH_DIR.exists(): + shutil.rmtree(PUBLISH_DIR) + + # Pack (produces nupkg) + run("dotnet", "pack", PROJECT, "--configuration", "Release") + + # Publish (produces the exe) + run( + "dotnet", "publish", PROJECT, + "--configuration", "Release", + "--output", PUBLISH_DIR, + ) + + if not (PUBLISH_DIR / EXE_NAME).exists(): + print(f"ERROR: expected output not found at {PUBLISH_DIR / EXE_NAME}", file=sys.stderr) + sys.exit(1) + + INSTALL_DIR.mkdir(parents=True, exist_ok=True) + for src in PUBLISH_DIR.iterdir(): + dst = INSTALL_DIR / src.name + shutil.copy2(src, dst) + print(f"\nInstalled to: {INSTALL_DIR}") + + +if __name__ == "__main__": + main() diff --git a/global.json b/global.json index 883d5bef..4aa75dd3 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0", + "version": "9.0.0", "rollForward": "minor" } } diff --git a/src/VisualBasicLanguageServer/Handlers/Completion.fs b/src/VisualBasicLanguageServer/Handlers/Completion.fs index 2ee9696c..d789afae 100644 --- a/src/VisualBasicLanguageServer/Handlers/Completion.fs +++ b/src/VisualBasicLanguageServer/Handlers/Completion.fs @@ -76,7 +76,7 @@ module Completion = let defaultCo: obj = coType.GetField("Default") |> nonNull "Microsoft.CodeAnalysis.Completion.CompletionOptions.Default" - |> _.GetValue() + |> _.GetValue(null) { Object = defaultCo; CompletionOptionsType = coType } diff --git a/src/VisualBasicLanguageServer/State/ServerState.fs b/src/VisualBasicLanguageServer/State/ServerState.fs index 636d0799..3503c47f 100644 --- a/src/VisualBasicLanguageServer/State/ServerState.fs +++ b/src/VisualBasicLanguageServer/State/ServerState.fs @@ -138,8 +138,8 @@ let getDocumentForUriOfType state docType (u: string) = let matchingUserDocumentMaybe = match matchingUserDocuments with - | [d] -> Some (d, UserDocument) - | _ -> None + | d :: _ -> Some (d, UserDocument) + | [] -> None let matchingDecompiledDocumentMaybe = Map.tryFind u state.DecompiledMetadata