diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index cf8d66f0b..632a26c9c 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -4408,7 +4408,7 @@ namespace ICSharpCode.Decompiler.CSharp protected internal override TranslatedExpression VisitInvalidExpression(InvalidExpression inst, TranslationContext context) { - string message = "Error"; + string message = inst.Severity; if (inst.StartILOffset != 0) { message += $" near IL_{inst.StartILOffset:x4}"; diff --git a/ICSharpCode.Decompiler/IL/BlockBuilder.cs b/ICSharpCode.Decompiler/IL/BlockBuilder.cs index 38e16639e..ee02e0f8b 100644 --- a/ICSharpCode.Decompiler/IL/BlockBuilder.cs +++ b/ICSharpCode.Decompiler/IL/BlockBuilder.cs @@ -385,7 +385,7 @@ namespace ICSharpCode.Decompiler.IL } var usedLabels = new LongSet(dispatch.TargetILOffsets.Select(offset => LongInterval.Inclusive(offset, offset))); switchInst.Sections.Add(new SwitchSection { Labels = usedLabels.Invert(), Body = new Branch(tryBody.EntryPoint) }); - dispatchBlock.Instructions.Add(new Nop { Comment = "ILSpy has introduced the following switch to emulate a goto from catch-block to try-block" }); + dispatchBlock.Instructions.Add(new InvalidExpression("ILSpy has introduced the following switch to emulate a goto from catch-block to try-block") { Severity = "Note" }); dispatchBlock.Instructions.Add(switchInst); tryBody.Blocks.Insert(0, dispatchBlock); diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs b/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs index 73d4be118..c813d3465 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs @@ -15,6 +15,7 @@ // 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.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -70,7 +71,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow } // Remove 'nop' instructions - block.Instructions.RemoveAll(inst => inst is Nop { Comment: null }); + block.Instructions.RemoveAll(inst => inst.OpCode == OpCode.Nop); } private static void RemoveDeadStackStores(Block block, ILTransformContext context) diff --git a/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs index a05f0d06e..14d5c89b3 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs @@ -89,6 +89,7 @@ namespace ICSharpCode.Decompiler.IL partial class InvalidExpression : SimpleInstruction { + public string Severity = "Error"; public string? Message; public StackType ExpectedResultType = StackType.Unknown;