diff --git a/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs index cda3652af..cb7d2161c 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs @@ -305,6 +305,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms { inst = addressOf.Value; } + // The argument of the unwrap instruction cannot be the end of the chain, because this + // would result in two null-conditional operators immediately following each other, + // which is not valid in C#. + if (IsValidEndOfChain()) + return false; } else if (inst is DynamicGetMemberInstruction dynGetMember) {