Skip to content

Commit 2b79b4b

Browse files
committed
Apply code review feedback
1 parent 0ebc055 commit 2b79b4b

File tree

3 files changed

+7
-50
lines changed

3 files changed

+7
-50
lines changed

src/Tests/dotnet-MsiInstallation.Tests/VMControl.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
94
using Microsoft.DotNet.Cli.Utils;
105
using Microsoft.DotNet.Installer.Windows;
116
using Microsoft.Management.Infrastructure;
127
using Microsoft.Management.Infrastructure.Serialization;
13-
using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext;
148

159
namespace Microsoft.DotNet.MsiInstallerTests
1610
{
@@ -101,16 +95,6 @@ public CommandResult RunCommandOnVM(string[] args, string workingDirectory = nul
10195
private IEnumerable<CimInstance> GetSnapshotInstances()
10296
{
10397
var snapshots = _session.QueryInstances(virtNamespace, "WQL", $"SELECT * FROM Msvm_VirtualSystemSettingData WHERE VirtualSystemIdentifier='{VMInstance.CimInstanceProperties["Name"].Value}' And IsSaved='True'").ToList();
104-
//Log.WriteLine("Snapshot count: " + snapshots.Count);
105-
//foreach (var snapshot in snapshots)
106-
//{
107-
// Log.WriteLine(snapshot.CimInstanceProperties["ElementName"].Value.ToString());
108-
// //Log.WriteLine(snapshot.ToString());
109-
// //foreach (var prop in snapshot.CimInstanceProperties)
110-
// //{
111-
// // Log.WriteLine($"\t{prop.Name}: {prop.Value}");
112-
// //}
113-
//}
11498

11599
return snapshots;
116100
}
@@ -126,20 +110,12 @@ public async Task RenameSnapshotAsync(string snapshotId, string newName)
126110

127111
var managementService = _session.QueryInstances(@"root\virtualization\v2", "WQL", "SELECT * FROM Msvm_VirtualSystemManagementService").Single();
128112
var modifyVmMethod = managementService.CimClass.CimClassMethods.Single(m => m.Name == "ModifySystemSettings");
129-
//foreach (var param in modifyVmMethod.Parameters)
130-
//{
131-
// Log.WriteLine($"{param.Name}: {param.CimType}");
132-
//}
133113

134114
var snapshot = snapshots.Single(s => s.CimInstanceProperties["ConfigurationID"].Value.ToString() == snapshotId);
135115

136116
snapshot.CimInstanceProperties["ElementName"].Value = newName;
137117

138118
Log.WriteLine("Renaming snapshot " + snapshotId + " to " + newName);
139-
//foreach (var prop in snapshot.CimInstanceProperties)
140-
//{
141-
// Log.WriteLine($"\t{prop.Name}: {prop.Value}");
142-
//}
143119

144120
CimSerializer serializer = CimSerializer.Create();
145121
var snapshotString = Encoding.Unicode.GetString(serializer.Serialize(snapshot, InstanceSerializationOptions.None));
@@ -279,10 +255,6 @@ private async Task WaitForJobSuccess(CimMethodResult result)
279255
if (jobState != JobState.Completed && jobState != JobState.CompletedWithWarnings)
280256
{
281257
Log.WriteLine("Job failed: " + jobState);
282-
//foreach (var prop in job.CimInstanceProperties)
283-
//{
284-
// Log.WriteLine($"\t{prop.Name}: {prop.Value}");
285-
//}
286258

287259
string exceptionText = "Job failed: " + jobState;
288260

src/Tests/dotnet-MsiInstallation.Tests/VMStateTree.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
9-
104
namespace Microsoft.DotNet.MsiInstallerTests
115
{
126
internal class VMStateTree
@@ -18,18 +12,18 @@ internal class VMStateTree
1812

1913
public Dictionary<SerializedVMAction, VMActionResult> ReadOnlyActions { get; set; } = new();
2014

21-
public SerializeableVMStateTree ToSerializeable()
15+
public SerializableVMStateTree ToSerializeable()
2216
{
23-
return new SerializeableVMStateTree()
17+
return new SerializableVMStateTree()
2418
{
2519
SnapshotId = SnapshotId,
2620
SnapshotName = SnapshotName,
27-
Actions = Actions.Select(a => new SerializeableVMStateTree.Entry() {
21+
Actions = Actions.Select(a => new SerializableVMStateTree.Entry() {
2822
Action = a.Key,
2923
ActionResult = a.Value.actionResult,
3024
ResultingState = a.Value.resultingState.ToSerializeable()
3125
}).ToList(),
32-
ReadOnlyActions = ReadOnlyActions.Select(a => new SerializeableVMStateTree.ReadOnlyEntry()
26+
ReadOnlyActions = ReadOnlyActions.Select(a => new SerializableVMStateTree.ReadOnlyEntry()
3327
{
3428
Action = a.Key,
3529
ActionResult = a.Value
@@ -39,7 +33,7 @@ public SerializeableVMStateTree ToSerializeable()
3933
}
4034
}
4135

42-
internal class SerializeableVMStateTree
36+
internal class SerializableVMStateTree
4337
{
4438
public string SnapshotId { get; set; }
4539
public string SnapshotName { get; set; }
@@ -53,7 +47,7 @@ public class Entry
5347
{
5448
public SerializedVMAction Action { get; set; }
5549
public VMActionResult ActionResult { get; set; }
56-
public SerializeableVMStateTree ResultingState { get; set; }
50+
public SerializableVMStateTree ResultingState { get; set; }
5751
}
5852

5953
public class ReadOnlyEntry

src/Tests/dotnet-MsiInstallation.Tests/VirtualMachine.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
using System.Collections.Generic;
6-
using System.Diagnostics;
7-
using System.Linq;
8-
using System.Text;
94
using System.Text.Json;
105
using System.Text.Json.Serialization;
11-
using System.Threading.Tasks;
12-
using Microsoft.Build.Execution;
13-
using Microsoft.DotNet.Cli.Utils;
146

157
namespace Microsoft.DotNet.MsiInstallerTests
168
{
@@ -77,7 +69,7 @@ public VirtualMachine(ITestOutputHelper log)
7769
if (File.Exists(_stateFile))
7870
{
7971
string json = File.ReadAllText(_stateFile);
80-
_rootState = JsonSerializer.Deserialize<SerializeableVMStateTree>(json, GetSerializerOptions()).ToVMStateTree();
72+
_rootState = JsonSerializer.Deserialize<SerializableVMStateTree>(json, GetSerializerOptions()).ToVMStateTree();
8173
}
8274
else
8375
{
@@ -440,7 +432,6 @@ string VMPathToSharePath(string vmPath)
440432
return $@"\\{VMControl.VMMachineName}\{driveLetter}$\{pathUnderDrive}";
441433
}
442434

443-
// Copilot wrote the entire body of this method
444435
string SharePathToVMPath(string sharePath)
445436
{
446437
if (!sharePath.StartsWith($@"\\{VMControl.VMMachineName}\"))

0 commit comments

Comments
 (0)