Skip to content

RegisterWithDotnetSuggest should not remove "extension" on Linux #2316

Closed

Description

@dorssel

See:

var currentProcessFileNameWithoutExtension = Path.GetFileNameWithoutExtension(currentProcessFullPath);

When building a Linux executable with full assembly name as output file, this removes the last part of the final executable name.

For example, if the executable output is named "Full.Assembly.Name.Linux.Executable", then RegisterWithDotnetSuggest() registers "Full.Assembly.Name.Linux" and completions won't work.

Activity

  1. KalleOlaviNiemitalo commented on Jan 4, 2024

    @KalleOlaviNiemitalo

    CliRootCommand.ExecutableName seems to have the same bug, even on the main branch:

    /// <summary>
    /// The name of the currently running executable.
    /// </summary>
    public static string ExecutableName
    => _executableName ??= Path.GetFileNameWithoutExtension(ExecutablePath).Replace(" ", "");
    /// <summary>
    /// The path to the currently running executable.
    /// </summary>
    public static string ExecutablePath => _executablePath ??= Environment.GetCommandLineArgs()[0];

    Likewise SuggestionDispatcher.ShellPrefixesToMatch:

    foreach (var r in registrations)
    {
    var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(r.ExecutablePath);
    yield return fileNameWithoutExtension;

    Especially as the extension may have already been deleted from Registration.ExecutablePath by GlobalToolsSuggestionRegistration:

    return _filesNameWithoutExtensionUnderDotnetProfileTools.Select(p =>
    new Registration(Path.Combine(_nullableToolsShimPath, p)));

    But I suppose command-line tools are more commonly named using kebab-case than Dot.Delimited.Titlecase. Except there are versioned names like perl5.36.1.

  2. KalleOlaviNiemitalo commented on Jun 21, 2025

    @KalleOlaviNiemitalo

    RegisterWithDotnetSuggest was deleted in 2.0.0-beta5 so this issue is no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions