Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ static IShellProvider LookupShellFromEnvironment(Dictionary<string, IShellProvid
{
throw new InvalidOperationException(Strings.ShellDiscovery_ShellEnvironmentNotSet);
}
var shellName = Path.GetFileName(shellPath);
if (shellMap.TryGetValue(shellPath, out var shellProvider))
var shellName = Path.GetFileName(shellPath).ToLower();
if (shellMap.TryGetValue(shellName, out var shellProvider))
{
return shellProvider;
}
Expand Down
24 changes: 24 additions & 0 deletions test/dotnet.Tests/CompletionTests/ShellDiscoveryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable


using System.CommandLine.StaticCompletions.Shells;
using Microsoft.DotNet.Cli.Commands.BuildServer.Shutdown;
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The using statement for Microsoft.DotNet.Cli.Commands.BuildServer.Shutdown appears unused in this test class. Unused using directives should be removed.

Suggested change
using Microsoft.DotNet.Cli.Commands.BuildServer.Shutdown;

Copilot uses AI. Check for mistakes.
using Xunit;
using Xunit.Abstractions;
using Parser = Microsoft.DotNet.Cli.Parser;

namespace System.CommandLine.StaticCompletions.Tests;

public class ShellDiscoveryTests()
{
[Fact]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe parameterize this test with the shell names and set the SHELL env var before each run so we can easily test all of our shell experiences??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point -- I think this test should be ok since it works in general on any generic shell. If we had more capacity I would probably add this to the test, but not going to prioritize it right now. Thank you for reviewing

public void StaticCompletionsCanParseWithoutAShell()
{
var result = Parser.Instance.Parse(@"dotnet completions script");
result.Errors.Should().BeEmpty();
result.GetValue<IShellProvider>("@CompletionsCommand_ShellArgument_Description").Should().NotBeNull();
}
}
Loading