From 0764fd7ca77e5ca21e080a1f5dced4e5c9f538fd Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 22 Apr 2011 23:47:28 +0200 Subject: [PATCH] Fixed issue in lambda decompilation when a closure class contains static fields (cached delegates). --- ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs | 2 ++ ICSharpCode.Decompiler/DecompilerSettings.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs b/ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs index 1e0ce47bf..c37957f5f 100644 --- a/ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs +++ b/ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs @@ -369,6 +369,8 @@ namespace ICSharpCode.Decompiler.Ast.Transforms // Now create variables for all fields of the display class (except for those that we already handled as parameters) List> variablesToDeclare = new List>(); foreach (FieldDefinition field in type.Fields) { + if (field.IsStatic) + continue; // skip static fields if (dict.ContainsKey(field)) // skip field if it already was handled as parameter continue; EnsureVariableNameIsAvailable(blockStatement, field.Name); diff --git a/ICSharpCode.Decompiler/DecompilerSettings.cs b/ICSharpCode.Decompiler/DecompilerSettings.cs index 78ccf7e60..f4a20e047 100644 --- a/ICSharpCode.Decompiler/DecompilerSettings.cs +++ b/ICSharpCode.Decompiler/DecompilerSettings.cs @@ -179,7 +179,7 @@ namespace ICSharpCode.Decompiler } } - bool objectCollectionInitializers; + bool objectCollectionInitializers = true; /// /// Gets/Sets whether to use C# 3.0 object/collection initializers