Skip to content

Commit 1e9ed11

Browse files
committed
Automatic code cleanup
1 parent 9233f5e commit 1e9ed11

File tree

325 files changed

+7726
-5019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+7726
-5019
lines changed

Assets/resharper.png

55.5 KB
Loading

Confuser.CLI/Program.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal static int Main(string[] args) {
6565
parameters.Project = proj;
6666
}
6767
catch (Exception ex) {
68-
WriteLineWithColor(ConsoleColor.Red,
68+
WriteLineWithColor(ConsoleColor.Red,
6969
string.Format(Resources.Culture, Resources.ErrorLoadingProjectFailed, ex.ToString()));
7070
return -1;
7171
}
@@ -91,7 +91,8 @@ internal static int Main(string[] args) {
9191
}
9292
catch (Exception ex) {
9393
WriteLineWithColor(ConsoleColor.Red,
94-
string.Format(Resources.Culture, Resources.ErrorLoadingProjectFailed, ex.ToString()));
94+
string.Format(Resources.Culture, Resources.ErrorLoadingProjectFailed,
95+
ex.ToString()));
9596
return -1;
9697
}
9798
}
@@ -109,8 +110,9 @@ internal static int Main(string[] args) {
109110
proj.Debug = debug.HasValue();
110111
parameters.Project = proj;
111112
}
112-
113-
parameters.ConfigureLogging = builder => builder.AddConsole(b => b.IncludeScopes = false).SetMinimumLevel(GetLogLevel(verbosity));
113+
114+
parameters.ConfigureLogging = builder =>
115+
builder.AddConsole(b => b.IncludeScopes = false).SetMinimumLevel(GetLogLevel(verbosity));
114116

115117
int retVal = await RunProject(parameters);
116118

@@ -132,7 +134,7 @@ internal static int Main(string[] args) {
132134
return cmd.Execute(args);
133135
}
134136
catch (Exception ex) {
135-
WriteLineWithColor(ConsoleColor.Red,
137+
WriteLineWithColor(ConsoleColor.Red,
136138
string.Format(Resources.Culture, Resources.ErrorUnexpected, ex.ToString()));
137139

138140
// ReSharper disable once InvertIf
@@ -148,6 +150,7 @@ internal static int Main(string[] args) {
148150
Console.Title = originalTitle;
149151
}
150152
}
153+
151154
private static ConfuserProject LoadConfuserProject(string projFile) {
152155
var proj = new ConfuserProject();
153156
var xmlDoc = new XmlDocument();
@@ -188,7 +191,6 @@ private static LogLevel GetLogLevel(CommandOption verbosityOption) {
188191
default:
189192
return LogLevel.Information;
190193
}
191-
192194
}
193195

194196
private static bool NeedPause() =>

Confuser.Core.Exports/EmptyProtectionParameters.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ public sealed class EmptyProtectionParameters : IProtectionParameters {
99

1010
IImmutableList<IDnlibDef> IProtectionParameters.Targets => ImmutableArray.Create<IDnlibDef>();
1111

12-
private EmptyProtectionParameters() { }
12+
private EmptyProtectionParameters() {
13+
}
1314

14-
T IProtectionParameters.GetParameter<T>(IConfuserContext context, IDnlibDef target, IProtectionParameter<T> parameter) {
15+
T IProtectionParameters.GetParameter<T>(IConfuserContext context, IDnlibDef target,
16+
IProtectionParameter<T> parameter) {
1517
if (context == null) throw new ArgumentNullException(nameof(context));
1618
if (target == null) throw new ArgumentNullException(nameof(target));
1719
if (parameter == null) throw new ArgumentNullException(nameof(parameter));

Confuser.Core.Exports/Helpers/ControlFlowGraph.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ void PopulateBlockHeaders(HashSet<Instruction> blockHeaders, HashSet<Instruction
8888
if (i + 1 < body.Instructions.Count)
8989
blockHeaders.Add(body.Instructions[i + 1]);
9090
}
91-
else if ((instr.OpCode.FlowControl == FlowControl.Throw || instr.OpCode.FlowControl == FlowControl.Return) &&
91+
else if ((instr.OpCode.FlowControl == FlowControl.Throw ||
92+
instr.OpCode.FlowControl == FlowControl.Return) &&
9293
i + 1 < body.Instructions.Count) {
9394
blockHeaders.Add(body.Instructions[i + 1]);
9495
}
9596
}
97+
9698
blockHeaders.Add(body.Instructions[0]);
9799
foreach (ExceptionHandler eh in body.ExceptionHandlers) {
98100
blockHeaders.Add(eh.TryStart);
@@ -117,7 +119,8 @@ void SplitBlocks(HashSet<Instruction> blockHeaders, HashSet<Instruction> entryHe
117119
var type = ControlFlowBlockType.Normal;
118120
if (entryHeaders.Contains(currentBlockHdr) || currentBlockHdr == body.Instructions[0])
119121
type |= ControlFlowBlockType.Entry;
120-
if (footer.OpCode.FlowControl == FlowControl.Return || footer.OpCode.FlowControl == FlowControl.Throw)
122+
if (footer.OpCode.FlowControl == FlowControl.Return ||
123+
footer.OpCode.FlowControl == FlowControl.Throw)
121124
type |= ControlFlowBlockType.Exit;
122125

123126
blocks.Add(new ControlFlowBlock(currentBlockId, type, currentBlockHdr, footer));
@@ -129,6 +132,7 @@ void SplitBlocks(HashSet<Instruction> blockHeaders, HashSet<Instruction> entryHe
129132

130133
instrBlocks[i] = currentBlockId;
131134
}
135+
132136
if (blocks.Count == 0 || blocks[blocks.Count - 1].Id != currentBlockId) {
133137
Instruction footer = body.Instructions[body.Instructions.Count - 1];
134138

@@ -160,6 +164,7 @@ void LinkBlocks() {
160164
}
161165
}
162166
}
167+
163168
for (int i = 0; i < blocks.Count; i++) {
164169
if (blocks[i].Footer.OpCode.FlowControl != FlowControl.Branch &&
165170
blocks[i].Footer.OpCode.FlowControl != FlowControl.Return &&

Confuser.Core.Exports/Helpers/KeySequence.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static BlockKey[] ComputeKeys(ControlFlowGraph graph, IRandomGenerator ra
4040
key.Type = BlockKeyType.Incremental;
4141
keys[block.Id] = key;
4242
}
43+
4344
ProcessBlocks(keys, graph, random);
4445
return keys;
4546
}
@@ -68,13 +69,15 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, IRandomGenera
6869
updated = true;
6970
}
7071
}
72+
7173
if (block.Targets.Count > 0) {
7274
uint newExit = block.Targets.Select(b => keys[b.Id].EntryState).Max();
7375
if (key.ExitState != newExit) {
7476
key.ExitState = newExit;
7577
updated = true;
7678
}
7779
}
80+
7881
if (block.Footer.OpCode.Code == Code.Endfilter || block.Footer.OpCode.Code == Code.Endfinally) {
7982
// Match the exit state within finally/fault/filter
8083
List<ExceptionHandler> ehs;
@@ -84,18 +87,20 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, IRandomGenera
8487
foreach (var eh in graph.Body.ExceptionHandlers) {
8588
if (eh.FilterStart != null && block.Footer.OpCode.Code == Code.Endfilter) {
8689
if (footerIndex >= graph.IndexOf(eh.FilterStart) &&
87-
footerIndex < graph.IndexOf(eh.HandlerStart))
90+
footerIndex < graph.IndexOf(eh.HandlerStart))
8891
ehs.Add(eh);
8992
}
9093
else if (eh.HandlerType == ExceptionHandlerType.Finally ||
91-
eh.HandlerType == ExceptionHandlerType.Fault) {
94+
eh.HandlerType == ExceptionHandlerType.Fault) {
9295
if (footerIndex >= graph.IndexOf(eh.HandlerStart) &&
93-
(eh.HandlerEnd == null || footerIndex < graph.IndexOf(eh.HandlerEnd)))
96+
(eh.HandlerEnd == null || footerIndex < graph.IndexOf(eh.HandlerEnd)))
9497
ehs.Add(eh);
9598
}
9699
}
100+
97101
ehMap[block] = ehs;
98102
}
103+
99104
foreach (var eh in ehs) {
100105
uint ehVal;
101106
if (finallyIds.TryGetValue(eh, out ehVal)) {
@@ -122,9 +127,10 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, IRandomGenera
122127
int footerIndex = graph.IndexOf(block.Footer);
123128
foreach (var eh in graph.Body.ExceptionHandlers) {
124129
if (footerIndex >= graph.IndexOf(eh.TryStart) &&
125-
(eh.TryEnd == null || footerIndex < graph.IndexOf(eh.TryEnd)))
130+
(eh.TryEnd == null || footerIndex < graph.IndexOf(eh.TryEnd)))
126131
ehs.Add(eh);
127132
}
133+
128134
ehMap[block] = ehs;
129135
}
130136

@@ -137,6 +143,7 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, IRandomGenera
137143
maxVal = ehVal;
138144
}
139145
}
146+
140147
if (maxVal != null) {
141148
if (key.ExitState > maxVal.Value) {
142149
maxVal = key.ExitState;
@@ -146,10 +153,12 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, IRandomGenera
146153
key.ExitState = maxVal.Value;
147154
updated = true;
148155
}
156+
149157
foreach (var eh in ehs)
150158
finallyIds[eh] = maxVal.Value;
151159
}
152160
}
161+
153162
keys[block.Id] = key;
154163
}
155164
} while (updated);

Confuser.Core.Exports/IPacker.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Threading.Tasks;
77

88
namespace Confuser.Core {
9-
109
/// <summary>
1110
/// Base class of Confuser packers.
1211
/// </summary>

Confuser.Core.Exports/IPackerMetadata.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Confuser.Core {
99
public interface IPackerMetadata {
1010
string Id { get; }
1111

12-
[DefaultValue(null)]
13-
string MarkerId { get; }
12+
[DefaultValue(null)] string MarkerId { get; }
1413
}
1514
}

Confuser.Core.Exports/IProtectionMetadata.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Confuser.Core {
99
public interface IProtectionMetadata {
1010
string Id { get; }
1111

12-
[DefaultValue(null)]
13-
string MarkerId { get; }
12+
[DefaultValue(null)] string MarkerId { get; }
1413
}
1514
}

Confuser.Core.Exports/IRuntimeModuleBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Confuser.Core {
99
public interface IRuntimeModuleBuilder {
10-
void AddImplementation(string targetFrameworkName, Func<Stream> assemblyStreamFactory, Func<Stream> debugSymbolStreamFactory);
10+
void AddImplementation(string targetFrameworkName, Func<Stream> assemblyStreamFactory,
11+
Func<Stream> debugSymbolStreamFactory);
1112
}
1213
}

Confuser.Core.Exports/Parameter/BooleanProtectionParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace Confuser.Core.Parameter {
55
internal sealed class BooleanProtectionParameter : IProtectionParameter<bool> {
6-
76
public bool DefaultValue { get; }
87

98
public string Name { get; }
@@ -30,6 +29,7 @@ bool IProtectionParameter<bool>.Deserialize(string serializedValue) {
3029
case "0":
3130
return false;
3231
}
32+
3333
throw new SerializationException($"Value {serializedValue} can't be deserialized to boolean.");
3434
}
3535

0 commit comments

Comments
 (0)