Skip to content

Commit 397dffd

Browse files
committed
remove System.Management
1 parent 6827e93 commit 397dffd

File tree

7 files changed

+332
-25
lines changed

7 files changed

+332
-25
lines changed

docs/diff-tool.custom.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var resolvedTool = DiffTools.AddToolBasedOn(
4040
Left: (temp, target) => $"\"custom args \"{target}\" \"{temp}\"",
4141
Right: (temp, target) => $"\"custom args \"{temp}\" \"{target}\""))!;
4242
```
43-
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L85-L94' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddToolBasedOn' title='Start of snippet'>anchor</a></sup>
43+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L86-L95' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddToolBasedOn' title='Start of snippet'>anchor</a></sup>
4444
<!-- endSnippet -->
4545

4646

@@ -70,7 +70,7 @@ var resolvedTool = DiffTools.AddToolBasedOn(
7070

7171
await DiffRunner.LaunchAsync(resolvedTool!, "PathToTempFile", "PathToTargetFile");
7272
```
73-
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L99-L110' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddToolAndLaunch' title='Start of snippet'>anchor</a></sup>
73+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L100-L111' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddToolAndLaunch' title='Start of snippet'>anchor</a></sup>
7474
<!-- endSnippet -->
7575

7676

docs/diff-tool.order.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ For example `VisualStudio,Meld` will result in VisualStudio then Meld then all o
5252
```cs
5353
DiffTools.UseOrder(DiffTool.VisualStudio, DiffTool.AraxisMerge);
5454
```
55-
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L182-L186' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseOrder' title='Start of snippet'>anchor</a></sup>
55+
<sup><a href='/src/DiffEngine.Tests/DiffToolsTest.cs#L183-L187' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseOrder' title='Start of snippet'>anchor</a></sup>
5656
<!-- endSnippet -->
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
global using System.Collections.Immutable;
2-
global using System.Management;
32
global using EmptyFiles;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
public class WindowsProcessTests(ITestOutputHelper output) :
2+
XunitContextBase(output)
3+
{
4+
[Theory]
5+
[InlineData("\"C:\\Program Files\\Beyond Compare 4\\BComp.exe\" C:\\temp\\file.1.txt C:\\temp\\file.2.txt", true)]
6+
[InlineData("notepad.exe C:\\Users\\test\\doc.1.txt C:\\Users\\test\\doc.2.txt", true)]
7+
[InlineData("\"C:\\diff\\tool.exe\" D:\\path\\to\\source.1.cs D:\\path\\to\\target.2.cs", true)]
8+
[InlineData("code.exe --diff file.a.b file.c.d", true)]
9+
[InlineData("app.exe path.with.dots path.more.dots", true)]
10+
public void MatchesPattern_WithTwoFilePaths_ReturnsTrue(string commandLine, bool expected) =>
11+
Assert.Equal(expected, WindowsProcess.MatchesPattern(commandLine));
12+
13+
[Theory]
14+
[InlineData("notepad.exe")]
15+
[InlineData("notepad.exe C:\\temp\\file.txt")]
16+
[InlineData("cmd.exe /c dir")]
17+
[InlineData("explorer.exe")]
18+
[InlineData("")]
19+
[InlineData("singleword")]
20+
[InlineData("app.exe onepath.with.dots")]
21+
public void MatchesPattern_WithoutTwoFilePaths_ReturnsFalse(string commandLine) =>
22+
Assert.False(WindowsProcess.MatchesPattern(commandLine));
23+
24+
[Fact]
25+
public void FindAll_ReturnsProcessCommands()
26+
{
27+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
28+
{
29+
return;
30+
}
31+
32+
var result = WindowsProcess.FindAll();
33+
Assert.NotNull(result);
34+
foreach (var cmd in result)
35+
{
36+
Debug.WriteLine($"{cmd.Process}: {cmd.Command}");
37+
}
38+
}
39+
}

src/DiffEngine/DiffEngine.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<Using Include="DiffEngine" />
8-
<Using Include="System.Management" />
8+
<Using Include="System.Text" />
99
<Using Include="Microsoft.Win32.SafeHandles" />
1010
<Using Include="System.Diagnostics.CodeAnalysis" />
1111
<Using Include="System.Net" />
@@ -21,11 +21,9 @@
2121
<PackageReference Include="System.Collections.Immutable"
2222
Condition="'$(TargetFramework)' != 'net8.0' AND '$(TargetFramework)' != 'net9.0' AND '$(TargetFramework)' != 'net10.0'" />
2323
<PackageReference Include="Polyfill" PrivateAssets="all" />
24-
<PackageReference Include="System.Management" />
2524
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
2625
</ItemGroup>
2726
<Target Name="CheckPackageVersion" BeforeTargets="Build">
2827
<Error Condition="'%(PackageVersion.Identity)' == 'System.Collections.Immutable' AND '%(PackageVersion.Version)' != '8.0.0'" Text="Invalid package version for System.Collections.Immutable. Expected: 8.0.0." />
29-
<Error Condition="'%(PackageVersion.Identity)' == 'System.Management' AND '%(PackageVersion.Version)' != '8.0.0'" Text="Invalid package version for System.Management. Expected: 8.0.0." />
3028
</Target>
3129
</Project>

0 commit comments

Comments
 (0)