From 887aa424c4f16c6d5dff67c92326965c36c1d27e Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Fri, 18 Mar 2011 22:54:09 +0200 Subject: [PATCH] Throw exceptions when something goes wrong. Some renames. --- .../Services/Debugger/WindowsDebugger.cs | 6 +++--- ICSharpCode.Decompiler/CodeMappings.cs | 12 ++++++++---- ILSpy/Commands/DebuggerCommands.cs | 8 ++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs b/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs index c67b4b35f..ca2217540 100644 --- a/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs +++ b/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs @@ -858,7 +858,7 @@ namespace ILSpy.Debugger.Services string fullName = debugType.FullNameWithoutGenericArguments; fullName = fullName.Replace("+", "/"); if (DebugData.LoadedAssemblies == null) - Continue(); + throw new NullReferenceException("No DebugData assemblies!"); else { // search for type in the current assembly list TypeDefinition typeDef = null; @@ -896,11 +896,11 @@ namespace ILSpy.Debugger.Services DebuggerService.JumpToCurrentLine(typeDef, line, 0, line, 0); } else { // continue since we cannot find the debugged type - StepOver(); + throw new InvalidOperationException(string.Format("No mapping for {0} for token {1} and offset {2}!", fullName, token, ilOffset)); } } else { // continue since we cannot find the debugged type - Continue(); + throw new NullReferenceException(string.Format("The type {0} was not found!", fullName)); } } } diff --git a/ICSharpCode.Decompiler/CodeMappings.cs b/ICSharpCode.Decompiler/CodeMappings.cs index 53733c7cc..7945a8f4b 100644 --- a/ICSharpCode.Decompiler/CodeMappings.cs +++ b/ICSharpCode.Decompiler/CodeMappings.cs @@ -250,7 +250,7 @@ namespace ICSharpCode.Decompiler /// Gets the source code and type name from metadata token and offset. /// /// Code mappings storage. - /// Current type name. + /// Current type name. /// Metadata token. /// IL offset. /// Type definition. @@ -258,7 +258,7 @@ namespace ICSharpCode.Decompiler /// It is possible to exist to different types from different assemblies with the same metadata token. public static bool GetSourceCodeFromMetadataTokenAndOffset( this ConcurrentDictionary> codeMappings, - string currentTypeFullName, + string typeName, uint token, int ilOffset, out TypeDefinition type, @@ -267,10 +267,14 @@ namespace ICSharpCode.Decompiler type = null; line = 0; - if (!codeMappings.ContainsKey(currentTypeFullName)) + if (codeMappings == null) + throw new ArgumentNullException("CodeMappings storage must be valid!"); + + typeName = typeName.Replace("+", "/"); + if (!codeMappings.ContainsKey(typeName)) return false; - var mapping = codeMappings[currentTypeFullName].Find(m => m.MetadataToken == token); + var mapping = codeMappings[typeName].Find(m => m.MetadataToken == token); if (mapping == null) return false; diff --git a/ILSpy/Commands/DebuggerCommands.cs b/ILSpy/Commands/DebuggerCommands.cs index 49b47a40f..ec711f683 100644 --- a/ILSpy/Commands/DebuggerCommands.cs +++ b/ILSpy/Commands/DebuggerCommands.cs @@ -242,8 +242,10 @@ namespace ICSharpCode.ILSpy.Commands { public override void Execute(object parameter) { - if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) + if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) { + base.Execute(null); CurrentDebugger.StepOver(); + } } } @@ -257,8 +259,10 @@ namespace ICSharpCode.ILSpy.Commands { public override void Execute(object parameter) { - if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) + if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) { + base.Execute(null); CurrentDebugger.StepOut(); + } } }