Skip to content

Commit abb79a7

Browse files
committed
Remove needless variables
1 parent 1502d6a commit abb79a7

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

BrowserGuard.Tests/UploadFileBridge/PathMacroTests.cs renamed to BrowserGuard.Tests/Common/PathMacroTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using Xunit;
3-
using BrowserGuard.UploadFileBridge;
3+
using BrowserGuard.Common;
44

5-
namespace BrowserGuard.Tests.UploadFileBridge
5+
namespace BrowserGuard.Tests.Common
66
{
77
public class PathMacroTests
88
{
@@ -33,7 +33,7 @@ public void PutsTheMachineAndTheUserIntoThePath()
3333
{
3434
var expanded = PathMacro.Expand(@"\\server\%PCNAME%\%USERID%", Now);
3535

36-
Assert.Equal($@"\\server\{Environment.MachineName}\{Environment.UserName}", expanded);
36+
Assert.Equal($@"\\server\{System.Environment.MachineName}\{System.Environment.UserName}", expanded);
3737
}
3838

3939
[Fact]
@@ -42,7 +42,7 @@ public void ExpandsSeveralMacrosInOnePath()
4242
var expanded = PathMacro.Expand(@"\\server\%PCNAME%\%DATE%\%USERID%", Now);
4343

4444
Assert.Equal(
45-
$@"\\server\{Environment.MachineName}\2026-08-20\{Environment.UserName}",
45+
$@"\\server\{System.Environment.MachineName}\2026-08-20\{System.Environment.UserName}",
4646
expanded);
4747
}
4848

@@ -52,7 +52,7 @@ public void ExpandsSeveralMacrosInOnePath()
5252
[InlineData("%PCNAME%")]
5353
public void DoesNotMindHowTheMacroIsSpelled(string macro)
5454
{
55-
Assert.Equal(Environment.MachineName, PathMacro.Expand(macro, Now));
55+
Assert.Equal(System.Environment.MachineName, PathMacro.Expand(macro, Now));
5656
}
5757

5858
// Dropping it would quietly put every machine in the same folder, where

BrowserGuard/UploadFileBridge/PathMacro.cs renamed to BrowserGuard/Common/PathMacro.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System;
22
using System.Globalization;
33
using System.Text.RegularExpressions;
4-
using BrowserGuard.NetLogger;
54

6-
namespace BrowserGuard.UploadFileBridge
5+
namespace BrowserGuard.Common
76
{
87
// A destination folder is written with macros, so that one setting can
98
// spread what it writes over a folder per machine, per user or per day
@@ -31,8 +30,8 @@ internal static string Expand(string text, DateTime now)
3130
private static string? Resolve(string name, DateTime now) =>
3231
name.ToUpperInvariant() switch
3332
{
34-
"PCNAME" => NetLogEntry.MachineName,
35-
"USERID" => NetLogEntry.UserName,
33+
"PCNAME" => Environment.MachineName,
34+
"USERID" => Environment.UserName,
3635
"DATE" => now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture),
3736
"YYYY" => now.ToString("yyyy", CultureInfo.InvariantCulture),
3837
"MM" => now.ToString("MM", CultureInfo.InvariantCulture),

‎BrowserGuard/NetLogger/NetLogEntry.cs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ internal static class NetLogEntry
1414
internal const string MachineProperty = "pcname";
1515
internal const string UserProperty = "userid";
1616

17-
internal static readonly string MachineName = Environment.MachineName;
18-
internal static readonly string UserName = Environment.UserName;
19-
2017
// The log is read back as text, so the escaping is relaxed to leave
2118
// Japanese page titles legible rather than as \uXXXX escapes.
2219
private static readonly JsonWriterOptions WriterOptions = new()
@@ -74,8 +71,8 @@ internal static string UploadFileBridgeFailed(string file, string reason, DateTi
7471
}
7572
property.WriteTo(writer);
7673
}
77-
writer.WriteString(MachineProperty, MachineName);
78-
writer.WriteString(UserProperty, UserName);
74+
writer.WriteString(MachineProperty, Environment.MachineName);
75+
writer.WriteString(UserProperty, Environment.UserName);
7976
writer.WriteEndObject();
8077
}
8178
line = Encoding.UTF8.GetString(buffer.ToArray());

0 commit comments

Comments
 (0)