Skip to content

Commit

Permalink
Merge 9ff3e52 into acbd871
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaring authored Jul 11, 2020
2 parents acbd871 + 9ff3e52 commit 5567be7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Tests/123_InheritCustomAttr.Test/InheritCustomAttributeTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using Confuser.Core;
using Confuser.Core.Project;
using Confuser.Renamer;
using Confuser.UnitTest;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -15,13 +17,15 @@ public class InheritCustomAttributeTest {
public InheritCustomAttributeTest(ITestOutputHelper outputHelper) =>
this.outputHelper = outputHelper ?? throw new ArgumentNullException(nameof(outputHelper));

[Fact]
[Theory]
[MemberData(nameof(InheritCustomAttributeData))]
[Trait("Category", "Protection")]
[Trait("Protection", "rename")]
[Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/123")]
public async Task InheritCustomAttribute() {
[Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/161")]
public async Task InheritCustomAttribute(string renameMode) {
var baseDir = Environment.CurrentDirectory;
var outputDir = Path.Combine(baseDir, "testtmp");
var outputDir = Path.Combine(baseDir, "testtmp_" + Guid.NewGuid().ToString());
var inputFile = Path.Combine(baseDir, "123_InheritCustomAttr.exe");
var outputFile = Path.Combine(outputDir, "123_InheritCustomAttr.exe");
FileUtilities.ClearOutput(outputFile);
Expand All @@ -31,7 +35,9 @@ public async Task InheritCustomAttribute() {
};
proj.Add(new ProjectModule() { Path = inputFile });
proj.Rules.Add(new Rule() {
new SettingItem<Protection>("rename")
new SettingItem<Protection>("rename") {
{ "mode", renameMode }
}
});

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

FileUtilities.ClearOutput(outputFile);
}

public static IEnumerable<object[]> InheritCustomAttributeData() {
foreach (var renameMode in new string[] { nameof(RenameMode.Unicode), nameof(RenameMode.ASCII), nameof(RenameMode.Letters), nameof(RenameMode.Debug) })
yield return new object[] { renameMode };
}
}
}
9 changes: 9 additions & 0 deletions Tests/Confuser.UnitTest/FileUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography;

namespace Confuser.UnitTest {
Expand All @@ -18,6 +19,14 @@ public static void ClearOutput(string outputFile) {
}
}
catch (UnauthorizedAccessException) { }

try {
var directoryName = Path.GetDirectoryName(outputFile);
if (Directory.Exists(directoryName) && !Directory.EnumerateFileSystemEntries(directoryName).Any()) {
Directory.Delete(directoryName);
}
}
catch (UnauthorizedAccessException) { }
}

public static byte[] ComputeFileChecksum(string file) {
Expand Down

0 comments on commit 5567be7

Please # to comment.