Skip to content

Commit 5567be7

Browse files
authored
Merge 9ff3e52 into acbd871
2 parents acbd871 + 9ff3e52 commit 5567be7

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Tests/123_InheritCustomAttr.Test/InheritCustomAttributeTest.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Diagnostics;
34
using System.IO;
45
using System.Threading.Tasks;
56
using Confuser.Core;
67
using Confuser.Core.Project;
8+
using Confuser.Renamer;
79
using Confuser.UnitTest;
810
using Xunit;
911
using Xunit.Abstractions;
@@ -15,13 +17,15 @@ public class InheritCustomAttributeTest {
1517
public InheritCustomAttributeTest(ITestOutputHelper outputHelper) =>
1618
this.outputHelper = outputHelper ?? throw new ArgumentNullException(nameof(outputHelper));
1719

18-
[Fact]
20+
[Theory]
21+
[MemberData(nameof(InheritCustomAttributeData))]
1922
[Trait("Category", "Protection")]
2023
[Trait("Protection", "rename")]
2124
[Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/123")]
22-
public async Task InheritCustomAttribute() {
25+
[Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/161")]
26+
public async Task InheritCustomAttribute(string renameMode) {
2327
var baseDir = Environment.CurrentDirectory;
24-
var outputDir = Path.Combine(baseDir, "testtmp");
28+
var outputDir = Path.Combine(baseDir, "testtmp_" + Guid.NewGuid().ToString());
2529
var inputFile = Path.Combine(baseDir, "123_InheritCustomAttr.exe");
2630
var outputFile = Path.Combine(outputDir, "123_InheritCustomAttr.exe");
2731
FileUtilities.ClearOutput(outputFile);
@@ -31,7 +35,9 @@ public async Task InheritCustomAttribute() {
3135
};
3236
proj.Add(new ProjectModule() { Path = inputFile });
3337
proj.Rules.Add(new Rule() {
34-
new SettingItem<Protection>("rename")
38+
new SettingItem<Protection>("rename") {
39+
{ "mode", renameMode }
40+
}
3541
});
3642

3743
var parameters = new ConfuserParameters {
@@ -62,5 +68,10 @@ public async Task InheritCustomAttribute() {
6268

6369
FileUtilities.ClearOutput(outputFile);
6470
}
71+
72+
public static IEnumerable<object[]> InheritCustomAttributeData() {
73+
foreach (var renameMode in new string[] { nameof(RenameMode.Unicode), nameof(RenameMode.ASCII), nameof(RenameMode.Letters), nameof(RenameMode.Debug) })
74+
yield return new object[] { renameMode };
75+
}
6576
}
6677
}

Tests/Confuser.UnitTest/FileUtilities.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Linq;
34
using System.Security.Cryptography;
45

56
namespace Confuser.UnitTest {
@@ -18,6 +19,14 @@ public static void ClearOutput(string outputFile) {
1819
}
1920
}
2021
catch (UnauthorizedAccessException) { }
22+
23+
try {
24+
var directoryName = Path.GetDirectoryName(outputFile);
25+
if (Directory.Exists(directoryName) && !Directory.EnumerateFileSystemEntries(directoryName).Any()) {
26+
Directory.Delete(directoryName);
27+
}
28+
}
29+
catch (UnauthorizedAccessException) { }
2130
}
2231

2332
public static byte[] ComputeFileChecksum(string file) {

0 commit comments

Comments
 (0)