Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Updated ByMethods plugin to show stack traces of commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Apr 9, 2015
1 parent 43afbdd commit 46b2a95
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 27 deletions.
4 changes: 2 additions & 2 deletions DNTProfiler.MetaData/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif

// Assembly Versions are incremented manually when branching the code for a release.
[assembly: AssemblyVersion("1.4.821.0")]
[assembly: AssemblyVersion("1.4.828.0")]
// Assembly File Version should be incremented automatically as part of the build process.
[assembly: AssemblyFileVersion("1.4.821.0")]
[assembly: AssemblyFileVersion("1.4.828.0")]

7 changes: 5 additions & 2 deletions DNTProfiler/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ private void doSearch()

void doStart(string data)
{
_selfHostConfig.OpenWait(GuiModelData.ServerUri, GuiModelData.AllowRemoteConnections);
_isStated = true;
Task.Factory.StartNew(() =>
{
_selfHostConfig.OpenWait(GuiModelData.ServerUri, GuiModelData.AllowRemoteConnections);
_isStated = true;
});
}

void doStop(string data)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using DNTProfiler.ApplicationExceptions.Core;
Expand Down Expand Up @@ -29,14 +30,13 @@ public MainViewModel(ProfilerPluginBase pluginContext)

private void addException(Exception ex)
{
AppExceptionsGuiData.AppExceptionsList.Add(new AppException
{
Message = ex.Message,
Details = ExceptionLogger.GetExceptionCallStack(ex)
});

DispatcherHelper.DispatchAction(() =>
{
AppExceptionsGuiData.AppExceptionsList.Add(new AppException
{
Message = ex.Message,
Details = ExceptionLogger.GetExceptionCallStack(ex)
});
PluginContext.NotifyPluginsHost(NotificationType.Update, 1);
});
}
Expand Down Expand Up @@ -80,6 +80,7 @@ private void setEvenets()
{
AppDomain.CurrentDomain.UnhandledException += currentDomainUnhandledException;
Application.Current.DispatcherUnhandledException += appDispatcherUnhandledException;
TaskScheduler.UnobservedTaskException += taskSchedulerUnobservedTaskException;

AppMessenger.Messenger.Register<Exception>("ShowException", exception => addException(exception));
}
Expand All @@ -98,5 +99,16 @@ private void setGuiModel()
new ExceptionLogger().LogExceptionToFile(new NotImplementedException(error), AppMessenger.LogFile);
});
}

void taskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
e.SetObserved();
e.Exception.Flatten().Handle(ex =>
{
new ExceptionLogger().LogExceptionToFile(ex, AppMessenger.LogFile);
addException(ex);
return true;
});
}
}
}
15 changes: 10 additions & 5 deletions Plugins/DNTProfiler.ByMethods/Core/CallbacksManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ public CallbacksManager(ProfilerPluginBase pluginContext, GuiModelBase guiModelD
{
}

public void ManageStackTraces(CallingMethodStackTrace item)
public void ManageStackTraces(Command command)
{
if (item.ApplicationIdentity.Equals(GuiModelData.SelectedApplicationIdentity))
var stackTrace = GetStackTrace(command);
if (stackTrace == null)
return;

stackTrace.ApplicationIdentity = command.ApplicationIdentity;
if (stackTrace.ApplicationIdentity.Equals(GuiModelData.SelectedApplicationIdentity))
{
GuiModelData.RelatedStackTraces.Add(item);
GuiModelData.RelatedStackTraces.Add(stackTrace);
}

_localCallingMethodStackTraces.Add(item);
_localCallingMethodStackTraces.Add(stackTrace);
PluginContext.NotifyPluginsHost(NotificationType.Update, 1);
UpdateAppIdentityNotificationsCount(item.ApplicationIdentity);
UpdateAppIdentityNotificationsCount(stackTrace.ApplicationIdentity);
}

public void Reset()
Expand Down
6 changes: 3 additions & 3 deletions Plugins/DNTProfiler.ByMethods/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ private void setActions()

private void setEvenets()
{
PluginContext.ProfilerData.StackTraces.CollectionChanged += StackTraces_CollectionChanged;
PluginContext.ProfilerData.Commands.CollectionChanged += Commands_CollectionChanged;
}

private void StackTraces_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void Commands_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (CallingMethodStackTrace item in e.NewItems)
foreach (Command item in e.NewItems)
{
_callbacksManager.ManageStackTraces(item);
}
Expand Down
18 changes: 12 additions & 6 deletions Plugins/DNTProfiler.QueryFromView/Core/CallbacksManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,27 @@ public CallbacksManager(ProfilerPluginBase pluginContext, GuiModelBase guiModelD
{
}

public void ManageStackTraces(CallingMethodStackTrace item)
public void ManageStackTraces(Command command)
{
if (!hasQueryFromView(item))
var stackTrace = GetStackTrace(command);
if (stackTrace == null)
return;

stackTrace.ApplicationIdentity = command.ApplicationIdentity;

if (!hasQueryFromView(stackTrace))
{
return;
}

if (item.ApplicationIdentity.Equals(GuiModelData.SelectedApplicationIdentity))
if (stackTrace.ApplicationIdentity.Equals(GuiModelData.SelectedApplicationIdentity))
{
GuiModelData.RelatedStackTraces.Add(item);
GuiModelData.RelatedStackTraces.Add(stackTrace);
}

_localCallingMethodStackTraces.Add(item);
_localCallingMethodStackTraces.Add(stackTrace);
PluginContext.NotifyPluginsHost(NotificationType.Update, 1);
UpdateAppIdentityNotificationsCount(item.ApplicationIdentity);
UpdateAppIdentityNotificationsCount(stackTrace.ApplicationIdentity);
}

public void Reset()
Expand Down
6 changes: 3 additions & 3 deletions Plugins/DNTProfiler.QueryFromView/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ private void setActions()

private void setEvenets()
{
PluginContext.ProfilerData.StackTraces.CollectionChanged += StackTraces_CollectionChanged;
PluginContext.ProfilerData.Commands.CollectionChanged += Commands_CollectionChanged;
}

private void StackTraces_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void Commands_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (CallingMethodStackTrace item in e.NewItems)
foreach (Command item in e.NewItems)
{
_callbacksManager.ManageStackTraces(item);
}
Expand Down

0 comments on commit 46b2a95

Please sign in to comment.