Skip to content

Commit

Permalink
#1049: add back some decompiler settings
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Jan 29, 2018
1 parent ebf213d commit 7cbcdd9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
Expand Up @@ -402,6 +402,10 @@ protected internal override Statement VisitUsingInstruction(UsingInstruction ins

Statement TransformToForeach(UsingInstruction inst, out Expression resource)
{
if (!settings.ForEachStatement) {
resource = null;
return null;
}
// Check if the using resource matches the GetEnumerator pattern.
resource = exprBuilder.Translate(inst.ResourceExpression);
var m = getEnumeratorPattern.Match(resource);
Expand Down
Expand Up @@ -236,6 +236,7 @@ bool ForStatementUsesVariable(ForStatement statement, IL.ILVariable variable)

Statement TransformForeachOnArray(ForStatement forStatement)
{
if (!context.Settings.ForEachStatement) return null;
Match m = forOnArrayPattern.Match(forStatement);
if (!m.Success) return null;
var itemVariable = m.Get<IdentifierExpression>("itemVariable").Single().GetILVariable();
Expand Down Expand Up @@ -363,6 +364,7 @@ bool MatchForeachOnMultiDimArray(IL.ILVariable[] upperBounds, IL.ILVariable coll

Statement TransformForeachOnMultiDimArray(ExpressionStatement expressionStatement)
{
if (!context.Settings.ForEachStatement) return null;
Match m;
Statement stmt = expressionStatement;
IL.ILVariable collection = null;
Expand Down
Expand Up @@ -33,6 +33,7 @@ public class TransformCollectionAndObjectInitializers : IStatementTransform

void IStatementTransform.Run(Block block, int pos, StatementTransformContext context)
{
if (!context.Settings.ObjectOrCollectionInitializers) return;
this.context = context;
try {
DoTransform(block, pos);
Expand Down
Expand Up @@ -99,6 +99,7 @@ bool MatchParameterVariableAssignment(ILInstruction expr, out ILVariable paramet

public void Run(Block block, int pos, StatementTransformContext context)
{
if (!context.Settings.ExpressionTrees) return;
this.context = context;
this.conversions = CSharpConversions.Get(context.TypeSystem.Compilation);
this.resolver = new CSharpResolver(context.TypeSystem.Compilation);
Expand Down

0 comments on commit 7cbcdd9

Please sign in to comment.