// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
namespace ICSharpCode.Decompiler
{
///
/// Settings for the decompiler.
///
public partial class DecompilerSettings : INotifyPropertyChanged
{
///
/// Equivalent to new DecompilerSettings(LanguageVersion.Latest)
///
public DecompilerSettings()
{
}
///
/// Creates a new DecompilerSettings instance with initial settings
/// appropriate for the specified language version.
///
///
/// This does not imply that the resulting code strictly uses only language features from
/// that version. Language constructs like generics or ref locals cannot be removed from
/// the compiled code.
/// The language version is a construction shortcut, not state: it initializes the feature
/// flags once (see ) and is not stored afterwards.
///
public DecompilerSettings(CSharp.LanguageVersion languageVersion)
{
SetLanguageVersion(languageVersion);
}
///
/// One-shot profile initializer: deactivates all language features from versions newer than
/// . The version itself is not stored - the feature flags
/// are the only state - so the call is not reversible and a later call with a higher version
/// does not re-enable features. Use to derive a
/// version back from the flags.
///
public partial void SetLanguageVersion(CSharp.LanguageVersion languageVersion);
///
/// Derives the lowest language version that includes all currently enabled language
/// features. The settings do not store a language version, so this derivation is how a
/// version is recovered from the flags; project export uses it as the default (and lower
/// bound) for the LangVersion written into the project file.
///
public partial CSharp.LanguageVersion GetMinimumRequiredVersion();
///
/// Use C# 9 nint/nuint types.
///
[Description("DecompilerSettings.NativeIntegers")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool NativeIntegers { get; set; }
///
/// Treat IntPtr/UIntPtr as nint/nuint.
///
[Description("DecompilerSettings.NumericIntPtr")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp11_0)]
public partial bool NumericIntPtr { get; set; }
///
/// Decompile C# 9 covariant return types.
///
[Description("DecompilerSettings.CovariantReturns")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool CovariantReturns { get; set; }
///
/// Use C# 9 init; property accessors.
///
[Description("DecompilerSettings.InitAccessors")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool InitAccessors { get; set; }
///
/// Use C# 9 record classes.
///
[Description("DecompilerSettings.RecordClasses")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool RecordClasses { get; set; }
///
/// Use C# 10 record structs.
///
[Description("DecompilerSettings.RecordStructs")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp10_0)]
public partial bool RecordStructs { get; set; }
///
/// Use field initializers in structs.
///
[Description("DecompilerSettings.StructDefaultConstructorsAndFieldInitializers")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp10_0)]
public partial bool StructDefaultConstructorsAndFieldInitializers { get; set; }
///
/// Use C# 9 with initializer expressions.
///
[Description("DecompilerSettings.WithExpressions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool WithExpressions { get; set; }
///
/// Use primary constructor syntax with records.
///
[Description("DecompilerSettings.UsePrimaryConstructorSyntax")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool UsePrimaryConstructorSyntax { get; set; }
///
/// Use C# 9 delegate* unmanaged types.
/// If this option is disabled, function pointers will instead be decompiled with type `IntPtr`.
///
[Description("DecompilerSettings.FunctionPointers")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool FunctionPointers { get; set; }
///
/// Use C# 11 scoped modifier.
///
[Description("DecompilerSettings.ScopedRef")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp11_0)]
public partial bool ScopedRef { get; set; }
[Obsolete("Renamed to ScopedRef. This property will be removed in a future version of the decompiler.")]
[Browsable(false)]
public bool LifetimeAnnotations {
get { return ScopedRef; }
set { ScopedRef = value; }
}
///
/// Use C# 11 required modifier.
///
[Description("DecompilerSettings.RequiredMembers")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp11_0)]
public partial bool RequiredMembers { get; set; }
///
/// Use C# 8 switch expressions.
///
[Description("DecompilerSettings.SwitchExpressions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool SwitchExpressions { get; set; }
///
/// Use C# 10 file-scoped namespaces.
///
[Description("DecompilerSettings.FileScopedNamespaces")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp10_0)]
public partial bool FileScopedNamespaces { get; set; }
///
/// Decompile anonymous methods/lambdas.
///
[Description("DecompilerSettings.DecompileAnonymousMethodsLambdas")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp2)]
public partial bool AnonymousMethods { get; set; }
///
/// Decompile anonymous types.
///
[Description("DecompilerSettings.DecompileAnonymousTypes")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp3)]
public partial bool AnonymousTypes { get; set; }
///
/// Use C# 3 lambda syntax if possible.
///
[Description("DecompilerSettings.UseLambdaSyntaxIfPossible")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp3)]
public partial bool UseLambdaSyntax { get; set; }
///
/// Decompile expression trees.
///
[Description("DecompilerSettings.DecompileExpressionTrees")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp3)]
public partial bool ExpressionTrees { get; set; }
///
/// Decompile enumerators.
///
[Description("DecompilerSettings.DecompileEnumeratorsYieldReturn")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp2)]
public partial bool YieldReturn { get; set; }
///
/// Decompile use of the 'dynamic' type.
///
[Description("DecompilerSettings.DecompileUseOfTheDynamicType")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp4)]
public partial bool Dynamic { get; set; }
///
/// Decompile async methods.
///
[Description("DecompilerSettings.DecompileAsyncMethods")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp5)]
public partial bool AsyncAwait { get; set; }
///
/// Decompile await in catch/finally blocks.
/// Only has an effect if is enabled.
///
[Description("DecompilerSettings.DecompileAwaitInCatchFinallyBlocks")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp6)]
public partial bool AwaitInCatchFinally { get; set; }
///
/// Decompile IAsyncEnumerator/IAsyncEnumerable.
/// Only has an effect if is enabled.
///
[Description("DecompilerSettings.AsyncEnumerator")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool AsyncEnumerator { get; set; }
///
/// Decompile [DecimalConstant(...)] as simple literal values.
///
[Description("DecompilerSettings.DecompileDecimalConstantAsSimpleLiteralValues")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool DecimalConstants { get; set; }
///
/// Decompile C# 1.0 'public unsafe fixed int arr[10];' members.
///
[Description("DecompilerSettings.DecompileC10PublicUnsafeFixedIntArr10Members")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool FixedBuffers { get; set; }
///
/// Decompile 'string.Concat(a, b)' calls into 'a + b'.
///
[Description("DecompilerSettings.StringConcat")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool StringConcat { get; set; }
///
/// Use lifted operators for nullables.
///
[Description("DecompilerSettings.UseLiftedOperatorsForNullables")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp2)]
public partial bool LiftNullables { get; set; }
///
/// Decompile C# 6 ?. and ?[] operators.
///
[Description("DecompilerSettings.NullPropagation")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp6)]
public partial bool NullPropagation { get; set; }
///
/// Decompile automatic properties
///
[Description("DecompilerSettings.DecompileAutomaticProperties")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp3)]
public partial bool AutomaticProperties { get; set; }
///
/// Decompile getter-only automatic properties
///
[Description("DecompilerSettings.GetterOnlyAutomaticProperties")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp6)]
public partial bool GetterOnlyAutomaticProperties { get; set; }
///
/// Decompile automatic events
///
[Description("DecompilerSettings.DecompileAutomaticEvents")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool AutomaticEvents { get; set; }
///
/// Decompile using statements.
///
[Description("DecompilerSettings.DetectUsingStatements")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool UsingStatement { get; set; }
///
/// Use enhanced using statements.
///
[Description("DecompilerSettings.UseEnhancedUsing")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool UseEnhancedUsing { get; set; }
///
/// Gets/Sets whether to use braces for single-statement-blocks.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AlwaysUseBraces")]
[DecompilerSetting]
public partial bool AlwaysUseBraces { get; set; }
///
/// Decompile foreach statements.
///
[Description("DecompilerSettings.DetectForeachStatements")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool ForEachStatement { get; set; }
///
/// Support GetEnumerator extension methods in foreach.
///
[Description("DecompilerSettings.DecompileForEachWithGetEnumeratorExtension")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool ForEachWithGetEnumeratorExtension { get; set; }
///
/// Support params collections.
///
[Description("DecompilerSettings.DecompileParamsCollections")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp13_0)]
public partial bool ParamsCollections { get; set; }
///
/// Decompile lock statements.
///
[Description("DecompilerSettings.DetectLockStatements")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool LockStatement { get; set; }
[Description("DecompilerSettings.DetectSwitchOnString")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool SwitchStatementOnString { get; set; }
[Description("DecompilerSettings.SparseIntegerSwitch")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool SparseIntegerSwitch { get; set; }
[Description("DecompilerSettings.InsertUsingDeclarations")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool UsingDeclarations { get; set; }
[Description("DecompilerSettings.UseExtensionMethodSyntax")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp3)]
public partial bool ExtensionMethods { get; set; }
[Description("DecompilerSettings.UseLINQExpressionSyntax")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp3)]
public partial bool QueryExpressions { get; set; }
///
/// Gets/Sets whether to use C# 2.0 method group conversions.
/// true: EventHandler h = this.OnClick;
/// false: EventHandler h = new EventHandler(this.OnClick);
///
[Description("DecompilerSettings.UseImplicitMethodGroupConversions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp2)]
public partial bool UseImplicitMethodGroupConversion { get; set; }
///
/// Gets/Sets whether to use object creation expressions for generic types with new() constraint.
/// true: T t = new T();
/// false: T t = Activator.CreateInstance<T>()
///
[Description("DecompilerSettings.UseObjectCreationOfGenericTypeParameter")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp2)]
public partial bool UseObjectCreationOfGenericTypeParameter { get; set; }
///
/// Gets/Sets whether to always cast targets to explicitly implemented methods.
/// true: ((ISupportInitialize)pictureBox1).BeginInit();
/// false: pictureBox1.BeginInit();
/// default: false
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AlwaysCastTargetsOfExplicitInterfaceImplementationCalls")]
[DecompilerSetting(DefaultValue = false)]
public partial bool AlwaysCastTargetsOfExplicitInterfaceImplementationCalls { get; set; }
///
/// Gets/Sets whether to always qualify member references.
/// true: this.DoSomething();
/// false: DoSomething();
/// default: false
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AlwaysQualifyMemberReferences")]
[DecompilerSetting(DefaultValue = false)]
public partial bool AlwaysQualifyMemberReferences { get; set; }
///
/// Gets/Sets whether to always show enum member values.
/// true: enum Kind { A = 0, B = 1, C = 5 }
/// false: enum Kind { A, B, C = 5 }
/// default: false
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AlwaysShowEnumMemberValues")]
[DecompilerSetting(DefaultValue = false)]
public partial bool AlwaysShowEnumMemberValues { get; set; }
///
/// Gets/Sets whether to use variable names from debug symbols, if available.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.UseVariableNamesFromDebugSymbolsIfAvailable")]
[DecompilerSetting]
public partial bool UseDebugSymbols { get; set; }
///
/// Gets/Sets whether to use array initializers.
/// If set to false, might produce non-compilable code.
///
[Description("DecompilerSettings.ArrayInitializerExpressions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool ArrayInitializers { get; set; }
///
/// Gets/Sets whether to use C# 3.0 object/collection initializers.
///
[Description("DecompilerSettings.ObjectCollectionInitializerExpressions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp3)]
public partial bool ObjectOrCollectionInitializers { get; set; }
///
/// Gets/Sets whether to use C# 6.0 dictionary initializers.
/// Only has an effect if ObjectOrCollectionInitializers is enabled.
///
[Description("DecompilerSettings.DictionaryInitializerExpressions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp6)]
public partial bool DictionaryInitializers { get; set; }
///
/// Gets/Sets whether to use C# 6.0 Extension Add methods in collection initializers.
/// Only has an effect if ObjectOrCollectionInitializers is enabled.
///
[Description("DecompilerSettings.AllowExtensionAddMethodsInCollectionInitializerExpressions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp6)]
public partial bool ExtensionMethodsInCollectionInitializers { get; set; }
///
/// Gets/Sets whether to use local ref variables in cases where this is necessary
/// for re-compilation with a modern C# compiler to reproduce the same behavior
/// as the original assembly produced with an old C# compiler that used an incorrect
/// order of evaluation.
/// See https://github.com/icsharpcode/ILSpy/issues/2050
///
[Description("DecompilerSettings.UseRefLocalsForAccurateOrderOfEvaluation")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool UseRefLocalsForAccurateOrderOfEvaluation { get; set; }
///
/// Gets/Sets whether to use C# 7.2 'ref' extension methods.
///
[Description("DecompilerSettings.AllowExtensionMethodSyntaxOnRef")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_2)]
public partial bool RefExtensionMethods { get; set; }
///
/// Gets/Sets whether to use C# 6.0 string interpolation
///
[Description("DecompilerSettings.UseStringInterpolation")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp6)]
public partial bool StringInterpolation { get; set; }
///
/// Gets/Sets whether to use C# 11.0 UTF-8 string literals
///
[Description("DecompilerSettings.Utf8StringLiterals")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp11_0)]
public partial bool Utf8StringLiterals { get; set; }
///
/// Gets/Sets whether to use C# 11.0 switch on (ReadOnly)Span<char>
///
[Description("DecompilerSettings.SwitchOnReadOnlySpanChar")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp11_0)]
public partial bool SwitchOnReadOnlySpanChar { get; set; }
///
/// Gets/Sets whether to use C# 11.0 unsigned right shift operator.
///
[Description("DecompilerSettings.UnsignedRightShift")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp11_0)]
public partial bool UnsignedRightShift { get; set; }
///
/// Gets/Sets whether to use C# 11.0 user-defined checked operators.
///
[Description("DecompilerSettings.CheckedOperators")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp11_0)]
public partial bool CheckedOperators { get; set; }
///
/// Gets/Sets whether to include XML documentation comments in the decompiled code.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.IncludeXMLDocumentationCommentsInTheDecompiledCode")]
[DecompilerSetting]
public partial bool ShowXmlDocumentation { get; set; }
[Browsable(false)]
[DecompilerSetting(DefaultValue = false)]
public partial bool FoldBraces { get; set; }
[Browsable(false)]
[DecompilerSetting(DefaultValue = false)]
public partial bool ExpandXmlDocumentationComments { get; set; }
[Browsable(false)]
[DecompilerSetting(DefaultValue = false)]
public partial bool ExpandMemberDefinitions { get; set; }
[Browsable(false)]
[DecompilerSetting(DefaultValue = false)]
public partial bool ExpandUsingDeclarations { get; set; }
///
/// Gets/Sets whether member bodies should be decompiled.
///
[Category("DecompilerSettings.Other")]
[Browsable(false)]
[DecompilerSetting]
public partial bool DecompileMemberBodies { get; set; }
///
/// Gets/Sets whether simple calculated getter-only property declarations
/// should use expression body syntax.
///
[Description("DecompilerSettings.UseExpressionBodiedMemberSyntaxForGetOnlyProperties")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp6)]
public partial bool UseExpressionBodyForCalculatedGetterOnlyProperties { get; set; }
///
/// Gets/Sets whether out variable declarations should be used when possible.
///
[Description("DecompilerSettings.UseOutVariableDeclarations")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool OutVariables { get; set; }
///
/// Gets/Sets whether discards should be used when possible.
/// Only has an effect if is enabled.
///
[Description("DecompilerSettings.UseDiscards")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool Discards { get; set; }
///
/// Gets/Sets whether IsByRefLikeAttribute should be replaced with 'ref' modifiers on structs.
///
[Description("DecompilerSettings.IsByRefLikeAttributeShouldBeReplacedWithRefModifiersOnStructs")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_2)]
public partial bool IntroduceRefModifiersOnStructs { get; set; }
///
/// Gets/Sets whether IsReadOnlyAttribute should be replaced with 'readonly' modifiers on structs
/// and with the 'in' modifier on parameters.
///
[Description("DecompilerSettings." +
"IsReadOnlyAttributeShouldBeReplacedWithReadonlyInModifiersOnStructsParameters")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_2)]
public partial bool IntroduceReadonlyAndInModifiers { get; set; }
///
/// Gets/Sets whether "private protected" should be used.
///
[Description("DecompilerSettings.IntroducePrivateProtectedAccessibility")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_2)]
public partial bool IntroducePrivateProtectedAccessibility { get; set; }
[Description("DecompilerSettings.ReadOnlyMethods")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool ReadOnlyMethods { get; set; }
[Description("DecompilerSettings.DetectAsyncUsingAndForeachStatements")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool AsyncUsingAndForEachStatement { get; set; }
///
/// If this option is active, [IsUnmanagedAttribute] on type parameters
/// is replaced with "T : unmanaged" constraints.
///
[Description("DecompilerSettings." +
"IsUnmanagedAttributeOnTypeParametersShouldBeReplacedWithUnmanagedConstraints")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_3)]
public partial bool IntroduceUnmanagedConstraint { get; set; }
///
/// Gets/Sets whether C# 7.3 stackalloc initializers should be used.
///
[Description("DecompilerSettings.UseStackallocInitializerSyntax")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_3)]
public partial bool StackAllocInitializers { get; set; }
///
/// Gets/Sets whether C# 7.3 pattern based fixed statement should be used.
///
[Description("DecompilerSettings.UsePatternBasedFixedStatement")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_3)]
public partial bool PatternBasedFixedStatement { get; set; }
///
/// Gets/Sets whether tuple type syntax (int, string)
/// should be used for System.ValueTuple.
///
[Description("DecompilerSettings.UseTupleTypeSyntax")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool TupleTypes { get; set; }
///
/// Gets/Sets whether throw expressions should be used.
///
[Description("DecompilerSettings.UseThrowExpressions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool ThrowExpressions { get; set; }
///
/// Gets/Sets whether implicit conversions between tuples
/// should be used in the decompiled output.
///
[Description("DecompilerSettings.UseImplicitConversionsBetweenTupleTypes")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool TupleConversions { get; set; }
///
/// Gets/Sets whether tuple comparisons should be detected.
///
[Description("DecompilerSettings.DetectTupleComparisons")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_3)]
public partial bool TupleComparisons { get; set; }
///
/// Gets/Sets whether named arguments should be used.
///
[Description("DecompilerSettings.UseNamedArguments")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp4)]
public partial bool NamedArguments { get; set; }
///
/// Gets/Sets whether C# 7.2 non-trailing named arguments should be used.
///
[Description("DecompilerSettings.UseNonTrailingNamedArguments")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7_2)]
public partial bool NonTrailingNamedArguments { get; set; }
///
/// Gets/Sets whether optional arguments should be removed, if possible.
///
[Description("DecompilerSettings.RemoveOptionalArgumentsIfPossible")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp4)]
public partial bool OptionalArguments { get; set; }
///
/// Gets/Sets whether to expand params arguments by replacing explicit array creation
/// with individual values in method calls.
///
[Description("DecompilerSettings.ExpandParamsArguments")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool ExpandParamsArguments { get; set; }
///
/// Gets/Sets whether C# 7.0 local functions should be transformed.
///
[Description("DecompilerSettings.IntroduceLocalFunctions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool LocalFunctions { get; set; }
///
/// Gets/Sets whether C# 7.0 deconstruction should be detected.
///
[Description("DecompilerSettings.Deconstruction")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool Deconstruction { get; set; }
///
/// Gets/Sets whether C# 7.0 pattern matching should be detected.
///
[Description("DecompilerSettings.PatternMatching")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp7)]
public partial bool PatternMatching { get; set; }
///
/// Gets/Sets whether C# 8.0 recursive patterns should be detected.
///
[Description("DecompilerSettings.RecursivePatternMatching")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool RecursivePatternMatching { get; set; }
///
/// Gets/Sets whether C# 9.0 and, or, not patterns should be detected.
///
[Description("DecompilerSettings.PatternCombinators")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool PatternCombinators { get; set; }
///
/// Gets/Sets whether C# 9.0 relational patterns should be detected.
///
[Description("DecompilerSettings.RelationalPatterns")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp9_0)]
public partial bool RelationalPatterns { get; set; }
///
/// Gets/Sets whether C# 8.0 static local functions should be transformed.
///
[Description("DecompilerSettings.IntroduceStaticLocalFunctions")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool StaticLocalFunctions { get; set; }
///
/// Gets/Sets whether C# 8.0 index and range syntax should be used.
///
[Description("DecompilerSettings.Ranges")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool Ranges { get; set; }
///
/// Gets/Sets whether C# 8.0 nullable reference types are enabled.
///
[Description("DecompilerSettings.NullableReferenceTypes")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp8_0)]
public partial bool NullableReferenceTypes { get; set; }
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.ShowInfoFromDebugSymbolsIfAvailable")]
[Browsable(false)]
[DecompilerSetting(DefaultValue = false)]
public partial bool ShowDebugInfo { get; set; }
#region Options to aid VB decompilation
///
/// Gets/Sets whether the decompiler can assume that 'ldlen; conv.i4.ovf'
/// does not throw an overflow exception.
///
[Category("DecompilerSettings.VBSpecificOptions")]
[Browsable(false)]
[DecompilerSetting]
public partial bool AssumeArrayLengthFitsIntoInt32 { get; set; }
///
/// Gets/Sets whether to use increment and decrement operators
///
[Category("DecompilerSettings.VBSpecificOptions")]
[Browsable(false)]
[DecompilerSetting]
public partial bool IntroduceIncrementAndDecrement { get; set; }
///
/// Gets/Sets whether to use assignment expressions such as in while ((count = Do()) != 0) ;
///
[Category("DecompilerSettings.VBSpecificOptions")]
[Browsable(false)]
[DecompilerSetting]
public partial bool MakeAssignmentExpressions { get; set; }
#endregion
#region Options to aid F# decompilation
[Category("DecompilerSettings.FSpecificOptions")]
[Description("DecompilerSettings.RemoveDeadAndSideEffectFreeCodeUseWithCaution")]
[DecompilerSetting(DefaultValue = false)]
public partial bool RemoveDeadCode { get; set; }
[Category("DecompilerSettings.FSpecificOptions")]
[Description("DecompilerSettings.RemoveDeadStores")]
[DecompilerSetting(DefaultValue = false)]
public partial bool RemoveDeadStores { get; set; }
#endregion
#region Assembly Load and Resolve options
[Browsable(false)]
[DecompilerSetting(DefaultValue = false)]
public partial bool LoadInMemory { get; set; }
[Browsable(false)]
[DecompilerSetting]
public partial bool ThrowOnAssemblyResolveErrors { get; set; }
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.ApplyWindowsRuntimeProjectionsOnLoadedAssemblies")]
[DecompilerSetting]
public partial bool ApplyWindowsRuntimeProjections { get; set; }
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AutoLoadAssemblyReferences")]
[DecompilerSetting]
public partial bool AutoLoadAssemblyReferences { get; set; }
#endregion
///
/// Gets/sets whether the decompiler should produce for loops.
///
[Description("DecompilerSettings.ForStatement")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool ForStatement { get; set; }
///
/// Gets/sets whether the decompiler should produce do-while loops.
///
[Description("DecompilerSettings.DoWhileStatement")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp1)]
public partial bool DoWhileStatement { get; set; }
///
/// Gets/sets whether RequiresLocationAttribute on parameters should be replaced with 'ref readonly' modifiers.
///
[Description("DecompilerSettings.RefReadOnlyParameters")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp12_0)]
public partial bool RefReadOnlyParameters { get; set; }
///
/// Use primary constructor syntax with classes and structs.
///
[Description("DecompilerSettings.UsePrimaryConstructorSyntaxForNonRecordTypes")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp12_0)]
public partial bool UsePrimaryConstructorSyntaxForNonRecordTypes { get; set; }
///
/// Gets/Sets whether C# 12.0 inline array uses should be transformed.
///
[Description("DecompilerSettings.InlineArrays")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp12_0)]
public partial bool InlineArrays { get; set; }
///
/// Gets/Sets whether C# 14.0 extension members should be transformed.
///
[Description("DecompilerSettings.ExtensionMembers")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp14_0)]
public partial bool ExtensionMembers { get; set; }
///
/// Gets/Sets whether (ReadOnly)Span<T> should be treated like built-in types.
///
[Description("DecompilerSettings.FirstClassSpanTypes")]
[DecompilerSetting(CSharp.LanguageVersion.CSharp14_0)]
public partial bool FirstClassSpanTypes { get; set; }
///
/// Gets/sets whether the decompiler should separate local variable declarations
/// from their initialization.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.SeparateLocalVariableDeclarations")]
[DecompilerSetting(DefaultValue = false)]
public partial bool SeparateLocalVariableDeclarations { get; set; }
///
/// Gets or sets a value indicating whether the new SDK style format
/// shall be used for the generated project files.
///
[Category("DecompilerSettings.ProjectExport")]
[Description("DecompilerSettings.UseSdkStyleProjectFormat")]
[DecompilerSetting]
public partial bool UseSdkStyleProjectFormat { get; set; }
///
/// Gets/sets whether namespaces and namespace-like identifiers should be split at '.'
/// and each part should produce a new level of nesting in the output directory structure.
///
[Category("DecompilerSettings.ProjectExport")]
[Description("DecompilerSettings.UseNestedDirectoriesForNamespaces")]
[DecompilerSetting(DefaultValue = false)]
public partial bool UseNestedDirectoriesForNamespaces { get; set; }
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AggressiveScalarReplacementOfAggregates")]
// TODO : Remove once https://github.com/icsharpcode/ILSpy/issues/2032 is fixed.
#if !DEBUG
[Browsable(false)]
#endif
[DecompilerSetting(DefaultValue = false)]
public partial bool AggressiveScalarReplacementOfAggregates { get; set; }
///
/// If set to false (the default), the decompiler will inline local variables only when they occur
/// in a context where the C# compiler is known to emit compiler-generated locals.
/// If set to true, the decompiler will inline local variables whenever possible.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AggressiveInlining")]
[DecompilerSetting(DefaultValue = false)]
public partial bool AggressiveInlining { get; set; }
///
/// Always fully qualify namespaces using the "global::" prefix.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AlwaysUseGlobal")]
[DecompilerSetting(DefaultValue = false)]
public partial bool AlwaysUseGlobal { get; set; }
///
/// If set to false (the default), the decompiler will move field initializers at the start of constructors
/// to their respective field declarations (TransformFieldAndConstructorInitializers) only when the declaring
/// type has BeforeFieldInit or the member IsConst.
/// If set true, the decompiler will always move them regardless of the flags.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AlwaysMoveInitializer")]
[DecompilerSetting(DefaultValue = false)]
public partial bool AlwaysMoveInitializer { get; set; }
///
/// Sort custom attributes.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.SortCustomAttributes")]
[DecompilerSetting(DefaultValue = false)]
public partial bool SortCustomAttributes { get; set; }
///
/// Sort switch sections by their label value instead of by IL offset.
/// Useful when diffing decompiler output across rebuilds of obfuscated assemblies,
/// where IL block layout is unstable but the case-to-value mapping is not.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.SortSwitchSections")]
[DecompilerSetting(DefaultValue = false)]
public partial bool SortSwitchSections { get; set; }
///
/// Check for overflow and underflow in operators.
///
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.CheckForOverflowUnderflow")]
[DecompilerSetting(DefaultValue = false)]
public partial bool CheckForOverflowUnderflow { get; set; }
CSharpFormattingOptions csharpFormattingOptions;
[Browsable(false)]
public CSharpFormattingOptions CSharpFormattingOptions {
get {
if (csharpFormattingOptions == null)
{
csharpFormattingOptions = FormattingOptionsFactory.CreateAllman();
csharpFormattingOptions.IndentSwitchBody = false;
csharpFormattingOptions.ArrayInitializerWrapping = Wrapping.WrapIfTooLong;
csharpFormattingOptions.AutoPropertyFormatting = PropertyFormatting.SingleLine;
}
return csharpFormattingOptions;
}
set {
if (value == null)
throw new ArgumentNullException();
if (csharpFormattingOptions != value)
{
csharpFormattingOptions = value;
OnPropertyChanged();
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public virtual DecompilerSettings Clone()
{
DecompilerSettings settings = (DecompilerSettings)MemberwiseClone();
if (csharpFormattingOptions != null)
settings.csharpFormattingOptions = csharpFormattingOptions.Clone();
settings.PropertyChanged = null;
return settings;
}
}
}