Browse Source

Throw exceptions when something goes wrong.

Some renames.
pull/191/merge
Eusebiu Marcu 15 years ago
parent
commit
887aa424c4
  1. 6
      Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
  2. 12
      ICSharpCode.Decompiler/CodeMappings.cs
  3. 8
      ILSpy/Commands/DebuggerCommands.cs

6
Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs

@ -858,7 +858,7 @@ namespace ILSpy.Debugger.Services
string fullName = debugType.FullNameWithoutGenericArguments; string fullName = debugType.FullNameWithoutGenericArguments;
fullName = fullName.Replace("+", "/"); fullName = fullName.Replace("+", "/");
if (DebugData.LoadedAssemblies == null) if (DebugData.LoadedAssemblies == null)
Continue(); throw new NullReferenceException("No DebugData assemblies!");
else { else {
// search for type in the current assembly list // search for type in the current assembly list
TypeDefinition typeDef = null; TypeDefinition typeDef = null;
@ -896,11 +896,11 @@ namespace ILSpy.Debugger.Services
DebuggerService.JumpToCurrentLine(typeDef, line, 0, line, 0); DebuggerService.JumpToCurrentLine(typeDef, line, 0, line, 0);
} else { } else {
// continue since we cannot find the debugged type // 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 { } else {
// continue since we cannot find the debugged type // continue since we cannot find the debugged type
Continue(); throw new NullReferenceException(string.Format("The type {0} was not found!", fullName));
} }
} }
} }

12
ICSharpCode.Decompiler/CodeMappings.cs

@ -250,7 +250,7 @@ namespace ICSharpCode.Decompiler
/// Gets the source code and type name from metadata token and offset. /// Gets the source code and type name from metadata token and offset.
/// </summary> /// </summary>
/// <param name="codeMappings">Code mappings storage.</param> /// <param name="codeMappings">Code mappings storage.</param>
/// <param name="currentTypeFullName">Current type name.</param> /// <param name="typeName">Current type name.</param>
/// <param name="token">Metadata token.</param> /// <param name="token">Metadata token.</param>
/// <param name="ilOffset">IL offset.</param> /// <param name="ilOffset">IL offset.</param>
/// <param name="typeName">Type definition.</param> /// <param name="typeName">Type definition.</param>
@ -258,7 +258,7 @@ namespace ICSharpCode.Decompiler
/// <remarks>It is possible to exist to different types from different assemblies with the same metadata token.</remarks> /// <remarks>It is possible to exist to different types from different assemblies with the same metadata token.</remarks>
public static bool GetSourceCodeFromMetadataTokenAndOffset( public static bool GetSourceCodeFromMetadataTokenAndOffset(
this ConcurrentDictionary<string, List<MemberMapping>> codeMappings, this ConcurrentDictionary<string, List<MemberMapping>> codeMappings,
string currentTypeFullName, string typeName,
uint token, uint token,
int ilOffset, int ilOffset,
out TypeDefinition type, out TypeDefinition type,
@ -267,10 +267,14 @@ namespace ICSharpCode.Decompiler
type = null; type = null;
line = 0; 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; return false;
var mapping = codeMappings[currentTypeFullName].Find(m => m.MetadataToken == token); var mapping = codeMappings[typeName].Find(m => m.MetadataToken == token);
if (mapping == null) if (mapping == null)
return false; return false;

8
ILSpy/Commands/DebuggerCommands.cs

@ -242,10 +242,12 @@ namespace ICSharpCode.ILSpy.Commands
{ {
public override void Execute(object parameter) public override void Execute(object parameter)
{ {
if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) {
base.Execute(null);
CurrentDebugger.StepOver(); CurrentDebugger.StepOver();
} }
} }
}
[ExportMainMenuCommand(Menu = "_Debugger", [ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "ILSpy.Debugger;component/Images/StepOut.png", MenuIcon = "ILSpy.Debugger;component/Images/StepOut.png",
@ -257,10 +259,12 @@ namespace ICSharpCode.ILSpy.Commands
{ {
public override void Execute(object parameter) public override void Execute(object parameter)
{ {
if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) {
base.Execute(null);
CurrentDebugger.StepOut(); CurrentDebugger.StepOut();
} }
} }
}
[ExportMainMenuCommand(Menu = "_Debugger", [ExportMainMenuCommand(Menu = "_Debugger",
MenuCategory = "Debugger1", MenuCategory = "Debugger1",

Loading…
Cancel
Save