Table of Contents

Class DecompilerSettings

Namespace
ICSharpCode.Decompiler
Assembly
ICSharpCode.Decompiler.dll

Settings for the decompiler.

public class DecompilerSettings : INotifyPropertyChanged
Inheritance
DecompilerSettings
Implements
Inherited Members

Constructors

DecompilerSettings()

Equivalent to new DecompilerSettings(LanguageVersion.Latest)

public DecompilerSettings()

DecompilerSettings(LanguageVersion)

Creates a new DecompilerSettings instance with initial settings appropriate for the specified language version.

public DecompilerSettings(LanguageVersion languageVersion)

Parameters

languageVersion LanguageVersion

Remarks

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.

Properties

AggressiveInlining

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.

public bool AggressiveInlining { get; set; }

Property Value

bool

AggressiveScalarReplacementOfAggregates

[Browsable(false)]
public bool AggressiveScalarReplacementOfAggregates { get; set; }

Property Value

bool

AlwaysCastTargetsOfExplicitInterfaceImplementationCalls

Gets/Sets whether to always cast targets to explicitly implemented methods. true: ((ISupportInitialize)pictureBox1).BeginInit(); false: pictureBox1.BeginInit(); default: false

public bool AlwaysCastTargetsOfExplicitInterfaceImplementationCalls { get; set; }

Property Value

bool

AlwaysQualifyMemberReferences

Gets/Sets whether to always qualify member references. true: this.DoSomething(); false: DoSomething(); default: false

public bool AlwaysQualifyMemberReferences { get; set; }

Property Value

bool

AlwaysShowEnumMemberValues

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

public bool AlwaysShowEnumMemberValues { get; set; }

Property Value

bool

AlwaysUseBraces

Gets/Sets whether to use braces for single-statement-blocks.

public bool AlwaysUseBraces { get; set; }

Property Value

bool

AlwaysUseGlobal

Always fully qualify namespaces using the "global::" prefix.

public bool AlwaysUseGlobal { get; set; }

Property Value

bool

AnonymousMethods

Decompile anonymous methods/lambdas.

public bool AnonymousMethods { get; set; }

Property Value

bool

AnonymousTypes

Decompile anonymous types.

public bool AnonymousTypes { get; set; }

Property Value

bool

ApplyWindowsRuntimeProjections

public bool ApplyWindowsRuntimeProjections { get; set; }

Property Value

bool

ArrayInitializers

Gets/Sets whether to use array initializers. If set to false, might produce non-compilable code.

public bool ArrayInitializers { get; set; }

Property Value

bool

AssumeArrayLengthFitsIntoInt32

Gets/Sets whether the decompiler can assume that 'ldlen; conv.i4.ovf' does not throw an overflow exception.

[Browsable(false)]
public bool AssumeArrayLengthFitsIntoInt32 { get; set; }

Property Value

bool

AsyncAwait

Decompile async methods.

public bool AsyncAwait { get; set; }

Property Value

bool

AsyncEnumerator

Decompile IAsyncEnumerator/IAsyncEnumerable. Only has an effect if AsyncAwait is enabled.

public bool AsyncEnumerator { get; set; }

Property Value

bool

AsyncUsingAndForEachStatement

public bool AsyncUsingAndForEachStatement { get; set; }

Property Value

bool

AutomaticEvents

Decompile automatic events

public bool AutomaticEvents { get; set; }

Property Value

bool

AutomaticProperties

Decompile automatic properties

public bool AutomaticProperties { get; set; }

Property Value

bool

AwaitInCatchFinally

Decompile await in catch/finally blocks. Only has an effect if AsyncAwait is enabled.

public bool AwaitInCatchFinally { get; set; }

Property Value

bool

CSharpFormattingOptions

[Browsable(false)]
public CSharpFormattingOptions CSharpFormattingOptions { get; set; }

Property Value

CSharpFormattingOptions

CheckedOperators

Gets/Sets whether to use C# 11.0 user-defined checked operators.

public bool CheckedOperators { get; set; }

Property Value

bool

CovariantReturns

Decompile C# 9 covariant return types.

public bool CovariantReturns { get; set; }

Property Value

bool

DecimalConstants

Decompile [DecimalConstant(...)] as simple literal values.

public bool DecimalConstants { get; set; }

Property Value

bool

DecompileMemberBodies

Gets/Sets whether member bodies should be decompiled.

[Browsable(false)]
public bool DecompileMemberBodies { get; set; }

Property Value

bool

Deconstruction

Gets/Sets whether C# 7.0 deconstruction should be detected.

public bool Deconstruction { get; set; }

Property Value

bool

DictionaryInitializers

Gets/Sets whether to use C# 6.0 dictionary initializers. Only has an effect if ObjectOrCollectionInitializers is enabled.

public bool DictionaryInitializers { get; set; }

Property Value

bool

Discards

Gets/Sets whether discards should be used when possible. Only has an effect if OutVariables is enabled.

public bool Discards { get; set; }

Property Value

bool

DoWhileStatement

Gets/sets whether the decompiler should produce do-while loops.

public bool DoWhileStatement { get; set; }

Property Value

bool

Dynamic

Decompile use of the 'dynamic' type.

public bool Dynamic { get; set; }

Property Value

bool

ExpandMemberDefinitions

[Browsable(false)]
public bool ExpandMemberDefinitions { get; set; }

Property Value

bool

ExpandUsingDeclarations

[Browsable(false)]
public bool ExpandUsingDeclarations { get; set; }

Property Value

bool

ExpressionTrees

Decompile expression trees.

public bool ExpressionTrees { get; set; }

Property Value

bool

ExtensionMethods

public bool ExtensionMethods { get; set; }

Property Value

bool

ExtensionMethodsInCollectionInitializers

Gets/Sets whether to use C# 6.0 Extension Add methods in collection initializers. Only has an effect if ObjectOrCollectionInitializers is enabled.

public bool ExtensionMethodsInCollectionInitializers { get; set; }

Property Value

bool

FileScopedNamespaces

Use C# 10 file-scoped namespaces.

public bool FileScopedNamespaces { get; set; }

Property Value

bool

FixedBuffers

Decompile C# 1.0 'public unsafe fixed int arr[10];' members.

public bool FixedBuffers { get; set; }

Property Value

bool

FoldBraces

[Browsable(false)]
public bool FoldBraces { get; set; }

Property Value

bool

ForEachStatement

Decompile foreach statements.

public bool ForEachStatement { get; set; }

Property Value

bool

ForEachWithGetEnumeratorExtension

Support GetEnumerator extension methods in foreach.

public bool ForEachWithGetEnumeratorExtension { get; set; }

Property Value

bool

ForStatement

Gets/sets whether the decompiler should produce for loops.

public bool ForStatement { get; set; }

Property Value

bool

FunctionPointers

Use C# 9 delegate* unmanaged types. If this option is disabled, function pointers will instead be decompiled with type IntPtr.

public bool FunctionPointers { get; set; }

Property Value

bool

GetterOnlyAutomaticProperties

Decompile getter-only automatic properties

public bool GetterOnlyAutomaticProperties { get; set; }

Property Value

bool

InitAccessors

Use C# 9 init; property accessors.

public bool InitAccessors { get; set; }

Property Value

bool

IntroduceIncrementAndDecrement

Gets/Sets whether to use increment and decrement operators

[Browsable(false)]
public bool IntroduceIncrementAndDecrement { get; set; }

Property Value

bool

IntroduceReadonlyAndInModifiers

Gets/Sets whether IsReadOnlyAttribute should be replaced with 'readonly' modifiers on structs and with the 'in' modifier on parameters.

public bool IntroduceReadonlyAndInModifiers { get; set; }

Property Value

bool

IntroduceRefModifiersOnStructs

Gets/Sets whether IsByRefLikeAttribute should be replaced with 'ref' modifiers on structs.

public bool IntroduceRefModifiersOnStructs { get; set; }

Property Value

bool

IntroduceUnmanagedConstraint

If this option is active, [IsUnmanagedAttribute] on type parameters is replaced with "T : unmanaged" constraints.

public bool IntroduceUnmanagedConstraint { get; set; }

Property Value

bool

LifetimeAnnotations

[Obsolete("Renamed to ScopedRef. This property will be removed in a future version of the decompiler.")]
[Browsable(false)]
public bool LifetimeAnnotations { get; set; }

Property Value

bool

LiftNullables

Use lifted operators for nullables.

public bool LiftNullables { get; set; }

Property Value

bool

LoadInMemory

[Browsable(false)]
public bool LoadInMemory { get; set; }

Property Value

bool

LocalFunctions

Gets/Sets whether C# 7.0 local functions should be transformed.

public bool LocalFunctions { get; set; }

Property Value

bool

LockStatement

Decompile lock statements.

public bool LockStatement { get; set; }

Property Value

bool

MakeAssignmentExpressions

Gets/Sets whether to use assignment expressions such as in while ((count = Do()) != 0) ;

[Browsable(false)]
public bool MakeAssignmentExpressions { get; set; }

Property Value

bool

NamedArguments

Gets/Sets whether named arguments should be used.

public bool NamedArguments { get; set; }

Property Value

bool

NativeIntegers

Use C# 9 nint/nuint types.

public bool NativeIntegers { get; set; }

Property Value

bool

NonTrailingNamedArguments

Gets/Sets whether C# 7.2 non-trailing named arguments should be used.

public bool NonTrailingNamedArguments { get; set; }

Property Value

bool

NullPropagation

Decompile C# 6 ?. and ?[] operators.

public bool NullPropagation { get; set; }

Property Value

bool

NullableReferenceTypes

Gets/Sets whether C# 8.0 nullable reference types are enabled.

public bool NullableReferenceTypes { get; set; }

Property Value

bool

NumericIntPtr

Treat IntPtr/UIntPtr as nint/nuint.

public bool NumericIntPtr { get; set; }

Property Value

bool

ObjectOrCollectionInitializers

Gets/Sets whether to use C# 3.0 object/collection initializers.

public bool ObjectOrCollectionInitializers { get; set; }

Property Value

bool

OptionalArguments

Gets/Sets whether optional arguments should be removed, if possible.

public bool OptionalArguments { get; set; }

Property Value

bool

OutVariables

Gets/Sets whether out variable declarations should be used when possible.

public bool OutVariables { get; set; }

Property Value

bool

ParameterNullCheck

Use C# 11 preview parameter null-checking (

string param!!
).
[Browsable(false)]
[Obsolete("This feature did not make it into C# 11, and may be removed in a future version of the decompiler.")]
public bool ParameterNullCheck { get; set; }

Property Value

bool

PatternBasedFixedStatement

Gets/Sets whether C# 7.3 pattern based fixed statement should be used.

public bool PatternBasedFixedStatement { get; set; }

Property Value

bool

PatternCombinators

Gets/Sets whether C# 9.0 and, or, not patterns should be detected.

public bool PatternCombinators { get; set; }

Property Value

bool

PatternMatching

Gets/Sets whether C# 7.0 pattern matching should be detected.

public bool PatternMatching { get; set; }

Property Value

bool

QueryExpressions

public bool QueryExpressions { get; set; }

Property Value

bool

Ranges

Gets/Sets whether C# 8.0 index and range syntax should be used.

public bool Ranges { get; set; }

Property Value

bool

ReadOnlyMethods

public bool ReadOnlyMethods { get; set; }

Property Value

bool

RecordClasses

Use C# 9 record classes.

public bool RecordClasses { get; set; }

Property Value

bool

RecordStructs

Use C# 10 record structs.

public bool RecordStructs { get; set; }

Property Value

bool

RecursivePatternMatching

Gets/Sets whether C# 8.0 recursive patterns should be detected.

public bool RecursivePatternMatching { get; set; }

Property Value

bool

RefExtensionMethods

Gets/Sets whether to use C# 7.2 'ref' extension methods.

public bool RefExtensionMethods { get; set; }

Property Value

bool

RelationalPatterns

Gets/Sets whether C# 9.0 relational patterns should be detected.

public bool RelationalPatterns { get; set; }

Property Value

bool

RemoveDeadCode

public bool RemoveDeadCode { get; set; }

Property Value

bool

RemoveDeadStores

public bool RemoveDeadStores { get; set; }

Property Value

bool

RequiredMembers

Use C# 11 required modifier.

public bool RequiredMembers { get; set; }

Property Value

bool

ScopedRef

Use C# 11 scoped modifier.

public bool ScopedRef { get; set; }

Property Value

bool

SeparateLocalVariableDeclarations

Gets/sets whether the decompiler should separate local variable declarations from their initialization.

public bool SeparateLocalVariableDeclarations { get; set; }

Property Value

bool

ShowDebugInfo

[Browsable(false)]
public bool ShowDebugInfo { get; set; }

Property Value

bool

ShowXmlDocumentation

Gets/Sets whether to include XML documentation comments in the decompiled code.

public bool ShowXmlDocumentation { get; set; }

Property Value

bool

SparseIntegerSwitch

public bool SparseIntegerSwitch { get; set; }

Property Value

bool

StackAllocInitializers

Gets/Sets whether C# 7.3 stackalloc initializers should be used.

public bool StackAllocInitializers { get; set; }

Property Value

bool

StaticLocalFunctions

Gets/Sets whether C# 8.0 static local functions should be transformed.

public bool StaticLocalFunctions { get; set; }

Property Value

bool

StringConcat

Decompile 'string.Concat(a, b)' calls into 'a + b'.

public bool StringConcat { get; set; }

Property Value

bool

StringInterpolation

Gets/Sets whether to use C# 6.0 string interpolation

public bool StringInterpolation { get; set; }

Property Value

bool

SwitchExpressions

Use C# 8 switch expressions.

public bool SwitchExpressions { get; set; }

Property Value

bool

SwitchOnReadOnlySpanChar

Gets/Sets whether to use C# 11.0 switch on (ReadOnly)Span<char>

public bool SwitchOnReadOnlySpanChar { get; set; }

Property Value

bool

SwitchStatementOnString

public bool SwitchStatementOnString { get; set; }

Property Value

bool

ThrowExpressions

Gets/Sets whether throw expressions should be used.

public bool ThrowExpressions { get; set; }

Property Value

bool

ThrowOnAssemblyResolveErrors

[Browsable(false)]
public bool ThrowOnAssemblyResolveErrors { get; set; }

Property Value

bool

TupleComparisons

Gets/Sets whether tuple comparisons should be detected.

public bool TupleComparisons { get; set; }

Property Value

bool

TupleConversions

Gets/Sets whether implicit conversions between tuples should be used in the decompiled output.

public bool TupleConversions { get; set; }

Property Value

bool

TupleTypes

Gets/Sets whether tuple type syntax (int, string) should be used for System.ValueTuple.

public bool TupleTypes { get; set; }

Property Value

bool

UnsignedRightShift

Gets/Sets whether to use C# 11.0 unsigned right shift operator.

public bool UnsignedRightShift { get; set; }

Property Value

bool

UseDebugSymbols

Gets/Sets whether to use variable names from debug symbols, if available.

public bool UseDebugSymbols { get; set; }

Property Value

bool

UseEnhancedUsing

Use enhanced using statements.

public bool UseEnhancedUsing { get; set; }

Property Value

bool

UseExpressionBodyForCalculatedGetterOnlyProperties

Gets/Sets whether simple calculated getter-only property declarations should use expression body syntax.

public bool UseExpressionBodyForCalculatedGetterOnlyProperties { get; set; }

Property Value

bool

UseImplicitMethodGroupConversion

Gets/Sets whether to use C# 2.0 method group conversions. true: EventHandler h = this.OnClick; false: EventHandler h = new EventHandler(this.OnClick);

public bool UseImplicitMethodGroupConversion { get; set; }

Property Value

bool

UseLambdaSyntax

Use C# 3 lambda syntax if possible.

public bool UseLambdaSyntax { get; set; }

Property Value

bool

UseNestedDirectoriesForNamespaces

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.

public bool UseNestedDirectoriesForNamespaces { get; set; }

Property Value

bool

UsePrimaryConstructorSyntax

Use primary constructor syntax with records.

public bool UsePrimaryConstructorSyntax { get; set; }

Property Value

bool

UseRefLocalsForAccurateOrderOfEvaluation

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

public bool UseRefLocalsForAccurateOrderOfEvaluation { get; set; }

Property Value

bool

UseSdkStyleProjectFormat

Gets or sets a value indicating whether the new SDK style format shall be used for the generated project files.

public bool UseSdkStyleProjectFormat { get; set; }

Property Value

bool

UsingDeclarations

public bool UsingDeclarations { get; set; }

Property Value

bool

UsingStatement

Decompile using statements.

public bool UsingStatement { get; set; }

Property Value

bool

Utf8StringLiterals

Gets/Sets whether to use C# 11.0 UTF-8 string literals

public bool Utf8StringLiterals { get; set; }

Property Value

bool

WithExpressions

Use C# 9 with initializer expressions.

public bool WithExpressions { get; set; }

Property Value

bool

YieldReturn

Decompile enumerators.

public bool YieldReturn { get; set; }

Property Value

bool

Methods

Clone()

public DecompilerSettings Clone()

Returns

DecompilerSettings

GetMinimumRequiredVersion()

public LanguageVersion GetMinimumRequiredVersion()

Returns

LanguageVersion

OnPropertyChanged(string)

protected virtual void OnPropertyChanged(string propertyName = null)

Parameters

propertyName string

SetLanguageVersion(LanguageVersion)

Deactivates all language features from versions newer than languageVersion.

public void SetLanguageVersion(LanguageVersion languageVersion)

Parameters

languageVersion LanguageVersion

Events

PropertyChanged

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler