Skip to content

Game.Modding.Toolchain.Dependencies.VSCodeDependency

Assembly:
Game

Namespace:
Game.Modding.Toolchain.Dependencies

Type:
public class

Base:
BaseIDEDependency

Summary:
Represents the VS Code IDE dependency used by the modding toolchain. This class provides metadata (name, icon, minimum supported version) and implements detection logic to determine the installed VS Code version by invoking the "code --version" command via CliWrap. It cannot install or uninstall VS Code; it only detects the installed version and reports errors/warnings through the toolchain logger.


Fields

  • None This class declares no private fields of its own. Detection logic is implemented in the protected GetIDEVersion method and uses local variables within that method.

Properties

  • public override string name { get; }
    Returns "VS Code". Used by the toolchain UI to identify the dependency.

  • public override string icon { get; }
    Returns "Media/Toolchain/VSCode.svg". Path to the icon used in the toolchain UI.

  • public override bool canBeInstalled { get; }
    Returns false. VS Code cannot be installed through the toolchain manager; it must be installed externally.

  • public override bool canBeUninstalled { get; }
    Returns false. VS Code cannot be uninstalled through the toolchain manager.

  • public override string minVersion { get; }
    Returns "1.86". The minimum supported VS Code version required by the modding toolchain.


Constructors

  • public VSCodeDependency()
    No explicit constructor is declared in the source; the type has the default parameterless constructor. The instance exposes the properties above and is typically used by the ToolchainDependencyManager to query and validate the IDE dependency.

Methods

  • protected override async Task<string> GetIDEVersion(CancellationToken token) : System.Threading.Tasks.Task
    Detects the installed VS Code version by executing the command line "code --version" using CliWrap. Behavior details:
  • Captures the first non-empty line of standard output as the installed version string.
  • Collects any standard error output lines into a list and logs them as a warning (via IToolchainDependency.log.Warn) if present.
  • Uses WithValidation(CommandResultValidation.None) so CliWrap will not throw on non-zero exit codes; errors are instead captured in the stderr delegate.
  • Catches Win32Exception; logs the exception unless the exception's ErrorCode is -2147467259 (the code is ignored in that specific case).
  • Catches and logs any other exceptions encountered while trying to run the command.
  • Returns the detected version string (or empty string if detection failed).

This method is asynchronous and respects the supplied CancellationToken.


Usage Example

// You can read the basic metadata directly:
var dep = new VSCodeDependency();
Console.WriteLine(dep.name);        // "VS Code"
Console.WriteLine(dep.icon);        // "Media/Toolchain/VSCode.svg"
Console.WriteLine(dep.minVersion);  // "1.86"
Console.WriteLine(dep.canBeInstalled);   // false
Console.WriteLine(dep.canBeUninstalled); // false

// Note: GetIDEVersion is protected. The ToolchainDependencyManager (or another class
// in the toolchain infrastructure) invokes the detection routine when checking dependencies.
// The detection runs "code --version" and returns the first stdout line as the installed version.