Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs (C#)

Code before:
                    foreach (dynamic child in childItemOutput)
                    {
                        // TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
                        _ = childrenInfoTable.TryAdd(GetChildNameFromPsObject(child, provider.ItemSeparator), child.PSIsContainer);
                    }

                    _ = context.Helper.CurrentPowerShell
                        .AddCommandWithPreferenceSetting("Microsoft.PowerShell.Management\\Get-ChildItem")
                        .AddParameter("LiteralPath", pathInfo.Path)
                        .AddParameter("Name")
                        .AddCommandWithPreferenceSetting("Microsoft.PowerShell.Utility\\Sort-Object")
                        .AddParameter("Unique");
                    childItemOutput = context.Helper.ExecuteCurrentPowerShell(out _);
                    foreach (PSObject child in childItemOutput)
                    {
                        string childName = (string)child.BaseObject;
                        childNameList.Add(childName);
                    }
                }
                else
                {
                    foreach (dynamic child in childItemOutput)
                    {
                        var childName = GetChildNameFromPsObject(child, provider.ItemSeparator);
                        // TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
                        if (childrenInfoTable.TryAdd(childName, child.PSIsContainer))
                        {
                            childNameList.Add(childName);
                        }
                    }
                }

                if (childNameList.Count == 0)
                {
                    return results;
                }

                string basePath = providerPrefix.Length > 0
                    ? string.Concat(providerPrefix, pathInfo.Path.AsSpan(providerPrefix.Length))
                    : pathInfo.Path;
                if (basePath[^1] is not '\\' and not '/' and not ':')
                {
                    basePath += provider.ItemSeparator;
                }

                if (relativePaths)
                {
                    basePath = context.ExecutionContext.EngineSessionState.NormalizeRelativePath(
                        basePath + childNameList[0], context.ExecutionContext.SessionState.Internal.CurrentLocation.ProviderPath);
                    if (!basePath.StartsWith($"..{provider.ItemSeparator}", StringComparison.Ordinal))
                    {

Review comment (refactor):
Style issue:
```suggestion

                        // TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
```

Code after:
                    foreach (dynamic child in childItemOutput)
                    {
                        // TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
                        _ = childrenInfoTable.TryAdd(GetChildNameFromPsObject(child, provider.ItemSeparator), child.PSIsContainer);
                    }

                    _ = context.Helper.CurrentPowerShell
                        .AddCommandWithPreferenceSetting("Microsoft.PowerShell.Management\\Get-ChildItem")
                        .AddParameter("LiteralPath", pathInfo.Path)
                        .AddParameter("Name")
                        .AddCommandWithPreferenceSetting("Microsoft.PowerShell.Utility\\Sort-Object")
                        .AddParameter("Unique");
                    childItemOutput = context.Helper.ExecuteCurrentPowerShell(out _);
                    foreach (PSObject child in childItemOutput)
                    {
                        string childName = (string)child.BaseObject;
                        childNameList.Add(childName);
                    }
                }
                else
                {
                    foreach (dynamic child in childItemOutput)
                    {
                        var childName = GetChildNameFromPsObject(child, provider.ItemSeparator);

                        // TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
                        if (childrenInfoTable.TryAdd(childName, child.PSIsContainer))
                        {
                            childNameList.Add(childName);
                        }
                    }
                }

                if (childNameList.Count == 0)
                {
                    return results;
                }

                string basePath = providerPrefix.Length > 0
                    ? string.Concat(providerPrefix, pathInfo.Path.AsSpan(providerPrefix.Length))
                    : pathInfo.Path;
                if (basePath[^1] is not '\\' and not '/' and not ':')
                {
                    basePath += provider.ItemSeparator;
                }

                if (relativePaths)
                {
                    basePath = context.ExecutionContext.EngineSessionState.NormalizeRelativePath(
                        basePath + childNameList[0], context.ExecutionContext.SessionState.Internal.CurrentLocation.ProviderPath);
                    if (!basePath.StartsWith($"..{provider.ItemSeparator}", StringComparison.Ordinal))