From 0719aa9f08f1df4514c9dcd504c744ecb088b5a4 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 17 Jul 2019 18:20:12 +0200 Subject: [PATCH] Enable DecompilerSettings.IntroduceLocalFunctions --- ICSharpCode.Decompiler/CSharp/StatementBuilder.cs | 3 ++- ICSharpCode.Decompiler/DecompilerSettings.cs | 11 ++++------- ILSpy/Properties/Resources.Designer.cs | 6 +++--- ILSpy/Properties/Resources.resx | 4 ++-- ILSpy/Properties/Resources.zh-Hans.resx | 6 +++--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs index bd72ac66d..25d8658ba 100644 --- a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs @@ -726,7 +726,8 @@ namespace ICSharpCode.Decompiler.CSharp /// /// Determines whether storeInst.Variable is only assigned once and used only inside . - /// Loads by reference (ldloca) are only allowed in the context of this pointer in call instructions. + /// Loads by reference (ldloca) are only allowed in the context of this pointer in call instructions, + /// or as target of ldobj. /// (This only applies to value types.) /// bool VariableIsOnlyUsedInBlock(StLoc storeInst, BlockContainer usingContainer) diff --git a/ICSharpCode.Decompiler/DecompilerSettings.cs b/ICSharpCode.Decompiler/DecompilerSettings.cs index f6e7a94dd..ed6f98191 100644 --- a/ICSharpCode.Decompiler/DecompilerSettings.cs +++ b/ICSharpCode.Decompiler/DecompilerSettings.cs @@ -945,19 +945,16 @@ namespace ICSharpCode.Decompiler bool localFunctions = true; /// - /// Gets/Sets whether C# 7.0 local functions should be used. - /// Note: this language feature is currently not implemented and this setting is always false. + /// Gets/Sets whether C# 7.0 local functions should be transformed. /// [Category("C# 7.0 / VS 2017")] - [Description("DecompilerSettings.IntroduceLocalFunctionsNOTIMPLEMENTED")] - [Browsable(false)] + [Description("DecompilerSettings.IntroduceLocalFunctions")] public bool LocalFunctions { get { return localFunctions; } set { if (localFunctions != value) { - throw new NotImplementedException("C# 7.0 local functions are not implemented!"); - //localFunctions = value; - //OnPropertyChanged(); + localFunctions = value; + OnPropertyChanged(); } } } diff --git a/ILSpy/Properties/Resources.Designer.cs b/ILSpy/Properties/Resources.Designer.cs index 5c86e06e2..9a8af3ff6 100644 --- a/ILSpy/Properties/Resources.Designer.cs +++ b/ILSpy/Properties/Resources.Designer.cs @@ -700,11 +700,11 @@ namespace ICSharpCode.ILSpy.Properties { } /// - /// Looks up a localized string similar to Introduce local functions (NOT IMPLEMENTED!). + /// Looks up a localized string similar to Introduce local functions. /// - public static string DecompilerSettings_IntroduceLocalFunctionsNOTIMPLEMENTED { + public static string DecompilerSettings_IntroduceLocalFunctions { get { - return ResourceManager.GetString("DecompilerSettings.IntroduceLocalFunctionsNOTIMPLEMENTED", resourceCulture); + return ResourceManager.GetString("DecompilerSettings.IntroduceLocalFunctions", resourceCulture); } } diff --git a/ILSpy/Properties/Resources.resx b/ILSpy/Properties/Resources.resx index 0128389d9..60701dc91 100644 --- a/ILSpy/Properties/Resources.resx +++ b/ILSpy/Properties/Resources.resx @@ -702,8 +702,8 @@ Remove optional arguments, if possible - - Introduce local functions (NOT IMPLEMENTED!) + + Introduce local functions Nullable reference types diff --git a/ILSpy/Properties/Resources.zh-Hans.resx b/ILSpy/Properties/Resources.zh-Hans.resx index 4ab21794f..4f04dba0b 100644 --- a/ILSpy/Properties/Resources.zh-Hans.resx +++ b/ILSpy/Properties/Resources.zh-Hans.resx @@ -676,7 +676,7 @@ IsByRefLikeAttribute应替换为结构上的 "ref" 修饰符 - IsReadOnlyAttribute 应替为结构参数上的 "readonly"/"中的修饰符 + IsReadOnlyAttribute 应替为结构参数上的 "readonly"/"in"中的修饰符 类型参数上的IsUnmanagedAttribute 应替换为 "非托管" 约束 @@ -702,8 +702,8 @@ 如果可能, 删除可选参数 - - 引入本地功能 (未实现!) + + 引入本地功能 C# 7.0 本地函数未实现!