From 4ecf8be05c85e55c2317a76ed35fb60741617697 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 28 Aug 2009 21:13:28 +0000 Subject: [PATCH] profiler: modified DefaultProfiler implementation to show error message instead of throwing NotSupportedException in case no profiler was found. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4812 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Src/Services/Debugger/DefaultDebugger.cs | 2 +- .../Src/Services/Profiler/DefaultProfiler.cs | 13 +++++++++---- .../Src/Services/Profiler/ProfilerService.cs | 6 ++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs b/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs index 511e080bb5..256e89288d 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs @@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop.Debugging OnDebugStarted(EventArgs.Empty); } catch (Exception) { OnDebugStopped(EventArgs.Empty); - throw new ApplicationException("Can't execute " + "\"" + processStartInfo.FileName + "\"\n"); + throw new ApplicationException("Can't execute \"" + processStartInfo.FileName + "\"\n"); } } diff --git a/src/Main/Base/Project/Src/Services/Profiler/DefaultProfiler.cs b/src/Main/Base/Project/Src/Services/Profiler/DefaultProfiler.cs index 096dfd04e3..405887c19a 100644 --- a/src/Main/Base/Project/Src/Services/Profiler/DefaultProfiler.cs +++ b/src/Main/Base/Project/Src/Services/Profiler/DefaultProfiler.cs @@ -5,7 +5,10 @@ // $Revision$ // +using ICSharpCode.Core; using System; +using System.Diagnostics; +using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.SharpDevelop.Profiling { @@ -13,16 +16,19 @@ namespace ICSharpCode.SharpDevelop.Profiling { public bool CanProfile(ICSharpCode.SharpDevelop.Project.IProject project) { - return false; + return true; } - public void Start(System.Diagnostics.ProcessStartInfo info, string outputPath, Action afterFinishedAction) + public void Start(ProcessStartInfo info, string outputPath, Action afterFinishedAction) { - throw new NotSupportedException(); + MessageService.ShowError("Profiling not supported! " + + "No appropriate Profiler AddIn was found."); + afterFinishedAction(); } public void Dispose() { + Stop(); } public bool IsRunning { @@ -33,7 +39,6 @@ namespace ICSharpCode.SharpDevelop.Profiling public void Stop() { - throw new NotSupportedException(); } } } diff --git a/src/Main/Base/Project/Src/Services/Profiler/ProfilerService.cs b/src/Main/Base/Project/Src/Services/Profiler/ProfilerService.cs index 4b5336dd61..ecae1eef23 100644 --- a/src/Main/Base/Project/Src/Services/Profiler/ProfilerService.cs +++ b/src/Main/Base/Project/Src/Services/Profiler/ProfilerService.cs @@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.Profiling } public static string GetSessionFileName(IProject project) - { + { string filename = @"ProfilingSessions\Session" + DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".sdps"; @@ -68,8 +68,10 @@ namespace ICSharpCode.SharpDevelop.Profiling } public static void AddSessionToProject(IProject project, string path) - { + { Action updater = () => { + if (!File.Exists(path)) + return; FileService.OpenFile(path); if (!project.ReadOnly) { FileProjectItem file = new FileProjectItem(project, ItemType.Content, "ProfilingSessions\\" + Path.GetFileName(path));