Skip to content

Commit b42b83e

Browse files
committed
Delete dead internal code
1 parent 021f95f commit b42b83e

File tree

3 files changed

+2
-91
lines changed

3 files changed

+2
-91
lines changed

src/PowerShellEditorServices/Utility/IScriptExtentExtensions.cs

-28
This file was deleted.

src/PowerShellEditorServices/Utility/PSCommandExtensions.cs

-34
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,14 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7-
using System.Linq.Expressions;
87
using System.Management.Automation;
98
using System.Management.Automation.Runspaces;
10-
using System.Reflection;
119
using System.Text;
1210

1311
namespace Microsoft.PowerShell.EditorServices.Utility
1412
{
1513
internal static class PSCommandHelpers
1614
{
17-
private static readonly Func<CommandInfo, Command> s_commandCtor;
18-
19-
static PSCommandHelpers()
20-
{
21-
ConstructorInfo ctor = typeof(Command).GetConstructor(
22-
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
23-
binder: null,
24-
new[] { typeof(CommandInfo) },
25-
modifiers: null);
26-
27-
ParameterExpression commandInfo = Expression.Parameter(typeof(CommandInfo), nameof(commandInfo));
28-
29-
s_commandCtor = Expression.Lambda<Func<CommandInfo, Command>>(
30-
Expression.New(ctor, commandInfo),
31-
new[] { commandInfo })
32-
.Compile();
33-
}
34-
35-
/// <summary>
36-
/// PowerShell's missing an API for us to AddCommand using a CommandInfo.
37-
/// An issue was filed here: https://github.com/PowerShell/PowerShell/issues/12295
38-
/// This works around this by creating a `Command` and passing it into PSCommand.AddCommand(Command command)
39-
/// </summary>
40-
/// <param name="command"></param>
41-
/// <param name="commandInfo"></param>
42-
/// <returns></returns>
43-
public static PSCommand AddCommand(this PSCommand command, CommandInfo commandInfo)
44-
{
45-
Command rsCommand = s_commandCtor(commandInfo);
46-
return command.AddCommand(rsCommand);
47-
}
48-
4915
public static PSCommand AddOutputCommand(this PSCommand psCommand)
5016
{
5117
return psCommand.MergePipelineResults()

src/PowerShellEditorServices/Utility/PathUtils.cs

+2-29
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,6 @@ namespace Microsoft.PowerShell.EditorServices.Utility
1010
{
1111
internal static class PathUtils
1212
{
13-
/// <summary>
14-
/// <para>The default path separator used by the base implementation of the providers.</para>
15-
/// <para>
16-
/// Porting note: IO.Path.DirectorySeparatorChar is correct for all platforms. On Windows,
17-
/// it is '\', and on Linux, it is '/', as expected.
18-
/// </para>
19-
/// </summary>
20-
internal static readonly char DefaultPathSeparator = Path.DirectorySeparatorChar;
21-
22-
/// <summary>
23-
/// <para>The alternate path separator used by the base implementation of the providers.</para>
24-
/// <para>
25-
/// Porting note: we do not use .NET's AlternatePathSeparatorChar here because it correctly
26-
/// states that both the default and alternate are '/' on Linux. However, for PowerShell to
27-
/// be "slash agnostic", we need to use the assumption that a '\' is the alternate path
28-
/// separator on Linux.
29-
/// </para>
30-
/// </summary>
31-
internal static readonly char AlternatePathSeparator = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? '/' : '\\';
32-
3313
/// <summary>
3414
/// The <see cref="StringComparison" /> value to be used when comparing paths. Will be
3515
/// <see cref="StringComparison.Ordinal" /> for case sensitive file systems and <see cref="StringComparison.OrdinalIgnoreCase" />
@@ -39,13 +19,6 @@ internal static class PathUtils
3919
? StringComparison.Ordinal
4020
: StringComparison.OrdinalIgnoreCase;
4121

42-
/// <summary>
43-
/// Converts all alternate path separators to the current platform's main path separators.
44-
/// </summary>
45-
/// <param name="path">The path to normalize.</param>
46-
/// <returns>The normalized path.</returns>
47-
public static string NormalizePathSeparators(string path) => string.IsNullOrWhiteSpace(path) ? path : path.Replace(AlternatePathSeparator, DefaultPathSeparator);
48-
4922
/// <summary>
5023
/// Determines whether two specified strings represent the same path.
5124
/// </summary>
@@ -67,8 +40,8 @@ internal static bool IsPathEqual(string left, string right)
6740
return false;
6841
}
6942

70-
left = Path.GetFullPath(left).TrimEnd(DefaultPathSeparator);
71-
right = Path.GetFullPath(right).TrimEnd(DefaultPathSeparator);
43+
left = Path.GetFullPath(left).TrimEnd(Path.DirectorySeparatorChar);
44+
right = Path.GetFullPath(right).TrimEnd(Path.DirectorySeparatorChar);
7245
return left.Equals(right, PathComparison);
7346
}
7447

0 commit comments

Comments
 (0)