Browse Source

Merge pull request #45 from tobijdc/newNRProfiler

Profiler ready for NewNR
pull/46/merge
Siegfried Oleg Pammer 12 years ago
parent
commit
a98d2e90f6
  1. 31
      SharpDevelop.sln
  2. 28
      src/AddIns/Analysis/Profiler/Controller/Data/CallTreeNode.cs
  3. 2
      src/AddIns/Analysis/Profiler/Controller/Data/IProfilingDataSet.cs
  4. 2
      src/AddIns/Analysis/Profiler/Controller/Data/IProfilingDataWriter.cs
  5. 4
      src/AddIns/Analysis/Profiler/Controller/Data/IncompatibleDatabaseException.cs
  6. 8
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/AllCalls.cs
  7. 2
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/Filter.cs
  8. 6
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/Limit.cs
  9. 5
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/MergeByName.cs
  10. 4
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/OptimizeQueryExpressionVisitor.cs
  11. 3
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/QueryNode.cs
  12. 4
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs
  13. 3
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/Sort.cs
  14. 6
      src/AddIns/Analysis/Profiler/Controller/Data/Linq/SqlQueryContext.cs
  15. 6
      src/AddIns/Analysis/Profiler/Controller/Data/PerformanceCounterDescriptor.cs
  16. 1
      src/AddIns/Analysis/Profiler/Controller/Data/ProfilingDataProvider.cs
  17. 33
      src/AddIns/Analysis/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs
  18. 40
      src/AddIns/Analysis/Profiler/Controller/Data/ProfilingDataSQLiteWriter.cs
  19. 41
      src/AddIns/Analysis/Profiler/Controller/Data/SQLiteCallTreeNode.cs
  20. 67
      src/AddIns/Analysis/Profiler/Controller/Data/TempFileDatabase.cs
  21. 8
      src/AddIns/Analysis/Profiler/Controller/Data/UnitTestRootCallTreeNode.cs
  22. 20
      src/AddIns/Analysis/Profiler/Controller/Data/UnitTestWriter.cs
  23. 23
      src/AddIns/Analysis/Profiler/Controller/Data/UnmanagedCallTreeNode.cs
  24. 6
      src/AddIns/Analysis/Profiler/Controller/Data/UnmanagedProfilingDataSet.cs
  25. 2
      src/AddIns/Analysis/Profiler/Controller/ExtensionMethods.cs
  26. 4
      src/AddIns/Analysis/Profiler/Controller/Interprocess/AtomicBoolean.cs
  27. 12
      src/AddIns/Analysis/Profiler/Controller/Interprocess/MemoryMappedFile.cs
  28. 4
      src/AddIns/Analysis/Profiler/Controller/Interprocess/UnmanagedCircularBuffer.cs
  29. 5
      src/AddIns/Analysis/Profiler/Controller/Profiler.Controller.csproj
  30. 128
      src/AddIns/Analysis/Profiler/Controller/Profiler.cs
  31. 3
      src/AddIns/Analysis/Profiler/Controller/ProfilerOptions.cs
  32. 1
      src/AddIns/Analysis/Profiler/Controller/Properties/AssemblyInfo.cs
  33. 2
      src/AddIns/Analysis/Profiler/Controller/Queries/NodePath.cs
  34. 5
      src/AddIns/Analysis/Profiler/Controller/Queries/QueryBase.cs
  35. 13
      src/AddIns/Analysis/Profiler/Controller/Queries/QueryCompiler.cs
  36. 3
      src/AddIns/Analysis/Profiler/Controller/structs.cs
  37. 2
      src/AddIns/Analysis/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin
  38. 12
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Profiler.AddIn.csproj
  39. 3
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/CopySelectedData.cs
  40. 23
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/DomMenuCommand.cs
  41. 5
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/FindCallsOfSelected.cs
  42. 9
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/FindReferences.cs
  43. 14
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs
  44. 4
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ProfileExecutable.cs
  45. 1
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs
  46. 3
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ProfilerMenuCommand.cs
  47. 16
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/RunTestWithProfilerCommand.cs
  48. 5
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/SetAsRoot.cs
  49. 5
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ShowFunctions.cs
  50. 7
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Dialogs/ProfileExecutableForm.xaml.cs
  51. 18
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml.cs
  52. 6
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Extensions.cs
  53. 7
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/OptionPanels/General.cs
  54. 4
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/OptionPanels/OptionWrapper.cs
  55. 139
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerProcessRunner.cs
  56. 31
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs
  57. 110
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerTestRunner.cs
  58. 7
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ComparisonView.xaml.cs
  59. 12
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerDisplayBinding.cs
  60. 30
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerView.xaml.cs
  61. 14
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/WpfViewer.cs
  62. 34
      src/AddIns/Analysis/Profiler/Frontend/Controls/CallTreeNodeViewModel.cs
  63. 7
      src/AddIns/Analysis/Profiler/Frontend/Controls/CompareView.xaml.cs
  64. 5
      src/AddIns/Analysis/Profiler/Frontend/Controls/CustomGridView.cs
  65. 48
      src/AddIns/Analysis/Profiler/Frontend/Controls/ExtendedTimeLineControl.xaml.cs
  66. 32
      src/AddIns/Analysis/Profiler/Frontend/Controls/HSVColor.cs
  67. 1
      src/AddIns/Analysis/Profiler/Frontend/Controls/HierarchyList.cs
  68. 9
      src/AddIns/Analysis/Profiler/Frontend/Controls/PercentBar.cs
  69. 8
      src/AddIns/Analysis/Profiler/Frontend/Controls/PiePiece.cs
  70. 5
      src/AddIns/Analysis/Profiler/Frontend/Controls/Profiler.Controls.csproj
  71. 58
      src/AddIns/Analysis/Profiler/Frontend/Controls/QueryView.xaml.cs
  72. 3
      src/AddIns/Analysis/Profiler/Frontend/Controls/RangeEventArgs.cs
  73. 35
      src/AddIns/Analysis/Profiler/Frontend/Controls/RingDiagramControl.cs
  74. 14
      src/AddIns/Analysis/Profiler/Frontend/Controls/SingleTask.cs
  75. 2
      src/AddIns/Analysis/Profiler/Frontend/Controls/Task.cs
  76. 97
      src/AddIns/Analysis/Profiler/Frontend/Controls/TimeLineControl.cs
  77. 20
      src/AddIns/Analysis/Profiler/Frontend/Controls/TreeListView.cs
  78. 1
      src/AddIns/Analysis/Profiler/Frontend/Controls/WaitBar.cs
  79. 12
      src/AddIns/Analysis/Profiler/X64Converter/Profiler.X64Converter.csproj
  80. 133
      src/AddIns/Analysis/Profiler/X64Converter/Program.cs
  81. 1
      src/AddIns/Analysis/Profiler/X64Converter/Properties/AssemblyInfo.cs
  82. 6
      src/AddIns/Analysis/Profiler/X64Converter/app.config
  83. 1
      src/AddIns/Analysis/UnitTesting/Model/TestBase.cs
  84. 2
      src/AddIns/Analysis/UnitTesting/Model/TestNamespace.cs
  85. 1
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestClass.cs
  86. 2
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestMethod.cs
  87. 2
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestProject.cs
  88. 3
      src/AddIns/Analysis/UnitTesting/TestRunner/TestExecutionOptions.cs
  89. 2
      src/AddIns/Analysis/UnitTesting/TestRunner/TestProcessRunnerBaseContext.cs

31
SharpDevelop.sln

@ -171,6 +171,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MachineSpecifications", "sr
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQuality", "src\AddIns\Analysis\CodeQuality\CodeQuality.csproj", "{D1DF9C2D-3A5E-4985-ACA4-648C604DB562}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQuality", "src\AddIns\Analysis\CodeQuality\CodeQuality.csproj", "{D1DF9C2D-3A5E-4985-ACA4-648C604DB562}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Profiler", "Profiler", "{E9BF2761-031F-4CDC-A7E6-F66F3B347311}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controller", "src\AddIns\Analysis\Profiler\Controller\Profiler.Controller.csproj", "{D788789A-4D43-42B9-B0F7-CB2CA761372B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.AddIn", "src\AddIns\Analysis\Profiler\Frontend\AddIn\Profiler.AddIn.csproj", "{2F5FBF6E-E9DD-48C0-A209-7241FE488FDF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.X64Converter", "src\AddIns\Analysis\Profiler\X64Converter\Profiler.X64Converter.csproj", "{600D7F63-DACE-4933-BE8C-B51A948A86D4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controls", "src\AddIns\Analysis\Profiler\Frontend\Controls\Profiler.Controls.csproj", "{B063078F-17D2-4B0C-A01C-DBF440F1C24D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
@ -461,6 +471,22 @@ Global
{D1DF9C2D-3A5E-4985-ACA4-648C604DB562}.Debug|Any CPU.Build.0 = Debug|Any CPU {D1DF9C2D-3A5E-4985-ACA4-648C604DB562}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1DF9C2D-3A5E-4985-ACA4-648C604DB562}.Release|Any CPU.ActiveCfg = Release|Any CPU {D1DF9C2D-3A5E-4985-ACA4-648C604DB562}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1DF9C2D-3A5E-4985-ACA4-648C604DB562}.Release|Any CPU.Build.0 = Release|Any CPU {D1DF9C2D-3A5E-4985-ACA4-648C604DB562}.Release|Any CPU.Build.0 = Release|Any CPU
{D788789A-4D43-42B9-B0F7-CB2CA761372B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D788789A-4D43-42B9-B0F7-CB2CA761372B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D788789A-4D43-42B9-B0F7-CB2CA761372B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D788789A-4D43-42B9-B0F7-CB2CA761372B}.Release|Any CPU.Build.0 = Release|Any CPU
{2F5FBF6E-E9DD-48C0-A209-7241FE488FDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F5FBF6E-E9DD-48C0-A209-7241FE488FDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F5FBF6E-E9DD-48C0-A209-7241FE488FDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F5FBF6E-E9DD-48C0-A209-7241FE488FDF}.Release|Any CPU.Build.0 = Release|Any CPU
{600D7F63-DACE-4933-BE8C-B51A948A86D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{600D7F63-DACE-4933-BE8C-B51A948A86D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{600D7F63-DACE-4933-BE8C-B51A948A86D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{600D7F63-DACE-4933-BE8C-B51A948A86D4}.Release|Any CPU.Build.0 = Release|Any CPU
{B063078F-17D2-4B0C-A01C-DBF440F1C24D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B063078F-17D2-4B0C-A01C-DBF440F1C24D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B063078F-17D2-4B0C-A01C-DBF440F1C24D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B063078F-17D2-4B0C-A01C-DBF440F1C24D}.Release|Any CPU.Build.0 = Release|Any CPU
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -558,6 +584,11 @@ Global
{08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7} {08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{D1DA3B8F-7313-4BDA-8880-461C5F007751} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7} {D1DA3B8F-7313-4BDA-8880-461C5F007751} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{D1DF9C2D-3A5E-4985-ACA4-648C604DB562} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7} {D1DF9C2D-3A5E-4985-ACA4-648C604DB562} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{E9BF2761-031F-4CDC-A7E6-F66F3B347311} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{D788789A-4D43-42B9-B0F7-CB2CA761372B} = {E9BF2761-031F-4CDC-A7E6-F66F3B347311}
{2F5FBF6E-E9DD-48C0-A209-7241FE488FDF} = {E9BF2761-031F-4CDC-A7E6-F66F3B347311}
{600D7F63-DACE-4933-BE8C-B51A948A86D4} = {E9BF2761-031F-4CDC-A7E6-F66F3B347311}
{B063078F-17D2-4B0C-A01C-DBF440F1C24D} = {E9BF2761-031F-4CDC-A7E6-F66F3B347311}
{49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E} = {39327899-ED91-4F7F-988C-4FE4E17C014D} {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E} {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}
{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E} {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}

28
src/AddIns/Analysis/Profiler/Controller/Data/CallTreeNode.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public virtual int CallCount { public virtual int CallCount {
get { get {
return this.RawCallCount + (this.IsActiveAtStart ? 1 : 0); return RawCallCount + (IsActiveAtStart ? 1 : 0);
} }
} }
@ -61,7 +61,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public virtual bool IsUserCode { public virtual bool IsUserCode {
get { get {
return this.NameMapping.Id > 0; return NameMapping.Id > 0;
} }
} }
@ -89,7 +89,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public string Name { public string Name {
get { get {
NameMapping name = this.NameMapping; NameMapping name = NameMapping;
return name != null ? name.Name : null; return name != null ? name.Name : null;
} }
} }
@ -99,7 +99,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public string ReturnType { public string ReturnType {
get { get {
NameMapping name = this.NameMapping; NameMapping name = NameMapping;
return name != null ? name.ReturnType : null; return name != null ? name.ReturnType : null;
} }
} }
@ -108,7 +108,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// Determines whether this node is a thread node. /// Determines whether this node is a thread node.
/// </summary> /// </summary>
public virtual bool IsThread { public virtual bool IsThread {
get { return this.Name.StartsWith("Thread#", StringComparison.Ordinal); } get { return Name.StartsWith("Thread#", StringComparison.Ordinal); }
} }
/// <summary> /// <summary>
@ -116,7 +116,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public virtual bool HasChildren { public virtual bool HasChildren {
get { get {
return this.Children.Any(); return Children.Any();
} }
} }
@ -125,7 +125,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public IList<string> Parameters { public IList<string> Parameters {
get { get {
NameMapping name = this.NameMapping; NameMapping name = NameMapping;
return name != null ? name.Parameters : NameMapping.EmptyParameterList; return name != null ? name.Parameters : NameMapping.EmptyParameterList;
} }
} }
@ -183,7 +183,7 @@ namespace ICSharpCode.Profiler.Controller.Data
try { try {
if (includeSelf) if (includeSelf)
yield return this; // Descendants is reflexive yield return this; // Descendants is reflexive
stack.Push(this.Children.GetEnumerator()); stack.Push(Children.GetEnumerator());
while (stack.Count > 0) { while (stack.Count > 0) {
IEnumerator<CallTreeNode> e = stack.Peek(); IEnumerator<CallTreeNode> e = stack.Peek();
if (e.MoveNext()) { if (e.MoveNext()) {
@ -220,7 +220,7 @@ namespace ICSharpCode.Profiler.Controller.Data
IEnumerable<CallTreeNode> GetAncestors(bool includeSelf) IEnumerable<CallTreeNode> GetAncestors(bool includeSelf)
{ {
CallTreeNode n = includeSelf ? this : this.Parent; CallTreeNode n = includeSelf ? this : Parent;
while (n != null) { while (n != null) {
yield return n; yield return n;
n = n.Parent; n = n.Parent;
@ -256,11 +256,11 @@ namespace ICSharpCode.Profiler.Controller.Data
public virtual IEnumerable<NodePath> GetPath() public virtual IEnumerable<NodePath> GetPath()
{ {
bool hasItems = false; bool hasItems = false;
foreach (CallTreeNode caller in this.Callers) { foreach (CallTreeNode caller in Callers) {
Debug.Print("caller: " + caller); Debug.Print("caller: " + caller);
foreach (NodePath p in caller.GetPath()) { foreach (NodePath p in caller.GetPath()) {
hasItems = true; hasItems = true;
yield return p.Append(this.NameMapping.Id); yield return p.Append(NameMapping.Id);
} }
} }
@ -277,9 +277,9 @@ namespace ICSharpCode.Profiler.Controller.Data
if (relativeTo.Equals(this)) if (relativeTo.Equals(this))
yield return NodePath.Empty; yield return NodePath.Empty;
else { else {
foreach (CallTreeNode caller in this.Callers) { foreach (CallTreeNode caller in Callers) {
foreach (NodePath p in caller.GetPathRelativeTo(relativeTo)) foreach (NodePath p in caller.GetPathRelativeTo(relativeTo))
yield return p.Append(this.NameMapping.Id); yield return p.Append(NameMapping.Id);
} }
} }
} }
@ -301,7 +301,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() public override string ToString()
{ {
return "[" + GetType().Name + " " + this.NameMapping.Id + " " + this.NameMapping.Name + "]"; return "[" + GetType().Name + " " + NameMapping.Id + " " + NameMapping.Name + "]";
} }
} }
} }

2
src/AddIns/Analysis/Profiler/Controller/Data/IProfilingDataSet.cs

@ -2,8 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace ICSharpCode.Profiler.Controller.Data namespace ICSharpCode.Profiler.Controller.Data
{ {

2
src/AddIns/Analysis/Profiler/Controller/Data/IProfilingDataWriter.cs

@ -3,8 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace ICSharpCode.Profiler.Controller.Data namespace ICSharpCode.Profiler.Controller.Data
{ {

4
src/AddIns/Analysis/Profiler/Controller/Data/IncompatibleDatabaseException.cs

@ -54,8 +54,8 @@ namespace ICSharpCode.Profiler.Controller.Data
{ {
base.GetObjectData(info, context); base.GetObjectData(info, context);
if (info != null) { if (info != null) {
info.AddValue("ExpectedVersion", this.ExpectedVersion, typeof(Version)); info.AddValue("ExpectedVersion", ExpectedVersion, typeof(Version));
info.AddValue("ActualVersion", this.ActualVersion, typeof(Version)); info.AddValue("ActualVersion", ActualVersion, typeof(Version));
} }
} }
} }

8
src/AddIns/Analysis/Profiler/Controller/Data/Linq/AllCalls.cs

@ -2,14 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection;
using System.Text; using System.Text;
namespace ICSharpCode.Profiler.Controller.Data.Linq namespace ICSharpCode.Profiler.Controller.Data.Linq
@ -23,7 +17,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
{ {
public static readonly AllCalls Instance = new AllCalls(); public static readonly AllCalls Instance = new AllCalls();
private AllCalls() : base(null) AllCalls() : base(null)
{ {
} }

2
src/AddIns/Analysis/Profiler/Controller/Data/Linq/Filter.cs

@ -2,14 +2,12 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection;
using System.Text; using System.Text;
namespace ICSharpCode.Profiler.Controller.Data.Linq namespace ICSharpCode.Profiler.Controller.Data.Linq

6
src/AddIns/Analysis/Profiler/Controller/Data/Linq/Limit.cs

@ -2,14 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection;
using System.Text; using System.Text;
namespace ICSharpCode.Profiler.Controller.Data.Linq namespace ICSharpCode.Profiler.Controller.Data.Linq

5
src/AddIns/Analysis/Profiler/Controller/Data/Linq/MergeByName.cs

@ -2,14 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection;
using System.Text; using System.Text;
namespace ICSharpCode.Profiler.Controller.Data.Linq namespace ICSharpCode.Profiler.Controller.Data.Linq

4
src/AddIns/Analysis/Profiler/Controller/Data/Linq/OptimizeQueryExpressionVisitor.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
/// Nodes returned from 'Visit' can be assumed to be fully optimized (they won't contain any of the patterns /// Nodes returned from 'Visit' can be assumed to be fully optimized (they won't contain any of the patterns
/// described in the SQLiteQueryProvider optimization documentation). /// described in the SQLiteQueryProvider optimization documentation).
/// </summary> /// </summary>
sealed class OptimizeQueryExpressionVisitor : System.Linq.Expressions.ExpressionVisitor sealed class OptimizeQueryExpressionVisitor : ExpressionVisitor
{ {
QueryNode Visit(QueryNode queryNode) QueryNode Visit(QueryNode queryNode)
{ {
@ -181,7 +181,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
} }
sealed class IsConditionSafeVisitor : System.Linq.Expressions.ExpressionVisitor sealed class IsConditionSafeVisitor : ExpressionVisitor
{ {
public static bool Test(Expression ex, params MemberInfo[] safeMembers) public static bool Test(Expression ex, params MemberInfo[] safeMembers)
{ {

3
src/AddIns/Analysis/Profiler/Controller/Data/Linq/QueryNode.cs

@ -3,10 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;

4
src/AddIns/Analysis/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs

@ -252,7 +252,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
} }
#region Convert Expression Tree To Query AST #region Convert Expression Tree To Query AST
sealed class ConvertToQueryAstVisitor : System.Linq.Expressions.ExpressionVisitor sealed class ConvertToQueryAstVisitor : ExpressionVisitor
{ {
readonly QueryExecutionOptions options; readonly QueryExecutionOptions options;
@ -573,7 +573,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
#endregion #endregion
#region ExecuteAllQueriesVisitor #region ExecuteAllQueriesVisitor
sealed class ExecuteAllQueriesVisitor : System.Linq.Expressions.ExpressionVisitor sealed class ExecuteAllQueriesVisitor : ExpressionVisitor
{ {
readonly SQLiteQueryProvider sqliteProvider; readonly SQLiteQueryProvider sqliteProvider;
readonly QueryExecutionOptions options; readonly QueryExecutionOptions options;

3
src/AddIns/Analysis/Profiler/Controller/Data/Linq/Sort.cs

@ -4,12 +4,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection;
using System.Text; using System.Text;
namespace ICSharpCode.Profiler.Controller.Data.Linq namespace ICSharpCode.Profiler.Controller.Data.Linq

6
src/AddIns/Analysis/Profiler/Controller/Data/Linq/SqlQueryContext.cs

@ -31,9 +31,9 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
public void SetCurrent(CallTreeNodeSqlNameSet nameSet, SqlTableType table, bool hasIDList) public void SetCurrent(CallTreeNodeSqlNameSet nameSet, SqlTableType table, bool hasIDList)
{ {
this.CurrentNameSet = nameSet; CurrentNameSet = nameSet;
this.CurrentTable = table; CurrentTable = table;
this.HasIDList = hasIDList; HasIDList = hasIDList;
} }
SQLiteQueryProvider provider; SQLiteQueryProvider provider;

6
src/AddIns/Analysis/Profiler/Controller/Data/PerformanceCounterDescriptor.cs

@ -130,7 +130,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public void Reset() public void Reset()
{ {
this.Values.Clear(); Values.Clear();
} }
/// <summary> /// <summary>
@ -155,14 +155,14 @@ namespace ICSharpCode.Profiler.Controller.Data
return; return;
} }
try { try {
this.Values.Add(counter.NextValue()); Values.Add(counter.NextValue());
#if DEBUG #if DEBUG
} catch (Exception e) { } catch (Exception e) {
Console.WriteLine(e.ToString()); Console.WriteLine(e.ToString());
#else #else
} catch (Exception) { } catch (Exception) {
#endif #endif
this.Values.Add(defaultValue); Values.Add(defaultValue);
} }
} }

1
src/AddIns/Analysis/Profiler/Controller/Data/ProfilingDataProvider.cs

@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;

33
src/AddIns/Analysis/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs

@ -1,18 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.Profiler.Controller.Data.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Data.SQLite; using System.Data.SQLite;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading; using System.Threading;
using ICSharpCode.Profiler.Interprocess; using ICSharpCode.Profiler.Controller.Data.Linq;
namespace ICSharpCode.Profiler.Controller.Data namespace ICSharpCode.Profiler.Controller.Data
{ {
@ -142,7 +139,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public override void Close() public override void Close()
{ {
this.Dispose(); Dispose();
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -182,7 +179,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public override ReadOnlyCollection<IProfilingDataSet> DataSets { public override ReadOnlyCollection<IProfilingDataSet> DataSets {
get { get {
if (this.dataSets == null) { if (dataSets == null) {
List<IProfilingDataSet> list = new List<IProfilingDataSet>(); List<IProfilingDataSet> list = new List<IProfilingDataSet>();
SQLiteCommand cmd; SQLiteCommand cmd;
@ -202,10 +199,10 @@ namespace ICSharpCode.Profiler.Controller.Data
} }
} }
this.dataSets = new ReadOnlyCollection<IProfilingDataSet>(list); dataSets = new ReadOnlyCollection<IProfilingDataSet>(list);
} }
return this.dataSets; return dataSets;
} }
} }
@ -227,7 +224,7 @@ namespace ICSharpCode.Profiler.Controller.Data
public CallTreeNode RootNode { public CallTreeNode RootNode {
get { get {
return this.provider.GetRoot(ID, ID); return provider.GetRoot(ID, ID);
} }
} }
@ -246,7 +243,7 @@ namespace ICSharpCode.Profiler.Controller.Data
rwLock.EnterWriteLock(); rwLock.EnterWriteLock();
try { try {
if (!isDisposed) if (!isDisposed)
this.connection.Close(); connection.Close();
isDisposed = true; isDisposed = true;
} finally { } finally {
@ -330,17 +327,17 @@ namespace ICSharpCode.Profiler.Controller.Data
throw new ProfilerException("processorfrequency was not found!"); throw new ProfilerException("processorfrequency was not found!");
} }
return this.processorFrequency; return processorFrequency;
} }
} }
/// <inheritdoc/> /// <inheritdoc/>
public override IQueryable<CallTreeNode> GetFunctions(int startIndex, int endIndex) public override IQueryable<CallTreeNode> GetFunctions(int startIndex, int endIndex)
{ {
if (startIndex < 0 || startIndex >= this.DataSets.Count) if (startIndex < 0 || startIndex >= DataSets.Count)
throw new ArgumentOutOfRangeException("startIndex", startIndex, "Value must be between 0 and " + endIndex); throw new ArgumentOutOfRangeException("startIndex", startIndex, "Value must be between 0 and " + endIndex);
if (endIndex < startIndex || endIndex >= this.DataSets.Count) if (endIndex < startIndex || endIndex >= DataSets.Count)
throw new ArgumentOutOfRangeException("endIndex", endIndex, "Value must be between " + startIndex + " and " + (this.DataSets.Count - 1)); throw new ArgumentOutOfRangeException("endIndex", endIndex, "Value must be between " + startIndex + " and " + (DataSets.Count - 1));
SQLiteQueryProvider queryProvider = new SQLiteQueryProvider(this, startIndex, endIndex); SQLiteQueryProvider queryProvider = new SQLiteQueryProvider(this, startIndex, endIndex);
@ -478,15 +475,15 @@ namespace ICSharpCode.Profiler.Controller.Data
LockObject LockAndCreateCommand(out SQLiteCommand cmd) LockObject LockAndCreateCommand(out SQLiteCommand cmd)
{ {
this.rwLock.EnterReadLock(); rwLock.EnterReadLock();
if (isDisposed) { if (isDisposed) {
this.rwLock.ExitReadLock(); rwLock.ExitReadLock();
throw new ObjectDisposedException("ProfilingDataSQLiteProvider", "The provider was already closed!"); throw new ObjectDisposedException("ProfilingDataSQLiteProvider", "The provider was already closed!");
} }
cmd = this.connection.CreateCommand(); cmd = connection.CreateCommand();
return new LockObject(cmd, this.rwLock); return new LockObject(cmd, rwLock);
} }
struct LockObject : IDisposable struct LockObject : IDisposable

40
src/AddIns/Analysis/Profiler/Controller/Data/ProfilingDataSQLiteWriter.cs

@ -3,15 +3,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.SQLite; using System.Data.SQLite;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using ICSharpCode.Profiler.Interprocess;
using System.Threading;
namespace ICSharpCode.Profiler.Controller.Data namespace ICSharpCode.Profiler.Controller.Data
{ {
@ -60,13 +56,13 @@ namespace ICSharpCode.Profiler.Controller.Data
if (isDisposed) if (isDisposed)
return; return;
using (SQLiteCommand cmd = this.connection.CreateCommand()) { using (SQLiteCommand cmd = connection.CreateCommand()) {
// create index at the end (after inserting data), this is faster // create index at the end (after inserting data), this is faster
cmd.CommandText = CallsAndFunctionsIndexDefs; cmd.CommandText = CallsAndFunctionsIndexDefs;
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
this.Dispose(); Dispose();
} }
/// <summary> /// <summary>
@ -75,11 +71,11 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public int ProcessorFrequency { public int ProcessorFrequency {
get { get {
return this.processorFrequency; return processorFrequency;
} }
set { set {
processorFrequency = value; processorFrequency = value;
ProfilingDataSQLiteProvider.SetProperty(this.connection.CreateCommand(), "processorfrequency", value.ToString(CultureInfo.InvariantCulture)); ProfilingDataSQLiteProvider.SetProperty(connection.CreateCommand(), "processorfrequency", value.ToString(CultureInfo.InvariantCulture));
} }
} }
@ -91,8 +87,8 @@ namespace ICSharpCode.Profiler.Controller.Data
if (dataSet == null) if (dataSet == null)
throw new ArgumentNullException("dataSet"); throw new ArgumentNullException("dataSet");
using (SQLiteTransaction transaction = this.connection.BeginTransaction()) { using (SQLiteTransaction transaction = connection.BeginTransaction()) {
SQLiteCommand cmd = this.connection.CreateCommand(); SQLiteCommand cmd = connection.CreateCommand();
if (dataSetCount == -1) if (dataSetCount == -1)
dataSetCount = 0; dataSetCount = 0;
@ -106,7 +102,7 @@ namespace ICSharpCode.Profiler.Controller.Data
int dataSetStartId = functionInfoCount; int dataSetStartId = functionInfoCount;
using (SQLiteCommand loopCommand = this.connection.CreateCommand()) { using (SQLiteCommand loopCommand = connection.CreateCommand()) {
CallTreeNode node = dataSet.RootNode; CallTreeNode node = dataSet.RootNode;
loopCommand.CommandText = "INSERT INTO Calls(id, endid, parentid, nameid, cpucyclesspent, cpucyclesspentself, isactiveatstart, callcount)" + loopCommand.CommandText = "INSERT INTO Calls(id, endid, parentid, nameid, cpucyclesspent, cpucyclesspentself, isactiveatstart, callcount)" +
@ -125,7 +121,7 @@ namespace ICSharpCode.Profiler.Controller.Data
InsertCalls(loopCommand, node, -1, dataParams); InsertCalls(loopCommand, node, -1, dataParams);
} }
using (SQLiteCommand functionsCommand = this.connection.CreateCommand()) { using (SQLiteCommand functionsCommand = connection.CreateCommand()) {
functionsCommand.CommandText = string.Format(@" functionsCommand.CommandText = string.Format(@"
INSERT INTO Functions INSERT INTO Functions
SELECT {0}, nameid, SUM(cpucyclesspent), SUM(cpucyclesspentself), SUM(isactiveatstart), SUM(callcount), MAX(id != endid) SELECT {0}, nameid, SUM(cpucyclesspent), SUM(cpucyclesspentself), SUM(isactiveatstart), SUM(callcount), MAX(id != endid)
@ -201,7 +197,7 @@ namespace ICSharpCode.Profiler.Controller.Data
// NameMapping.Id <-> FunctionData.NameId 1:N // NameMapping.Id <-> FunctionData.NameId 1:N
// FunctionData.ParentId <-> FunctionData.Id 1:N // FunctionData.ParentId <-> FunctionData.Id 1:N
SQLiteCommand cmd = this.connection.CreateCommand(); SQLiteCommand cmd = connection.CreateCommand();
cmd.CommandText = CallsAndFunctionsTableDefs + @" cmd.CommandText = CallsAndFunctionsTableDefs + @"
@ -276,8 +272,8 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public void WriteMappings(IEnumerable<NameMapping> mappings) public void WriteMappings(IEnumerable<NameMapping> mappings)
{ {
using (SQLiteTransaction trans = this.connection.BeginTransaction()) { using (SQLiteTransaction trans = connection.BeginTransaction()) {
using (SQLiteCommand cmd = this.connection.CreateCommand()) { using (SQLiteCommand cmd = connection.CreateCommand()) {
SQLiteParameter idParam = new SQLiteParameter("id"); SQLiteParameter idParam = new SQLiteParameter("id");
SQLiteParameter retTParam = new SQLiteParameter("returntype"); SQLiteParameter retTParam = new SQLiteParameter("returntype");
SQLiteParameter nameParam = new SQLiteParameter("name"); SQLiteParameter nameParam = new SQLiteParameter("name");
@ -307,7 +303,7 @@ namespace ICSharpCode.Profiler.Controller.Data
public void Dispose() public void Dispose()
{ {
if (!isDisposed) if (!isDisposed)
this.connection.Close(); connection.Close();
isDisposed = true; isDisposed = true;
} }
@ -315,9 +311,9 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters) public void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters)
{ {
using (SQLiteTransaction trans = this.connection.BeginTransaction()) { using (SQLiteTransaction trans = connection.BeginTransaction()) {
using (SQLiteCommand cmd = this.connection.CreateCommand()) { using (SQLiteCommand cmd = connection.CreateCommand()) {
using (SQLiteCommand cmd2 = this.connection.CreateCommand()) { using (SQLiteCommand cmd2 = connection.CreateCommand()) {
SQLiteParameter idParam = new SQLiteParameter("id"); SQLiteParameter idParam = new SQLiteParameter("id");
SQLiteParameter nameParam = new SQLiteParameter("name"); SQLiteParameter nameParam = new SQLiteParameter("name");
@ -368,8 +364,8 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public void WriteEventData(IEnumerable<EventDataEntry> events) public void WriteEventData(IEnumerable<EventDataEntry> events)
{ {
using (SQLiteTransaction trans = this.connection.BeginTransaction()) { using (SQLiteTransaction trans = connection.BeginTransaction()) {
using (SQLiteCommand cmd = this.connection.CreateCommand()) { using (SQLiteCommand cmd = connection.CreateCommand()) {
SQLiteParameter dataSetParam = new SQLiteParameter("datasetid"); SQLiteParameter dataSetParam = new SQLiteParameter("datasetid");
SQLiteParameter eventTypeParam = new SQLiteParameter("eventtype"); SQLiteParameter eventTypeParam = new SQLiteParameter("eventtype");
SQLiteParameter nameIdParam = new SQLiteParameter("nameid"); SQLiteParameter nameIdParam = new SQLiteParameter("nameid");
@ -395,7 +391,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public int DataSetCount { public int DataSetCount {
get { return this.dataSetCount; } get { return dataSetCount; }
} }
} }
} }

41
src/AddIns/Analysis/Profiler/Controller/Data/SQLiteCallTreeNode.cs

@ -1,14 +1,11 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.Profiler.Controller.Data.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.SQLite;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using ICSharpCode.Profiler.Controller.Data.Linq;
namespace ICSharpCode.Profiler.Controller.Data namespace ICSharpCode.Profiler.Controller.Data
{ {
@ -44,15 +41,15 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
internal int[] IdList { internal int[] IdList {
get { get {
int[] tmp = this.ids; int[] tmp = ids;
if (tmp == null) { if (tmp == null) {
tmp = provider.LoadIDListForFunction(nameId); tmp = provider.LoadIDListForFunction(nameId);
this.ids = tmp; ids = tmp;
} }
return tmp; return tmp;
} }
set { set {
this.ids = value; ids = value;
} }
} }
@ -64,14 +61,14 @@ namespace ICSharpCode.Profiler.Controller.Data
if (nameId == 0) if (nameId == 0)
return new NameMapping(0, null, "Merged node", null); return new NameMapping(0, null, "Merged node", null);
return this.provider.GetMapping(nameId); return provider.GetMapping(nameId);
} }
} }
/// <inheritdoc/> /// <inheritdoc/>
public override int RawCallCount { public override int RawCallCount {
get { get {
return this.callCount; return callCount;
} }
} }
@ -80,12 +77,12 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public override long CpuCyclesSpent { public override long CpuCyclesSpent {
get{ get{
return this.cpuCyclesSpent; return cpuCyclesSpent;
} }
} }
public override long CpuCyclesSpentSelf { public override long CpuCyclesSpentSelf {
get { return this.cpuCyclesSpentSelf; } get { return cpuCyclesSpentSelf; }
} }
/// <summary> /// <summary>
@ -93,7 +90,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public override CallTreeNode Parent { public override CallTreeNode Parent {
get { get {
return this.parent; return parent;
} }
} }
@ -110,7 +107,7 @@ namespace ICSharpCode.Profiler.Controller.Data
if (!hasChildren) if (!hasChildren)
return EmptyQueryable; return EmptyQueryable;
List<int> ids = this.IdList.ToList(); List<int> ids = IdList.ToList();
Expression<Func<SingleCall, bool>> filterLambda = c => ids.Contains(c.ParentID); Expression<Func<SingleCall, bool>> filterLambda = c => ids.Contains(c.ParentID);
return provider.CreateQuery(new MergeByName(new Filter(AllCalls.Instance, filterLambda))); return provider.CreateQuery(new MergeByName(new Filter(AllCalls.Instance, filterLambda)));
} }
@ -121,13 +118,13 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public override double TimeSpent { public override double TimeSpent {
get { get {
return CpuCyclesSpent / (1000.0 * this.provider.ProcessorFrequency); return CpuCyclesSpent / (1000.0 * provider.ProcessorFrequency);
} }
} }
public override double TimeSpentSelf { public override double TimeSpentSelf {
get { get {
return CpuCyclesSpentSelf / (1000.0 * this.provider.ProcessorFrequency); return CpuCyclesSpentSelf / (1000.0 * provider.ProcessorFrequency);
} }
} }
@ -151,7 +148,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <returns>A new CallTreeNode.</returns> /// <returns>A new CallTreeNode.</returns>
public override CallTreeNode Merge(IEnumerable<CallTreeNode> nodes) public override CallTreeNode Merge(IEnumerable<CallTreeNode> nodes)
{ {
SQLiteCallTreeNode mergedNode = new SQLiteCallTreeNode(0, null, this.provider); SQLiteCallTreeNode mergedNode = new SQLiteCallTreeNode(0, null, provider);
List<int> mergedIds = new List<int>(); List<int> mergedIds = new List<int>();
bool initialised = false; bool initialised = false;
@ -179,12 +176,12 @@ namespace ICSharpCode.Profiler.Controller.Data
get { get {
// parent is not null => this node was created by a // parent is not null => this node was created by a
// 'Children' call => all our IDs come from that parent // 'Children' call => all our IDs come from that parent
if (this.parent != null) if (parent != null)
return (new CallTreeNode[] { this.parent }).AsQueryable(); return (new CallTreeNode[] { parent }).AsQueryable();
List<int> parentIDList = provider.RunSQLIDList( List<int> parentIDList = provider.RunSQLIDList(
"SELECT parentid FROM Calls " "SELECT parentid FROM Calls "
+ "WHERE id IN(" + string.Join(",", this.IdList.Select(s => s.ToString()).ToArray()) + @")"); + "WHERE id IN(" + string.Join(",", IdList.Select(s => s.ToString()).ToArray()) + @")");
Expression<Func<SingleCall, bool>> filterLambda = c => parentIDList.Contains(c.ID); Expression<Func<SingleCall, bool>> filterLambda = c => parentIDList.Contains(c.ID);
return provider.CreateQuery(new MergeByName(new Filter(AllCalls.Instance, filterLambda))); return provider.CreateQuery(new MergeByName(new Filter(AllCalls.Instance, filterLambda)));
@ -196,7 +193,7 @@ namespace ICSharpCode.Profiler.Controller.Data
SQLiteCallTreeNode node = other as SQLiteCallTreeNode; SQLiteCallTreeNode node = other as SQLiteCallTreeNode;
if (node != null) { if (node != null) {
int[] a = this.IdList; int[] a = IdList;
int[] b = node.IdList; int[] b = node.IdList;
if (a.Length != b.Length) if (a.Length != b.Length)
return false; return false;
@ -219,7 +216,7 @@ namespace ICSharpCode.Profiler.Controller.Data
int hash = 0; int hash = 0;
unchecked { unchecked {
foreach (int i in this.IdList) { foreach (int i in IdList) {
hash = hash * hashPrime + i; hash = hash * hashPrime + i;
} }
} }
@ -228,7 +225,7 @@ namespace ICSharpCode.Profiler.Controller.Data
} }
public override bool HasChildren { public override bool HasChildren {
get { return this.hasChildren; } get { return hasChildren; }
} }
} }
} }

67
src/AddIns/Analysis/Profiler/Controller/Data/TempFileDatabase.cs

@ -7,7 +7,6 @@ using System.Collections.ObjectModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using ICSharpCode.Profiler.Interprocess; using ICSharpCode.Profiler.Interprocess;
@ -77,7 +76,7 @@ namespace ICSharpCode.Profiler.Controller.Data
public override int ProcessorFrequency { public override int ProcessorFrequency {
get { get {
return this.database.processorFrequency; return database.processorFrequency;
} }
} }
@ -95,13 +94,13 @@ namespace ICSharpCode.Profiler.Controller.Data
{ {
if (nameId == 0) if (nameId == 0)
return new NameMapping(0); return new NameMapping(0);
return this.database.nameMappings[nameId]; return database.nameMappings[nameId];
} }
public override void Dispose() public override void Dispose()
{ {
base.Dispose(); base.Dispose();
this.view.Dispose(); view.Dispose();
} }
} }
@ -117,10 +116,10 @@ namespace ICSharpCode.Profiler.Controller.Data
public int ProcessorFrequency { public int ProcessorFrequency {
get { get {
return this.database.processorFrequency; return database.processorFrequency;
} }
set { set {
this.database.processorFrequency = value; database.processorFrequency = value;
} }
} }
@ -131,7 +130,7 @@ namespace ICSharpCode.Profiler.Controller.Data
throw new InvalidOperationException("TempFileDatabase cannot write DataSets other than UnmanagedProfilingDataSet!"); throw new InvalidOperationException("TempFileDatabase cannot write DataSets other than UnmanagedProfilingDataSet!");
database.AddDataset((byte *)uDataSet.StartPtr.ToPointer(), uDataSet.Length, uDataSet.NativeStartPosition, uDataSet.NativeRootFuncInfoPosition, uDataSet.IsFirst); database.AddDataset((byte *)uDataSet.StartPtr.ToPointer(), uDataSet.Length, uDataSet.NativeStartPosition, uDataSet.NativeRootFuncInfoPosition, uDataSet.IsFirst);
this.database.is64Bit = uDataSet.Is64Bit; database.is64Bit = uDataSet.Is64Bit;
} }
public void Close() public void Close()
@ -144,21 +143,21 @@ namespace ICSharpCode.Profiler.Controller.Data
public void WriteMappings(IEnumerable<NameMapping> mappings) public void WriteMappings(IEnumerable<NameMapping> mappings)
{ {
foreach (NameMapping nm in mappings) foreach (NameMapping nm in mappings)
this.database.nameMappings.Add(nm.Id, nm); database.nameMappings.Add(nm.Id, nm);
} }
public void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters) public void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters)
{ {
this.database.counters.AddRange(counters); database.counters.AddRange(counters);
} }
public void WriteEventData(IEnumerable<EventDataEntry> events) public void WriteEventData(IEnumerable<EventDataEntry> events)
{ {
this.database.events.AddRange(events); database.events.AddRange(events);
} }
public int DataSetCount { public int DataSetCount {
get { return this.database.DataSetCount; } get { return database.DataSetCount; }
} }
} }
#endregion #endregion
@ -181,23 +180,23 @@ namespace ICSharpCode.Profiler.Controller.Data
{ {
byte[] data = new byte[length]; byte[] data = new byte[length];
Marshal.Copy(new IntPtr(ptr), data, 0, (int)length); Marshal.Copy(new IntPtr(ptr), data, 0, (int)length);
if (this.currentWrite != null) if (currentWrite != null)
this.file.EndWrite(this.currentWrite); file.EndWrite(currentWrite);
this.streamInfos.Add(new StreamInfo { NativeStartPosition = nativeStartPosition, NativeRootFuncInfoStartPosition = nativeRootFuncInfoStartPosition, streamInfos.Add(new StreamInfo { NativeStartPosition = nativeStartPosition, NativeRootFuncInfoStartPosition = nativeRootFuncInfoStartPosition,
StreamStartPosition = this.file.Length, StreamLength = length, IsFirst = isFirst }); StreamStartPosition = file.Length, StreamLength = length, IsFirst = isFirst });
this.currentWrite = this.file.BeginWrite(data, 0, (int)length, null, null); currentWrite = file.BeginWrite(data, 0, (int)length, null, null);
} }
void NotifyFinish() void NotifyFinish()
{ {
if (this.currentWrite != null) { if (currentWrite != null) {
this.file.EndWrite(this.currentWrite); file.EndWrite(currentWrite);
this.currentWrite = null; currentWrite = null;
} }
this.file.Flush(); file.Flush();
if (this.streamInfos.Count > 0) if (streamInfos.Count > 0)
this.mmf = MemoryMappedFile.Open(file);//Name, FileAccess.Read, FileShare.ReadWrite); mmf = MemoryMappedFile.Open(file);//Name, FileAccess.Read, FileShare.ReadWrite);
} }
/// <summary> /// <summary>
@ -205,9 +204,9 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public void Close() public void Close()
{ {
if (this.mmf != null) if (mmf != null)
this.mmf.Close(); mmf.Close();
this.file.Close(); file.Close();
} }
/// <summary> /// <summary>
@ -229,7 +228,7 @@ namespace ICSharpCode.Profiler.Controller.Data
throw new IndexOutOfRangeException("index needs to be between 0 and " + (streamInfos.Count - 1) throw new IndexOutOfRangeException("index needs to be between 0 and " + (streamInfos.Count - 1)
+ "\nActual value: " + index); + "\nActual value: " + index);
if (this.mmf == null) if (mmf == null)
throw new InvalidOperationException("All writers have to be closed before reading the data from the database!"); throw new InvalidOperationException("All writers have to be closed before reading the data from the database!");
return new DataSet(this, mmf.MapView(streamInfos[index].StreamStartPosition, streamInfos[index].StreamLength), streamInfos[index].NativeStartPosition, return new DataSet(this, mmf.MapView(streamInfos[index].StreamStartPosition, streamInfos[index].StreamLength), streamInfos[index].NativeStartPosition,
@ -243,16 +242,16 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <param name="progressReport">Used to report the progress of writing all DataSets, returning false tells WriteTo to cancel the process.</param> /// <param name="progressReport">Used to report the progress of writing all DataSets, returning false tells WriteTo to cancel the process.</param>
public void WriteTo(IProfilingDataWriter writer, Predicate<double> progressReport) public void WriteTo(IProfilingDataWriter writer, Predicate<double> progressReport)
{ {
writer.ProcessorFrequency = this.processorFrequency; writer.ProcessorFrequency = processorFrequency;
writer.WriteMappings(this.nameMappings.Values); writer.WriteMappings(nameMappings.Values);
writer.WritePerformanceCounterData(this.counters); writer.WritePerformanceCounterData(counters);
writer.WriteEventData(this.events); writer.WriteEventData(events);
for (int i = 0; i < this.DataSetCount; i++) { for (int i = 0; i < DataSetCount; i++) {
using (UnmanagedProfilingDataSet dataSet = this.LoadDataSet(i)) using (UnmanagedProfilingDataSet dataSet = LoadDataSet(i))
writer.WriteDataSet(dataSet); writer.WriteDataSet(dataSet);
if (!progressReport.Invoke((i + 1) / (double)this.DataSetCount)) if (!progressReport.Invoke((i + 1) / (double)DataSetCount))
break; break;
} }
} }
@ -321,7 +320,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// Returns the number of DataSets stored in the database. /// Returns the number of DataSets stored in the database.
/// </summary> /// </summary>
public int DataSetCount { public int DataSetCount {
get { return this.streamInfos.Count; } get { return streamInfos.Count; }
} }
/// <summary> /// <summary>

8
src/AddIns/Analysis/Profiler/Controller/Data/UnitTestRootCallTreeNode.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public class UnitTestRootCallTreeNode : CallTreeNode public class UnitTestRootCallTreeNode : CallTreeNode
{ {
List<CallTreeNode> unitTests = null; List<CallTreeNode> unitTests;
/// <summary> /// <summary>
/// Creates a new UnitTestRootCallTreeNode. /// Creates a new UnitTestRootCallTreeNode.
@ -40,7 +40,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public override bool IsActiveAtStart { public override bool IsActiveAtStart {
get { get {
return (this.unitTests == null) ? false : this.unitTests.Any(test => test.IsActiveAtStart); return (unitTests == null) ? false : unitTests.Any(test => test.IsActiveAtStart);
} }
} }
@ -66,7 +66,7 @@ namespace ICSharpCode.Profiler.Controller.Data
} }
/// <inheritdoc/> /// <inheritdoc/>
public override CallTreeNode Merge(System.Collections.Generic.IEnumerable<CallTreeNode> nodes) public override CallTreeNode Merge(IEnumerable<CallTreeNode> nodes)
{ {
// throw new ShouldNeverHappenException(); // throw new ShouldNeverHappenException();
throw new NotSupportedException("Cannot merge a UnitTestRootCallTreeNode (should never be possible)"); throw new NotSupportedException("Cannot merge a UnitTestRootCallTreeNode (should never be possible)");
@ -75,7 +75,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()
{ {
return (this.unitTests == null) ? 0 : this.unitTests.Aggregate(0, (sum, item) => sum ^= item.GetHashCode()); return (unitTests == null) ? 0 : unitTests.Aggregate(0, (sum, item) => sum ^= item.GetHashCode());
} }
/// <inheritdoc/> /// <inheritdoc/>

20
src/AddIns/Analysis/Profiler/Controller/Data/UnitTestWriter.cs

@ -47,8 +47,8 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <inheritdoc/> /// <inheritdoc/>
public int ProcessorFrequency { public int ProcessorFrequency {
get { return this.targetWriter.ProcessorFrequency; } get { return targetWriter.ProcessorFrequency; }
set { this.targetWriter.ProcessorFrequency = value; } set { targetWriter.ProcessorFrequency = value; }
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -62,13 +62,13 @@ namespace ICSharpCode.Profiler.Controller.Data
FindUnitTests(dataSet.RootNode, list); FindUnitTests(dataSet.RootNode, list);
if (list.Count > 0) { if (list.Count > 0) {
this.targetWriter.WriteDataSet( targetWriter.WriteDataSet(
new UnitTestDataSet(new UnitTestRootCallTreeNode(list), dataSet.IsFirst) new UnitTestDataSet(new UnitTestRootCallTreeNode(list), dataSet.IsFirst)
); );
} else { } else {
// proposed fix for http://community.sharpdevelop.net/forums/t/10533.aspx // proposed fix for http://community.sharpdevelop.net/forums/t/10533.aspx
// discuss with Daniel // discuss with Daniel
this.targetWriter.WriteDataSet(dataSet); targetWriter.WriteDataSet(dataSet);
} }
} }
@ -90,32 +90,32 @@ namespace ICSharpCode.Profiler.Controller.Data
} }
/// <inheritdoc/> /// <inheritdoc/>
public void WriteMappings(System.Collections.Generic.IEnumerable<NameMapping> mappings) public void WriteMappings(IEnumerable<NameMapping> mappings)
{ {
this.targetWriter.WriteMappings(mappings); targetWriter.WriteMappings(mappings);
} }
/// <inheritdoc/> /// <inheritdoc/>
public void Close() public void Close()
{ {
this.targetWriter.Close(); targetWriter.Close();
} }
/// <inheritdoc/> /// <inheritdoc/>
public void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters) public void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters)
{ {
this.targetWriter.WritePerformanceCounterData(counters); targetWriter.WritePerformanceCounterData(counters);
} }
/// <inheritdoc/> /// <inheritdoc/>
public void WriteEventData(IEnumerable<EventDataEntry> events) public void WriteEventData(IEnumerable<EventDataEntry> events)
{ {
this.targetWriter.WriteEventData(events); targetWriter.WriteEventData(events);
} }
/// <inheritdoc/> /// <inheritdoc/>
public int DataSetCount { public int DataSetCount {
get { return this.targetWriter.DataSetCount; } get { return targetWriter.DataSetCount; }
} }
} }
} }

23
src/AddIns/Analysis/Profiler/Controller/Data/UnmanagedCallTreeNode.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
namespace ICSharpCode.Profiler.Controller.Data namespace ICSharpCode.Profiler.Controller.Data
@ -25,7 +24,7 @@ namespace ICSharpCode.Profiler.Controller.Data
this.parent = parent; this.parent = parent;
} }
public override System.Linq.IQueryable<CallTreeNode> Children { public override IQueryable<CallTreeNode> Children {
get { get {
dataSet.VerifyAccess(); dataSet.VerifyAccess();
@ -47,35 +46,35 @@ namespace ICSharpCode.Profiler.Controller.Data
public override NameMapping NameMapping { public override NameMapping NameMapping {
get { get {
return this.dataSet.GetMapping(this.data->Id); return dataSet.GetMapping(data->Id);
} }
} }
public override int RawCallCount { public override int RawCallCount {
get { get {
dataSet.VerifyAccess(); // need to verify before deferencing data dataSet.VerifyAccess(); // need to verify before deferencing data
return this.data->CallCount; return data->CallCount;
} }
} }
public int Index { public int Index {
get { get {
dataSet.VerifyAccess(); // need to verify before deferencing data dataSet.VerifyAccess(); // need to verify before deferencing data
return (int)(this.data->TimeSpent >> 56); return (int)(data->TimeSpent >> 56);
} }
} }
public override bool IsActiveAtStart { public override bool IsActiveAtStart {
get { get {
dataSet.VerifyAccess(); // need to verify before deferencing data dataSet.VerifyAccess(); // need to verify before deferencing data
return (this.data->TimeSpent & ((ulong)1 << 55)) != 0; return (data->TimeSpent & ((ulong)1 << 55)) != 0;
} }
} }
public override long CpuCyclesSpent { public override long CpuCyclesSpent {
get { get {
dataSet.VerifyAccess(); // need to verify before deferencing data dataSet.VerifyAccess(); // need to verify before deferencing data
return (long)(this.data->TimeSpent & CpuCycleMask); return (long)(data->TimeSpent & CpuCycleMask);
} }
} }
@ -83,7 +82,7 @@ namespace ICSharpCode.Profiler.Controller.Data
get { get {
dataSet.VerifyAccess(); dataSet.VerifyAccess();
long result = (long)(this.data->TimeSpent & CpuCycleMask); long result = (long)(data->TimeSpent & CpuCycleMask);
TargetProcessPointer32* childrenPtr = FunctionInfo.GetChildren32(data); TargetProcessPointer32* childrenPtr = FunctionInfo.GetChildren32(data);
for (int i = 0; i <= data->LastChildIndex; i++) for (int i = 0; i <= data->LastChildIndex; i++)
@ -99,19 +98,19 @@ namespace ICSharpCode.Profiler.Controller.Data
public override CallTreeNode Parent { public override CallTreeNode Parent {
get { get {
return this.parent; return parent;
} }
} }
public override double TimeSpent { public override double TimeSpent {
get { get {
return this.CpuCyclesSpent / (1000.0 * this.dataSet.ProcessorFrequency); return CpuCyclesSpent / (1000.0 * dataSet.ProcessorFrequency);
} }
} }
public override double TimeSpentSelf { public override double TimeSpentSelf {
get { get {
return this.CpuCyclesSpentSelf / (1000.0 * this.dataSet.ProcessorFrequency); return CpuCyclesSpentSelf / (1000.0 * dataSet.ProcessorFrequency);
} }
} }
@ -135,7 +134,7 @@ namespace ICSharpCode.Profiler.Controller.Data
{ {
UnmanagedCallTreeNode32 node = other as UnmanagedCallTreeNode32; UnmanagedCallTreeNode32 node = other as UnmanagedCallTreeNode32;
if (node != null) { if (node != null) {
return node.data == this.data; return node.data == data;
} }
return false; return false;

6
src/AddIns/Analysis/Profiler/Controller/Data/UnmanagedProfilingDataSet.cs

@ -82,12 +82,12 @@ namespace ICSharpCode.Profiler.Controller.Data
internal unsafe FunctionInfo* GetFunctionInfo(TargetProcessPointer ptr) internal unsafe FunctionInfo* GetFunctionInfo(TargetProcessPointer ptr)
{ {
return (FunctionInfo*)this.TranslatePointer(ptr); return (FunctionInfo*)TranslatePointer(ptr);
} }
internal unsafe FunctionInfo* GetRootFunctionInfo() internal unsafe FunctionInfo* GetRootFunctionInfo()
{ {
return GetFunctionInfo(this.nativeRootFuncInfoPosition); return GetFunctionInfo(nativeRootFuncInfoPosition);
} }
/// <summary> /// <summary>
@ -96,7 +96,7 @@ namespace ICSharpCode.Profiler.Controller.Data
public unsafe CallTreeNode RootNode { public unsafe CallTreeNode RootNode {
get { get {
VerifyAccess(); VerifyAccess();
if (this.is64Bit) if (is64Bit)
return new UnmanagedCallTreeNode64( return new UnmanagedCallTreeNode64(
this, this,
GetRootFunctionInfo(), GetRootFunctionInfo(),

2
src/AddIns/Analysis/Profiler/Controller/ExtensionMethods.cs

@ -8,9 +8,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;

4
src/AddIns/Analysis/Profiler/Controller/Interprocess/AtomicBoolean.cs

@ -48,7 +48,7 @@ namespace ICSharpCode.Profiler.Interprocess
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()
{ {
return this.Value.GetHashCode(); return Value.GetHashCode();
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -62,7 +62,7 @@ namespace ICSharpCode.Profiler.Interprocess
/// </summary> /// </summary>
public bool Equals(AtomicBoolean other) public bool Equals(AtomicBoolean other)
{ {
return this.Value == other.Value; return Value == other.Value;
} }
/// <summary> /// <summary>

12
src/AddIns/Analysis/Profiler/Controller/Interprocess/MemoryMappedFile.cs

@ -9,12 +9,12 @@ using System.Threading;
namespace ICSharpCode.Profiler.Interprocess namespace ICSharpCode.Profiler.Interprocess
{ {
// aliases for WIN32 types // aliases for WIN32 types
using WORD = System.Int16; using WORD = Int16;
using DWORD = System.Int32; using DWORD = Int32;
using ULONG = System.UInt32; using ULONG = UInt32;
using LPVOID = System.IntPtr; using LPVOID = IntPtr;
using DWORD_PTR = System.IntPtr; using DWORD_PTR = IntPtr;
using HANDLE = System.IntPtr; using HANDLE = IntPtr;
/// <summary> /// <summary>
/// Represents a memory mapped file. /// Represents a memory mapped file.

4
src/AddIns/Analysis/Profiler/Controller/Interprocess/UnmanagedCircularBuffer.cs

@ -59,7 +59,7 @@ namespace ICSharpCode.Profiler.Interprocess
public static readonly int SynchronizationOverheadSize = sizeof(UnmanagedCircularBufferHeader); public static readonly int SynchronizationOverheadSize = sizeof(UnmanagedCircularBufferHeader);
#region Construction #region Construction
private UnmanagedCircularBuffer(IntPtr bufferPointer, int bufferLength) UnmanagedCircularBuffer(IntPtr bufferPointer, int bufferLength)
{ {
// we need space for the header and at least 2 bytes of data (because the buffer can never be completely filled) // we need space for the header and at least 2 bytes of data (because the buffer can never be completely filled)
if (bufferLength < sizeof(UnmanagedCircularBufferHeader) + 2) if (bufferLength < sizeof(UnmanagedCircularBufferHeader) + 2)
@ -281,7 +281,7 @@ namespace ICSharpCode.Profiler.Interprocess
// wait until there's data // wait until there's data
while (startOffset == endOffset) { while (startOffset == endOffset) {
lock (circularBuffer.closeLock) { lock (circularBuffer.closeLock) {
if (this.circularBuffer.isClosed) { if (circularBuffer.isClosed) {
Monitor.Pulse(circularBuffer.closeLock); Monitor.Pulse(circularBuffer.closeLock);
return 0; return 0;
} }

5
src/AddIns/Analysis/Profiler/Controller/Profiler.Controller.csproj

@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ICSharpCode.Profiler.Controller</RootNamespace> <RootNamespace>ICSharpCode.Profiler.Controller</RootNamespace>
<AssemblyName>ICSharpCode.Profiler.Controller</AssemblyName> <AssemblyName>ICSharpCode.Profiler.Controller</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
@ -46,7 +46,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

128
src/AddIns/Analysis/Profiler/Controller/Profiler.cs

@ -69,10 +69,10 @@ namespace ICSharpCode.Profiler.Controller
public int ProcessorFrequency public int ProcessorFrequency
{ {
get { get {
if (this.is64Bit) if (is64Bit)
return this.memHeader64->ProcessorFrequency; return memHeader64->ProcessorFrequency;
else else
return this.memHeader32->ProcessorFrequency; return memHeader32->ProcessorFrequency;
} }
} }
@ -202,7 +202,7 @@ namespace ICSharpCode.Profiler.Controller
/// </summary> /// </summary>
public void EnableDataCollection() public void EnableDataCollection()
{ {
this.enableDC = true; enableDC = true;
} }
/// <summary> /// <summary>
@ -210,8 +210,8 @@ namespace ICSharpCode.Profiler.Controller
/// </summary> /// </summary>
public void DisableDataCollection() public void DisableDataCollection()
{ {
this.enableDC = false; enableDC = false;
this.isFirstDC = true; isFirstDC = true;
} }
/// <summary> /// <summary>
@ -321,16 +321,16 @@ namespace ICSharpCode.Profiler.Controller
void DataCollection() void DataCollection()
{ {
while (!stopDC) { while (!stopDC) {
this.Pause(); Pause();
this.threadListMutex.WaitOne(); threadListMutex.WaitOne();
if (this.is64Bit) if (is64Bit)
CollectData64(); CollectData64();
else else
CollectData32(); CollectData32();
this.threadListMutex.ReleaseMutex(); threadListMutex.ReleaseMutex();
this.Continue(); Continue();
Thread.Sleep(500); Thread.Sleep(500);
} }
} }
@ -342,7 +342,7 @@ namespace ICSharpCode.Profiler.Controller
ulong now = GetRdtsc(); ulong now = GetRdtsc();
ThreadLocalData32* item = (ThreadLocalData32*)TranslatePointer(this.memHeader32->LastThreadListItem); ThreadLocalData32* item = (ThreadLocalData32*)TranslatePointer(memHeader32->LastThreadListItem);
List<Stack<int>> stackList = new List<Stack<int>>(); List<Stack<int>> stackList = new List<Stack<int>>();
@ -363,8 +363,8 @@ namespace ICSharpCode.Profiler.Controller
item = (ThreadLocalData32*)TranslatePointer(item->Predecessor); item = (ThreadLocalData32*)TranslatePointer(item->Predecessor);
} }
if (this.enableDC) { if (enableDC) {
this.AddDataset(fullView.Pointer, AddDataset(fullView.Pointer,
memHeader32->NativeAddress + memHeader32->HeapOffset, memHeader32->NativeAddress + memHeader32->HeapOffset,
memHeader32->Allocator.startPos - memHeader32->NativeAddress, memHeader32->Allocator.startPos - memHeader32->NativeAddress,
memHeader32->Allocator.pos - memHeader32->Allocator.startPos, memHeader32->Allocator.pos - memHeader32->Allocator.startPos,
@ -381,7 +381,7 @@ namespace ICSharpCode.Profiler.Controller
memHeader32->RootFuncInfoAddress = TranslatePointerBack32(root); memHeader32->RootFuncInfoAddress = TranslatePointerBack32(root);
item = (ThreadLocalData32*)TranslatePointer(this.memHeader32->LastThreadListItem); item = (ThreadLocalData32*)TranslatePointer(memHeader32->LastThreadListItem);
now = GetRdtsc(); now = GetRdtsc();
@ -415,8 +415,8 @@ namespace ICSharpCode.Profiler.Controller
unsafe void AddDataset(byte *ptr, TargetProcessPointer nativeStartPosition, long offset, long length, bool isFirst, TargetProcessPointer nativeRootFuncInfoPosition) unsafe void AddDataset(byte *ptr, TargetProcessPointer nativeStartPosition, long offset, long length, bool isFirst, TargetProcessPointer nativeRootFuncInfoPosition)
{ {
using (DataSet dataSet = new DataSet(this, ptr + offset, length, nativeStartPosition, nativeRootFuncInfoPosition, isFirst, is64Bit)) { using (DataSet dataSet = new DataSet(this, ptr + offset, length, nativeStartPosition, nativeRootFuncInfoPosition, isFirst, is64Bit)) {
lock (this.dataWriter) { lock (dataWriter) {
this.dataWriter.WriteDataSet(dataSet); dataWriter.WriteDataSet(dataSet);
if (usePerformanceCounters) { if (usePerformanceCounters) {
if (performanceCounterInstanceName == null) if (performanceCounterInstanceName == null)
@ -487,7 +487,7 @@ namespace ICSharpCode.Profiler.Controller
while (readString != null) { while (readString != null) {
readString = ReadString(stream); readString = ReadString(stream);
if (readString != null && !ProcessCommand(readString)) if (readString != null && !ProcessCommand(readString))
this.LogString(readString); LogString(readString);
} }
} }
@ -526,23 +526,23 @@ namespace ICSharpCode.Profiler.Controller
LogString("Using 64-bit hook."); LogString("Using 64-bit hook.");
LogString("Starting process, waiting for profiler hook..."); LogString("Starting process, waiting for profiler hook...");
this.profilee = new Process(); profilee = new Process();
this.profilee.EnableRaisingEvents = true; profilee.EnableRaisingEvents = true;
this.profilee.StartInfo = this.psi; profilee.StartInfo = psi;
this.profilee.Exited += new EventHandler(ProfileeExited); profilee.Exited += new EventHandler(ProfileeExited);
this.enableDC = this.profilerOptions.EnableDCAtStart; enableDC = profilerOptions.EnableDCAtStart;
this.isFirstDC = true; isFirstDC = true;
Debug.WriteLine("Launching profiler for " + this.psi.FileName + "..."); Debug.WriteLine("Launching profiler for " + psi.FileName + "...");
this.profilee.Start(); profilee.Start();
this.logger.Start(nativeToManagedBuffer.CreateReadingStream()); logger.Start(nativeToManagedBuffer.CreateReadingStream());
// GC references currentSession // GC references currentSession
if (this.profilerOptions.EnableDC) { if (profilerOptions.EnableDC) {
this.dataCollector.Start(); dataCollector.Start();
} }
OnSessionStarted(EventArgs.Empty); OnSessionStarted(EventArgs.Empty);
@ -554,11 +554,11 @@ namespace ICSharpCode.Profiler.Controller
/// </summary> /// </summary>
void Pause() void Pause()
{ {
this.accessEventHandle.Reset(); accessEventHandle.Reset();
if (is64Bit) if (is64Bit)
this.memHeader64->ExclusiveAccess = 1; memHeader64->ExclusiveAccess = 1;
else else
this.memHeader32->ExclusiveAccess = 1; memHeader32->ExclusiveAccess = 1;
Thread.MemoryBarrier(); Thread.MemoryBarrier();
if (is64Bit) if (is64Bit)
while (!AllThreadsWait64()) ; while (!AllThreadsWait64()) ;
@ -569,7 +569,7 @@ namespace ICSharpCode.Profiler.Controller
bool AllThreadsWait32() bool AllThreadsWait32()
{ {
try { try {
this.threadListMutex.WaitOne(); threadListMutex.WaitOne();
} catch (AbandonedMutexException) { } catch (AbandonedMutexException) {
// profilee crashed while holding the thread list mutex // profilee crashed while holding the thread list mutex
return true; return true;
@ -577,7 +577,7 @@ namespace ICSharpCode.Profiler.Controller
bool isWaiting = true; bool isWaiting = true;
ThreadLocalData32* item = (ThreadLocalData32*)TranslatePointer(this.memHeader32->LastThreadListItem); ThreadLocalData32* item = (ThreadLocalData32*)TranslatePointer(memHeader32->LastThreadListItem);
while (item != null) { while (item != null) {
if (item->InLock == 1) if (item->InLock == 1)
@ -586,7 +586,7 @@ namespace ICSharpCode.Profiler.Controller
item = (ThreadLocalData32*)TranslatePointer(item->Predecessor); item = (ThreadLocalData32*)TranslatePointer(item->Predecessor);
} }
this.threadListMutex.ReleaseMutex(); threadListMutex.ReleaseMutex();
return isWaiting; return isWaiting;
} }
@ -597,10 +597,10 @@ namespace ICSharpCode.Profiler.Controller
void Continue() void Continue()
{ {
if (is64Bit) if (is64Bit)
this.memHeader64->ExclusiveAccess = 0; memHeader64->ExclusiveAccess = 0;
else else
this.memHeader32->ExclusiveAccess = 0; memHeader32->ExclusiveAccess = 0;
this.accessEventHandle.Set(); accessEventHandle.Set();
} }
unsafe void ProfileeExited(object sender, EventArgs e) unsafe void ProfileeExited(object sender, EventArgs e)
@ -610,34 +610,34 @@ namespace ICSharpCode.Profiler.Controller
DeregisterProfiler(); DeregisterProfiler();
this.stopDC = true; stopDC = true;
Debug.WriteLine("Closing native to managed buffer"); Debug.WriteLine("Closing native to managed buffer");
nativeToManagedBuffer.Close(true); nativeToManagedBuffer.Close(true);
Debug.WriteLine("Joining logger thread..."); Debug.WriteLine("Joining logger thread...");
this.logger.Join(); logger.Join();
Debug.WriteLine("Logger thread joined!"); Debug.WriteLine("Logger thread joined!");
if (this.profilerOptions.EnableDC) if (profilerOptions.EnableDC)
this.dataCollector.Join(); dataCollector.Join();
// Do last data collection // Do last data collection
if (this.is64Bit) if (is64Bit)
CollectData64(); CollectData64();
else else
CollectData32(); CollectData32();
isRunning = false; isRunning = false;
this.dataWriter.WritePerformanceCounterData(performanceCounters); dataWriter.WritePerformanceCounterData(performanceCounters);
this.dataWriter.Close(); dataWriter.Close();
OnSessionEnded(EventArgs.Empty); OnSessionEnded(EventArgs.Empty);
} }
internal void LogString(string text) internal void LogString(string text)
{ {
this.profilerOutput.AppendLine(text); profilerOutput.AppendLine(text);
OnOutputUpdated(EventArgs.Empty); OnOutputUpdated(EventArgs.Empty);
} }
@ -654,7 +654,7 @@ namespace ICSharpCode.Profiler.Controller
internal unsafe void* TranslatePointer(TargetProcessPointer ptr) internal unsafe void* TranslatePointer(TargetProcessPointer ptr)
{ {
if (this.is64Bit) if (is64Bit)
return TranslatePointer64(ptr.To64()); return TranslatePointer64(ptr.To64());
else else
return TranslatePointer32(ptr.To32()); return TranslatePointer32(ptr.To32());
@ -698,8 +698,8 @@ namespace ICSharpCode.Profiler.Controller
string returnType = parts[3]; string returnType = parts[3];
IList<string> parameters = parts.Skip(5).ToList(); IList<string> parameters = parts.Skip(5).ToList();
lock (this.dataWriter) { lock (dataWriter) {
this.dataWriter.WriteMappings(new NameMapping[] {new NameMapping(id, returnType, name, parameters)}); dataWriter.WriteMappings(new NameMapping[] {new NameMapping(id, returnType, name, parameters)});
} }
return true; return true;
@ -712,8 +712,8 @@ namespace ICSharpCode.Profiler.Controller
int id = int.Parse(parts[1], CultureInfo.InvariantCulture); int id = int.Parse(parts[1], CultureInfo.InvariantCulture);
string name = parts[3] + ((string.IsNullOrEmpty(parts[4])) ? "" : " - " + parts[4]); string name = parts[3] + ((string.IsNullOrEmpty(parts[4])) ? "" : " - " + parts[4]);
lock (this.dataWriter) { lock (dataWriter) {
this.dataWriter.WriteMappings(new[] {new NameMapping(id, null, name, null)}); dataWriter.WriteMappings(new[] {new NameMapping(id, null, name, null)});
} }
return true; return true;
@ -726,8 +726,8 @@ namespace ICSharpCode.Profiler.Controller
int name = int.Parse(parts[2], CultureInfo.InvariantCulture); int name = int.Parse(parts[2], CultureInfo.InvariantCulture);
string data = parts[3]; string data = parts[3];
lock (this.dataWriter) { lock (dataWriter) {
this.dataWriter.WriteEventData(new[] { new EventDataEntry() { DataSetId = this.dataWriter.DataSetCount, NameId = name, Type = (EventType)type, Data = data } }); dataWriter.WriteEventData(new[] { new EventDataEntry() { DataSetId = dataWriter.DataSetCount, NameId = name, Type = (EventType)type, Data = data } });
} }
return true; return true;
} else { } else {
@ -820,27 +820,27 @@ namespace ICSharpCode.Profiler.Controller
stopDC = true; stopDC = true;
nativeToManagedBuffer.Close(true); nativeToManagedBuffer.Close(true);
try { try {
this.profilee.Kill(); profilee.Kill();
} catch (InvalidOperationException) { } catch (InvalidOperationException) {
// can happen if profilee has already exited // can happen if profilee has already exited
} }
if (logger != null && logger.IsAlive) { if (logger != null && logger.IsAlive) {
this.logger.Join(); logger.Join();
} }
if (dataCollector != null && dataCollector.IsAlive) { if (dataCollector != null && dataCollector.IsAlive) {
this.dataCollector.Join(); dataCollector.Join();
} }
this.fullView.Dispose(); fullView.Dispose();
this.file.Close(); file.Close();
this.threadListMutex.Close(); threadListMutex.Close();
this.accessEventHandle.Close(); accessEventHandle.Close();
this.dataWriter.Close(); dataWriter.Close();
this.profilee.Dispose(); profilee.Dispose();
} }
} }
@ -865,13 +865,13 @@ namespace ICSharpCode.Profiler.Controller
public override int ProcessorFrequency { public override int ProcessorFrequency {
get { get {
return this.profiler.ProcessorFrequency; return profiler.ProcessorFrequency;
} }
} }
internal unsafe override void* TranslatePointer(TargetProcessPointer ptr) internal unsafe override void* TranslatePointer(TargetProcessPointer ptr)
{ {
return this.profiler.TranslatePointer(ptr); return profiler.TranslatePointer(ptr);
} }
} }
#endregion #endregion

3
src/AddIns/Analysis/Profiler/Controller/ProfilerOptions.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
@ -41,7 +40,7 @@ namespace ICSharpCode.Profiler.Controller
/// Gets the performance counters selected for monitoring. /// Gets the performance counters selected for monitoring.
/// </summary> /// </summary>
public PerformanceCounterDescriptor[] Counters { public PerformanceCounterDescriptor[] Counters {
get { return this.counters; } get { return counters; }
} }
/// <summary> /// <summary>

1
src/AddIns/Analysis/Profiler/Controller/Properties/AssemblyInfo.cs

@ -5,7 +5,6 @@ using System;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Permissions;
// Allgemeine Informationen über eine Assembly werden über die folgenden // Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,

2
src/AddIns/Analysis/Profiler/Controller/Queries/NodePath.cs

@ -58,7 +58,7 @@ namespace ICSharpCode.Profiler.Controller.Queries
if (other == null) if (other == null)
return false; return false;
return other.lastId == this.lastId && object.Equals(other.previous, this.previous); return other.lastId == lastId && object.Equals(other.previous, previous);
} }
/// <inheritdoc/> /// <inheritdoc/>

5
src/AddIns/Analysis/Profiler/Controller/Queries/QueryBase.cs

@ -1,10 +1,9 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.Profiler.Controller.Data;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using ICSharpCode.Profiler.Controller.Data;
namespace ICSharpCode.Profiler.Controller.Queries namespace ICSharpCode.Profiler.Controller.Queries
{ {
@ -53,7 +52,7 @@ namespace ICSharpCode.Profiler.Controller.Queries
/// </summary> /// </summary>
public CallTreeNode GetNodeByPath(params int[] nameIds) public CallTreeNode GetNodeByPath(params int[] nameIds)
{ {
CallTreeNode node = this.Root; CallTreeNode node = Root;
for (int i = 1; i < nameIds.Length; i++) { for (int i = 1; i < nameIds.Length; i++) {
node = node.Children.FirstOrDefault(n => n.NameMapping.Id == nameIds[i]); node = node.Children.FirstOrDefault(n => n.NameMapping.Id == nameIds[i]);

13
src/AddIns/Analysis/Profiler/Controller/Queries/QueryCompiler.cs

@ -1,15 +1,14 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.Profiler.Controller.Data;
using System; using System;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using Microsoft.CSharp; using Microsoft.CSharp;
using ICSharpCode.Profiler.Controller.Data;
namespace ICSharpCode.Profiler.Controller.Queries namespace ICSharpCode.Profiler.Controller.Queries
{ {
@ -69,11 +68,11 @@ namespace ICSharpCode.Profiler.Controller.Queries
/// <returns>true, if successful, otherwise false.</returns> /// <returns>true, if successful, otherwise false.</returns>
public bool Compile() public bool Compile()
{ {
if (string.IsNullOrEmpty(this.currentQuery)) if (string.IsNullOrEmpty(currentQuery))
return false; return false;
lock (queryCache) { lock (queryCache) {
if (!queryCache.ContainsKey(this.currentQuery)) { if (!queryCache.ContainsKey(currentQuery)) {
string code = text + PreprocessString(currentQuery) + textEnd; string code = text + PreprocessString(currentQuery) + textEnd;
CompilerResults results = csc.CompileAssemblyFromSource(GetParameters(), code); CompilerResults results = csc.CompileAssemblyFromSource(GetParameters(), code);
report(results.Errors.Cast<CompilerError>()); report(results.Errors.Cast<CompilerError>());
@ -81,7 +80,7 @@ namespace ICSharpCode.Profiler.Controller.Queries
if (results.Errors.Count > 0) if (results.Errors.Count > 0)
return false; return false;
queryCache.Add(this.currentQuery, results.CompiledAssembly); queryCache.Add(currentQuery, results.CompiledAssembly);
} else { } else {
report(new List<CompilerError>().AsEnumerable()); // clear errors list report(new List<CompilerError>().AsEnumerable()); // clear errors list
} }
@ -101,7 +100,7 @@ namespace ICSharpCode.Profiler.Controller.Queries
Assembly assembly; Assembly assembly;
lock (queryCache) lock (queryCache)
assembly = queryCache[this.currentQuery]; assembly = queryCache[currentQuery];
QueryBase queryContainer = assembly.CreateInstance("Query") as QueryBase; QueryBase queryContainer = assembly.CreateInstance("Query") as QueryBase;
queryContainer.Provider = provider; queryContainer.Provider = provider;
@ -130,7 +129,7 @@ namespace ICSharpCode.Profiler.Controller.Queries
cp.OutputAssembly = Path.GetTempFileName(); cp.OutputAssembly = Path.GetTempFileName();
cp.ReferencedAssemblies.Add("System.dll"); cp.ReferencedAssemblies.Add("System.dll");
cp.ReferencedAssemblies.Add("System.Core.dll"); cp.ReferencedAssemblies.Add("System.Core.dll");
cp.ReferencedAssemblies.Add(this.GetType().Assembly.Location); cp.ReferencedAssemblies.Add(GetType().Assembly.Location);
cp.WarningLevel = 4; cp.WarningLevel = 4;
cp.TreatWarningsAsErrors = true; cp.TreatWarningsAsErrors = true;

3
src/AddIns/Analysis/Profiler/Controller/structs.cs

@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -126,7 +125,7 @@ namespace ICSharpCode.Profiler.Controller
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj is TargetProcessPointer) { if (obj is TargetProcessPointer) {
return ((TargetProcessPointer)obj).pointer.Pointer == this.pointer.Pointer; return ((TargetProcessPointer)obj).pointer.Pointer == pointer.Pointer;
} }
return false; return false;

2
src/AddIns/Analysis/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin

@ -99,7 +99,7 @@
</And> </And>
<MenuItem id = "RunWithProfiler" <MenuItem id = "RunWithProfiler"
label = "${res:AddIns.Profiler.UnitTests.RunWithProfiler}" label = "${res:AddIns.Profiler.UnitTests.RunWithProfiler}"
class = "ICSharpCode.Profiler.AddIn.Commands.RunTestWithProfilerCommand"/> class = "ICSharpCode.Profiler.AddIn.Commands.RunSelectedTestsWithProfilerCommand"/>
</ComplexCondition> </ComplexCondition>
</Path> </Path>
</AddIn> </AddIn>

12
src/AddIns/Analysis/Profiler/Frontend/AddIn/Profiler.AddIn.csproj

@ -7,7 +7,7 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Profiler.AddIn</RootNamespace> <RootNamespace>ICSharpCode.Profiler.AddIn</RootNamespace>
<AssemblyName>ICSharpCode.Profiler.AddIn</AssemblyName> <AssemblyName>ICSharpCode.Profiler.AddIn</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@ -90,8 +90,8 @@
<DependentUpon>General.xaml</DependentUpon> <DependentUpon>General.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Src\OptionPanels\OptionWrapper.cs" /> <Compile Include="Src\OptionPanels\OptionWrapper.cs" />
<Compile Include="Src\ProfilerProcessRunner.cs" />
<Compile Include="Src\ProfilerRunner.cs" /> <Compile Include="Src\ProfilerRunner.cs" />
<Compile Include="Src\ProfilerTestRunner.cs" />
<Compile Include="Src\SharpDevelopTranslation.cs" /> <Compile Include="Src\SharpDevelopTranslation.cs" />
<Compile Include="Src\Views\ComparisonView.xaml.cs"> <Compile Include="Src\Views\ComparisonView.xaml.cs">
<DependentUpon>ComparisonView.xaml</DependentUpon> <DependentUpon>ComparisonView.xaml</DependentUpon>
@ -140,6 +140,14 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
<Name>ICSharpCode.NRefactory.CSharp</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name> <Name>ICSharpCode.SharpDevelop</Name>

3
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/CopySelectedData.cs

@ -6,10 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controls; using ICSharpCode.Profiler.Controls;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands

23
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/DomMenuCommand.cs

@ -5,9 +5,9 @@ using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
@ -21,7 +21,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
public abstract override void Run(); public abstract override void Run();
protected IMember GetMemberFromName(IClass c, string name, ReadOnlyCollection<string> parameters) protected IMember GetMemberFromName(ITypeDefinition c, string name, ReadOnlyCollection<string> parameters)
{ {
if (name == null || c == null) if (name == null || c == null)
return null; return null;
@ -54,7 +54,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
matchWithSameParameterCount = method; matchWithSameParameterCount = method;
bool isCorrect = true; bool isCorrect = true;
for (int i = 0; i < method.Parameters.Count; i++) { for (int i = 0; i < method.Parameters.Count; i++) {
if (parameters[i] != ambience.Convert(method.Parameters[i])) { if (parameters[i] != ambience.ConvertVariable(method.Parameters[i])) {
isCorrect = false; isCorrect = false;
break; break;
} }
@ -67,20 +67,19 @@ namespace ICSharpCode.Profiler.AddIn.Commands
return matchWithSameParameterCount ?? matchWithSameName; return matchWithSameParameterCount ?? matchWithSameName;
} }
protected IClass GetClassFromName(string name) protected ITypeDefinition GetClassFromName(string name)
{ {
if (name == null) if (name == null)
return null; return null;
if (ProjectService.OpenSolution == null) if (ProjectService.OpenSolution == null)
return null; return null;
foreach (IProject project in ProjectService.OpenSolution.Projects) { foreach (IProject project in SD.ProjectService.CurrentSolution.Projects) {
IProjectContent content = ParserService.GetProjectContent(project); ICompilation compilation = SD.ParserService.GetCompilation(project);
if (content != null) { IType type = compilation.FindType(new FullTypeName(name));
IClass c = content.GetClassByReflectionName(name, true); ITypeDefinition definition = type.GetDefinition();
if (c != null) if (definition != null)
return c; return definition;
}
} }
return null; return null;

5
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/FindCallsOfSelected.cs

@ -3,16 +3,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Controls;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.Profiler.Controller.Queries; using ICSharpCode.Profiler.Controller.Queries;
using ICSharpCode.Profiler.Controls;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {

9
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/FindReferences.cs

@ -3,8 +3,7 @@
using System; using System;
using System.Linq; using System.Linq;
using ICSharpCode.Core; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Refactoring;
@ -22,7 +21,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
if (selectedItem == null) if (selectedItem == null)
return; return;
IClass c = GetClassFromName(selectedItem.FullyQualifiedClassName); ITypeDefinition c = GetClassFromName(selectedItem.FullyQualifiedClassName);
if (c == null) if (c == null)
return; return;
@ -35,9 +34,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
string memberName = member.DeclaringType.Name + "." + member.Name; string memberName = member.DeclaringType.Name + "." + member.Name;
using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}")) using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}"))
{ {
FindReferencesAndRenameHelper.ShowAsSearchResults( FindReferencesAndRenameHelper.RunFindReferences(member);
StringParser.Parse("${res:SharpDevelop.Refactoring.ReferencesTo}", new StringTagPair("Name", memberName)),
RefactoringService.FindReferences(member, monitor));
} }
} }
} }

14
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs

@ -3,8 +3,9 @@
using System; using System;
using System.Linq; using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {
@ -19,14 +20,13 @@ namespace ICSharpCode.Profiler.AddIn.Commands
public override void Run() public override void Run()
{ {
var selectedItem = GetSelectedItems().FirstOrDefault(); var selectedItem = GetSelectedItems().FirstOrDefault();
if (selectedItem != null) { if (selectedItem != null) {
IClass c = GetClassFromName(selectedItem.FullyQualifiedClassName); ITypeDefinition c = GetClassFromName(selectedItem.FullyQualifiedClassName);
if (c != null) { if (c != null) {
IEntity member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters); IMember member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters);
FilePosition position = c.ProjectContent.GetPosition(member ?? c); if (!member.Region.IsEmpty && !string.IsNullOrEmpty(member.Region.FileName)) {
if (!position.IsEmpty && !string.IsNullOrEmpty(position.FileName)) { FileName fn = new FileName(member.Region.FileName);
FileService.JumpToFilePosition(position.FileName, position.Line, position.Column); SD.FileService.JumpToFilePosition(fn, member.Region.BeginLine, member.Region.BeginColumn);
} }
} }
} }

4
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ProfileExecutable.cs

@ -3,8 +3,8 @@
using System; using System;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.Profiler.AddIn.Dialogs; using ICSharpCode.Profiler.AddIn.Dialogs;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {
@ -19,7 +19,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
public override void Run() public override void Run()
{ {
ProfileExecutableForm form = new ProfileExecutableForm(); ProfileExecutableForm form = new ProfileExecutableForm();
form.Owner = WorkbenchSingleton.MainWindow; form.Owner = SD.Workbench.MainWindow;
form.ShowDialog(); form.ShowDialog();
} }
} }

1
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs

@ -8,7 +8,6 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {
using ICSharpCode.Profiler.Controller;
/// <summary> /// <summary>
/// Description of RunProject /// Description of RunProject

3
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ProfilerMenuCommand.cs

@ -5,12 +5,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes; using System.Windows.Shapes;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controls; using ICSharpCode.Profiler.Controls;
using ICSharpCode.Profiler.AddIn.Views;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {

16
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/RunTestWithProfilerCommand.cs

@ -1,16 +1,24 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Project; using System.Collections.Generic;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.UnitTesting; using ICSharpCode.UnitTesting;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {
public class RunTestWithProfilerCommand : AbstractRunTestCommand public class RunSelectedTestsWithProfilerCommand : AbstractMenuCommand
{ {
protected override ITestRunner CreateTestRunner(IProject project) public override void Run()
{ {
return new ProfilerTestRunner(); ITestService testService = SD.GetRequiredService<ITestService>();
IEnumerable<ITest> tests = TestableCondition.GetTests(testService.OpenSolution, Owner);
string path = tests.FirstOrDefault().ParentProject.Project.GetSessionFileName();
testService.RunTestsAsync(tests, new TestExecutionOptions { ProcessRunner = new ProfilerProcessRunner(new ProfilingDataSQLiteWriter(path), new ProfilerOptions()) }).FireAndForget();
} }
} }
} }

5
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/SetAsRoot.cs

@ -3,16 +3,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Controls;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.Profiler.Controller.Queries; using ICSharpCode.Profiler.Controller.Queries;
using ICSharpCode.Profiler.Controls;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {

5
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ShowFunctions.cs

@ -2,15 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Controls;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controls; using ICSharpCode.Profiler.Controls;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.Profiler.AddIn.Commands namespace ICSharpCode.Profiler.AddIn.Commands
{ {

7
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Dialogs/ProfileExecutableForm.xaml.cs

@ -11,7 +11,6 @@ using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller; using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using Microsoft.Win32; using Microsoft.Win32;
namespace ICSharpCode.Profiler.AddIn.Dialogs namespace ICSharpCode.Profiler.AddIn.Dialogs
@ -28,7 +27,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
void btnCancelClick(object sender, RoutedEventArgs e) void btnCancelClick(object sender, RoutedEventArgs e)
{ {
this.Close(); Close();
} }
void btnStartClick(object sender, RoutedEventArgs e) void btnStartClick(object sender, RoutedEventArgs e)
@ -58,13 +57,13 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
if (runner != null) { if (runner != null) {
runner.RunFinished += delegate { runner.RunFinished += delegate {
WorkbenchSingleton.SafeThreadCall(() => FileService.OpenFile(outputPath)); SD.MainThread.InvokeIfRequired(() => FileService.OpenFile(outputPath));
}; };
runner.Run(); runner.Run();
} }
this.Close(); Close();
} catch (ProfilerException ex) { } catch (ProfilerException ex) {
MessageService.ShowError(ex.Message); MessageService.ShowError(ex.Message);
} }

18
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml.cs

@ -1,17 +1,9 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.Core;
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using ICSharpCode.Core;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.Profiler.Controller;
namespace ICSharpCode.Profiler.AddIn.Dialogs namespace ICSharpCode.Profiler.AddIn.Dialogs
{ {
@ -34,7 +26,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
void CollectDataChecked(object sender, RoutedEventArgs e) void CollectDataChecked(object sender, RoutedEventArgs e)
{ {
try { try {
this.runner.Profiler.EnableDataCollection(); runner.Profiler.EnableDataCollection();
} catch (Exception ex) { } catch (Exception ex) {
MessageService.ShowException(ex); MessageService.ShowException(ex);
} }
@ -43,7 +35,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
void CollectDataUnchecked(object sender, RoutedEventArgs e) void CollectDataUnchecked(object sender, RoutedEventArgs e)
{ {
try { try {
this.runner.Profiler.DisableDataCollection(); runner.Profiler.DisableDataCollection();
} catch (Exception ex) { } catch (Exception ex) {
MessageService.ShowException(ex); MessageService.ShowException(ex);
} }
@ -51,8 +43,8 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
void ShutdownClick(object sender, RoutedEventArgs e) void ShutdownClick(object sender, RoutedEventArgs e)
{ {
this.AllowClose = true; AllowClose = true;
this.runner.Stop(); runner.Stop();
} }
void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e) void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)

6
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Extensions.cs

@ -1,7 +1,6 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Gui;
using System; using System;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
@ -34,15 +33,14 @@ namespace ICSharpCode.Profiler.AddIn
if (!File.Exists(path)) if (!File.Exists(path))
return; return;
FileService.OpenFile(path); FileService.OpenFile(path);
if (!project.ReadOnly) { if (!project.IsReadOnly) {
FileProjectItem file = new FileProjectItem(project, ItemType.Content, "ProfilingSessions\\" + Path.GetFileName(path)); FileProjectItem file = new FileProjectItem(project, ItemType.Content, "ProfilingSessions\\" + Path.GetFileName(path));
ProjectService.AddProjectItem(project, file); ProjectService.AddProjectItem(project, file);
ProjectBrowserPad.RefreshViewAsync(); ProjectBrowserPad.RefreshViewAsync();
project.Save(); project.Save();
} }
}; };
SD.MainThread.InvokeIfRequired(updater);
WorkbenchSingleton.SafeThreadCall(updater);
} }
} }
} }

7
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/OptionPanels/General.cs

@ -2,15 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using System.Windows.Threading;
namespace ICSharpCode.Profiler.AddIn.OptionPanels namespace ICSharpCode.Profiler.AddIn.OptionPanels
{ {

4
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/OptionPanels/OptionWrapper.cs

@ -4,13 +4,13 @@
using System; using System;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller; using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.SharpDevelop;
namespace ICSharpCode.Profiler.AddIn.OptionPanels namespace ICSharpCode.Profiler.AddIn.OptionPanels
{ {
public static class OptionWrapper public static class OptionWrapper
{ {
static Properties properties = PropertyService.Get("ProfilerOptions", new Properties()); static Properties properties = SD.PropertyService.Get("ProfilerOptions", new Properties());
public static int SharedMemorySize { public static int SharedMemorySize {
get { return properties.Get("SharedMemorySize", ProfilerOptions.DefaultSharedMemorySize) / 1024 / 1024; } get { return properties.Get("SharedMemorySize", ProfilerOptions.DefaultSharedMemorySize) / 1024 / 1024; }

139
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerProcessRunner.cs

@ -0,0 +1,139 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.Profiler.AddIn
{
/// <summary>
/// Description of ProfilerProcessRunner.
/// </summary>
public class ProfilerProcessRunner : IProcessRunner
{
ProcessStartInfo psi;
ProfilerRunner profilerRunner;
Process runningProcess;
IProfilingDataWriter writer;
ProfilerOptions options;
readonly object lockObj = new object();
bool wasStarted;
public ProfilerProcessRunner(IProfilingDataWriter writer, ProfilerOptions options)
{
if (writer == null)
throw new ArgumentNullException("writer");
if (options == null)
throw new ArgumentNullException("options");
this.writer = writer;
this.options = options;
this.psi = new ProcessStartInfo();
wasStarted = false;
}
public Task<int> RunInOutputPadAsync(MessageViewCategory outputCategory, string program, params string[] arguments)
{
throw new NotImplementedException();
}
public void Start(string program, params string[] arguments)
{
lock (lockObj) {
if (wasStarted)
throw new InvalidOperationException();
profilerRunner = new ProfilerRunner(psi, true, writer);
profilerRunner.RunFinished += delegate { hasExited = true; };
runningProcess = profilerRunner.Run();
wasStarted = true;
}
}
public void StartCommandLine(string commandLine)
{
string[] args = ProcessRunner.CommandLineToArgumentArray(commandLine);
Start(args.FirstOrDefault() ?? "", args.Skip(1).ToArray());
}
public void Kill()
{
profilerRunner.Stop();
}
TaskCompletionSource<object> waitForExitTCS;
bool hasExited;
public Task WaitForExitAsync()
{
if (hasExited)
return Task.FromResult(true);
if (!wasStarted)
throw new InvalidOperationException("Process was not yet started");
lock (lockObj) {
if (waitForExitTCS != null) {
waitForExitTCS = new TaskCompletionSource<object>();
profilerRunner.RunFinished += delegate { waitForExitTCS.SetResult(null); };
}
}
return waitForExitTCS.Task;
}
public StreamReader OpenStandardOutputReader()
{
return runningProcess.StandardOutput;
}
public StreamReader OpenStandardErrorReader()
{
return runningProcess.StandardError;
}
public string WorkingDirectory {
get { return psi.WorkingDirectory; }
set { psi.WorkingDirectory = value; }
}
public ProcessCreationFlags CreationFlags { get; set; }
public IDictionary<string, string> EnvironmentVariables { get; set; }
public bool RedirectStandardOutput { get; set; }
public bool RedirectStandardError { get; set; }
public bool RedirectStandardOutputAndErrorToSingleStream { get; set; }
public Stream StandardOutput {
get {
if (runningProcess == null)
throw new InvalidOperationException("Cannot access StdOut of process, because it is not yet started!");
return null;//runningProcess.StandardOutput;
}
}
public Stream StandardError {
get {
if (runningProcess == null)
throw new InvalidOperationException("Cannot access StdErr of process, because it is not yet started!");
return null;//runningProcess.StandardError;
}
}
bool disposed = false;
public void Dispose()
{
if (!disposed) {
profilerRunner.Dispose();
disposed = true;
}
}
}
}

31
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs

@ -9,6 +9,7 @@ using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Dialogs; using ICSharpCode.Profiler.AddIn.Dialogs;
using ICSharpCode.Profiler.AddIn.OptionPanels; using ICSharpCode.Profiler.AddIn.OptionPanels;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
@ -17,7 +18,7 @@ namespace ICSharpCode.Profiler.AddIn
/// <summary> /// <summary>
/// Description of ProfilerRunner. /// Description of ProfilerRunner.
/// </summary> /// </summary>
public class ProfilerRunner public class ProfilerRunner : IDisposable
{ {
public event EventHandler RunFinished; public event EventHandler RunFinished;
ProfilerControlWindow controlWindow; ProfilerControlWindow controlWindow;
@ -80,8 +81,7 @@ namespace ICSharpCode.Profiler.AddIn
try { try {
using (AsynchronousWaitDialog dlg = AsynchronousWaitDialog.ShowWaitDialog(StringParser.Parse("${res:AddIns.Profiler.Messages.PreparingForAnalysis}"), true)) { using (AsynchronousWaitDialog dlg = AsynchronousWaitDialog.ShowWaitDialog(StringParser.Parse("${res:AddIns.Profiler.Messages.PreparingForAnalysis}"), true)) {
profiler.Dispose(); profiler.Dispose();
SD.MainThread.InvokeAsyncAndForget(() => { controlWindow.AllowClose = true; controlWindow.Close(); });
WorkbenchSingleton.SafeThreadAsyncCall(() => { controlWindow.AllowClose = true; this.controlWindow.Close(); });
if (database != null) { if (database != null) {
database.WriteTo(writer, progress => { database.WriteTo(writer, progress => {
dlg.Progress = progress; dlg.Progress = progress;
@ -101,12 +101,13 @@ namespace ICSharpCode.Profiler.AddIn
} }
} }
public void Run() public Process Run()
{ {
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront(); SD.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
this.controlWindow = new ProfilerControlWindow(this); controlWindow = new ProfilerControlWindow(this);
profiler.Start(); Process p = profiler.Start();
this.controlWindow.Show(); controlWindow.Show();
return p;
} }
public void Stop() public void Stop()
@ -148,7 +149,7 @@ namespace ICSharpCode.Profiler.AddIn
} }
#region MessageView Management #region MessageView Management
static MessageViewCategory profileCategory = null; static MessageViewCategory profileCategory;
static void EnsureProfileCategory() static void EnsureProfileCategory()
{ {
@ -175,5 +176,17 @@ namespace ICSharpCode.Profiler.AddIn
profileCategory.AppendLine(StringParser.Parse(text)); profileCategory.AppendLine(StringParser.Parse(text));
} }
#endregion #endregion
bool isDisposed = false;
public void Dispose()
{
if (!isDisposed) {
profiler.Dispose();
controlWindow.Close();
isDisposed = true;
}
}
} }
} }

110
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerTestRunner.cs

@ -1,110 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.Profiler.AddIn
{
public class ProfilerTestRunner : TestRunnerBase
{
ProfilerRunner runner;
UnitTestingOptions options = new UnitTestingOptions();
TestResultsMonitor testResultsMonitor;
public ProfilerTestRunner()
{
}
public override void Start(SelectedTests selectedTests)
{
ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests);
Start(startInfo, selectedTests);
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
{
NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, options);
testResultsMonitor = new TestResultsMonitor();
app.Results = testResultsMonitor.FileName;
return app.GetProcessStartInfo();
}
void Start(ProcessStartInfo startInfo, SelectedTests selectedTests)
{
LogCommandLine(startInfo);
string path = selectedTests.Project.GetSessionFileName();
LoggingService.Info("starting profiler...");
runner = new ProfilerRunner(startInfo, true, new UnitTestWriter(new ProfilingDataSQLiteWriter(path), GetUnitTestNames(selectedTests).ToArray()));
runner.RunFinished += delegate {
WorkbenchSingleton.SafeThreadCall(() => FileService.OpenFile(path));
AfterFinish(selectedTests, path);
};
testResultsMonitor.TestFinished += OnTestFinished;
testResultsMonitor.Start();
runner.Run();
}
IEnumerable<string> GetUnitTestNames(SelectedTests selectedTests)
{
IProjectContent content = ParserService.GetProjectContent(selectedTests.Project);
if (selectedTests.Class == null) {
var testClasses = content.Classes
.Where(c => c.Attributes.Any(a => a.AttributeType.FullyQualifiedName == "NUnit.Framework.TestFixtureAttribute"));
return testClasses
.SelectMany(c2 => c2.Methods)
.Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute"))
.Select(m2 => m2.FullyQualifiedName);
}
if (selectedTests.Member == null) {
return content.Classes.First(c => c.FullyQualifiedName == selectedTests.Class.DotNetName).Methods
.Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute"))
.Select(m2 => m2.FullyQualifiedName);
}
return new[] { selectedTests.Class.DotNetName + "." + selectedTests.Member.Name };
}
void AfterFinish(SelectedTests selectedTests, string path)
{
selectedTests.Project.AddSessionToProject(path);
OnAllTestsFinished(this, new EventArgs());
LoggingService.Info("shutting profiler down...");
}
public override void Stop()
{
if (this.runner != null && this.runner.Profiler.IsRunning) {
LoggingService.Info("stopping profiler...");
runner.Stop();
}
if (testResultsMonitor != null) {
testResultsMonitor.Stop();
testResultsMonitor.Read();
testResultsMonitor = null;
}
}
public override void Dispose()
{
Stop();
}
}
}

7
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ComparisonView.xaml.cs

@ -2,14 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace ICSharpCode.Profiler.AddIn.Views namespace ICSharpCode.Profiler.AddIn.Views
{ {

12
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerDisplayBinding.cs

@ -7,6 +7,7 @@ using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Profiler.AddIn.Views namespace ICSharpCode.Profiler.AddIn.Views
{ {
@ -24,7 +25,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
return true; // definition in .addin does extension-based filtering return true; // definition in .addin does extension-based filtering
} }
public ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(OpenedFile file) public IViewContent CreateContentForFile(OpenedFile file)
{ {
ProfilingDataSQLiteProvider provider; ProfilingDataSQLiteProvider provider;
try { try {
@ -46,12 +47,17 @@ namespace ICSharpCode.Profiler.AddIn.Views
return new WpfViewer(file, provider); return new WpfViewer(file, provider);
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return true; return true;
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public bool CanCreateContentForFile(FileName fileName)
{
return fileName.GetExtension().Equals(".sdps", StringComparison.OrdinalIgnoreCase);
}
public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return 1; return 1;
} }

30
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerView.xaml.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
} }
} }
this.dummyTab.Header = new Image { Source = PresentationResourceService.GetImage("Icons.16x16.NewDocumentIcon").Source, Height = 16, Width = 16 }; this.dummyTab.Header = new Image { Source = SD.ResourceService.GetImage("Icons.16x16.NewDocumentIcon").ImageSource, Height = 16, Width = 16 };
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, ExecuteSelectAll, CanExecuteSelectAll)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, ExecuteSelectAll, CanExecuteSelectAll));
@ -62,7 +62,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
void TimeLineRangeChanged(object sender, RangeEventArgs e) void TimeLineRangeChanged(object sender, RangeEventArgs e)
{ {
foreach (TabItem item in this.tabView.Items) { foreach (TabItem item in tabView.Items) {
if (item != null && item.Content != null) if (item != null && item.Content != null)
((QueryView)item.Content).SetRange(e.StartIndex, e.EndIndex); ((QueryView)item.Content).SetRange(e.StartIndex, e.EndIndex);
} }
@ -76,9 +76,9 @@ namespace ICSharpCode.Profiler.AddIn.Views
void DoSelectAll() void DoSelectAll()
{ {
if (this.timeLine.IsEnabled) { if (timeLine.IsEnabled) {
this.timeLine.SelectedStartIndex = 0; timeLine.SelectedStartIndex = 0;
this.timeLine.SelectedEndIndex = this.timeLine.Provider.DataSets.Count - 1; timeLine.SelectedEndIndex = timeLine.Provider.DataSets.Count - 1;
} }
} }
@ -90,7 +90,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
void CanDoSelectAll(CanExecuteRoutedEventArgs e) void CanDoSelectAll(CanExecuteRoutedEventArgs e)
{ {
e.CanExecute = this.timeLine.IsEnabled && this.timeLine.Provider.DataSets.Count > 0; e.CanExecute = timeLine.IsEnabled && timeLine.Provider.DataSets.Count > 0;
} }
void CloseButtonClick(object sender, RoutedEventArgs e) void CloseButtonClick(object sender, RoutedEventArgs e)
@ -104,16 +104,14 @@ namespace ICSharpCode.Profiler.AddIn.Views
void UpdateErrorList(IEnumerable<CompilerError> errors) void UpdateErrorList(IEnumerable<CompilerError> errors)
{ {
Dispatcher.Invoke( Dispatcher.Invoke(
(Action)( (Action)delegate {
() => { List<SDTask> tasks = errors.Select(error => new SDTask(null, error.ErrorText, error.Column, error.Line, (error.IsWarning) ? TaskType.Warning : TaskType.Error)).ToList();
var tasks = errors.Select(error => new Task(null, error.ErrorText, error.Column, error.Line, (error.IsWarning) ? TaskType.Warning : TaskType.Error)).ToList();
if (tasks.Count > 0) { if (tasks.Count > 0) {
WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); SD.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
TaskService.ClearExceptCommentTasks(); TaskService.ClearExceptCommentTasks();
TaskService.AddRange(tasks); TaskService.AddRange(tasks);
} }
} }
)
); );
} }
@ -159,8 +157,8 @@ namespace ICSharpCode.Profiler.AddIn.Views
provider.SetProperty("tabs", tabs.CreateSeparatedString()); provider.SetProperty("tabs", tabs.CreateSeparatedString());
List<string> queryHistory = new List<string>(); List<string> queryHistory = new List<string>();
for (int i = 2; i < this.mnuQueryHistory.Items.Count; i++) for (int i = 2; i < mnuQueryHistory.Items.Count; i++)
queryHistory.Add((this.mnuQueryHistory.Items[i] as MenuItem).Header.ToString() ?? string.Empty); queryHistory.Add((mnuQueryHistory.Items[i] as MenuItem).Header.ToString() ?? string.Empty);
provider.SetProperty("queryHistory", queryHistory.CreateSeparatedString()); provider.SetProperty("queryHistory", queryHistory.CreateSeparatedString());
} }
@ -172,7 +170,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
TabItem CreateTab(string title, string query, bool switchToNewTab) TabItem CreateTab(string title, string query, bool switchToNewTab)
{ {
TabItem newTab = new TabItem(); TabItem newTab = new TabItem();
Button closeButton = new Button { Style = this.Resources["CloseButton"] as Style }; Button closeButton = new Button { Style = Resources["CloseButton"] as Style };
TextBlock header = new TextBlock { Margin = new Thickness(0, 0, 4, 0), MaxWidth = 120, MinWidth = 40 }; TextBlock header = new TextBlock { Margin = new Thickness(0, 0, 4, 0), MaxWidth = 120, MinWidth = 40 };
newTab.Header = new StackPanel { Orientation = Orientation.Horizontal, Children = { header, closeButton } }; newTab.Header = new StackPanel { Orientation = Orientation.Horizontal, Children = { header, closeButton } };
@ -184,9 +182,9 @@ namespace ICSharpCode.Profiler.AddIn.Views
newTab.Content = view = new QueryView(); newTab.Content = view = new QueryView();
view.Provider = this.provider; view.Provider = provider;
view.Reporter = new ErrorReporter(UpdateErrorList); view.Reporter = new ErrorReporter(UpdateErrorList);
view.SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex); view.SetRange(timeLine.SelectedStartIndex, timeLine.SelectedEndIndex);
view.CurrentQuery = query; view.CurrentQuery = query;
view.ShowQueryItems = true; view.ShowQueryItems = true;

14
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/WpfViewer.cs

@ -1,19 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.Core;
using System; using System;
using System.IO; using System.IO;
using System.Windows.Forms; using ICSharpCode.Core;
using System.Windows.Forms.Integration;
using ICSharpCode.Core.Presentation;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Profiler.AddIn.Views namespace ICSharpCode.Profiler.AddIn.Views
{ {
using ICSharpCode.Profiler.Controller;
/// <summary> /// <summary>
/// Description of the view content /// Description of the view content
@ -66,7 +62,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
{ {
if (FileUtility.IsEqualFileName(e.FileName, file.FileName) || if (FileUtility.IsEqualFileName(e.FileName, file.FileName) ||
FileUtility.IsBaseDirectory(e.FileName, file.FileName)) FileUtility.IsBaseDirectory(e.FileName, file.FileName))
this.WorkbenchWindow.CloseWindow(true); WorkbenchWindow.CloseWindow(true);
} }
/// <summary> /// <summary>
@ -74,8 +70,8 @@ namespace ICSharpCode.Profiler.AddIn.Views
/// </summary> /// </summary>
public override void Dispose() public override void Dispose()
{ {
this.dataView.SaveUserState(); dataView.SaveUserState();
this.provider.Close(); provider.Close();
FileService.FileRemoving -= FileServiceFileRemoving; FileService.FileRemoving -= FileServiceFileRemoving;
base.Dispose(); base.Dispose();

34
src/AddIns/Analysis/Profiler/Frontend/Controls/CallTreeNodeViewModel.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.Profiler.Controls
protected void OnPropertyChanged(string name) protected void OnPropertyChanged(string name)
{ {
if (this.PropertyChanged != null) if (PropertyChanged != null)
{ {
PropertyChanged(this, new PropertyChangedEventArgs(name)); PropertyChanged(this, new PropertyChangedEventArgs(name));
} }
@ -61,7 +61,7 @@ namespace ICSharpCode.Profiler.Controls
void BringIntoView(CallTreeNodeViewModel item) void BringIntoView(CallTreeNodeViewModel item)
{ {
if (this.parent != null) { if (parent != null) {
parent.BringIntoView(item); parent.BringIntoView(item);
return; return;
} }
@ -89,10 +89,10 @@ namespace ICSharpCode.Profiler.Controls
public virtual double TimePercentageOfParent public virtual double TimePercentageOfParent
{ {
get { get {
if (this.parent == null) if (parent == null)
return 1; return 1;
else else
return (double)this.node.CpuCyclesSpent / (double)this.parent.node.CpuCyclesSpent; return (double)node.CpuCyclesSpent / (double)parent.node.CpuCyclesSpent;
} }
} }
@ -168,7 +168,7 @@ namespace ICSharpCode.Profiler.Controls
public ReadOnlyCollection<string> Parameters public ReadOnlyCollection<string> Parameters
{ {
get { get {
return new ReadOnlyCollection<string>(this.node.Parameters); return new ReadOnlyCollection<string>(node.Parameters);
} }
} }
@ -196,15 +196,15 @@ namespace ICSharpCode.Profiler.Controls
public virtual ReadOnlyCollection<CallTreeNodeViewModel> Children { public virtual ReadOnlyCollection<CallTreeNodeViewModel> Children {
get { get {
lock (this) { lock (this) {
if (this.children == null) { if (children == null) {
this.children = this.node.Children children = node.Children
.Select(c => new CallTreeNodeViewModel(c, this)) .Select(c => new CallTreeNodeViewModel(c, this))
.ToList() .ToList()
.AsReadOnly(); .AsReadOnly();
} }
return this.children; return children;
} }
} }
} }
@ -212,14 +212,14 @@ namespace ICSharpCode.Profiler.Controls
public virtual string Name public virtual string Name
{ {
get { get {
return this.node.Name ?? string.Empty; return node.Name ?? string.Empty;
} }
} }
public virtual string FullyQualifiedClassName public virtual string FullyQualifiedClassName
{ {
get { get {
string nodeName = this.node.Name; string nodeName = node.Name;
if (string.IsNullOrEmpty(nodeName)) if (string.IsNullOrEmpty(nodeName))
return null; return null;
if (!nodeName.Contains(".")) if (!nodeName.Contains("."))
@ -234,7 +234,7 @@ namespace ICSharpCode.Profiler.Controls
public virtual string MethodName public virtual string MethodName
{ {
get { get {
string nodeName = this.node.Name; string nodeName = node.Name;
if (string.IsNullOrEmpty(nodeName)) if (string.IsNullOrEmpty(nodeName))
return null; return null;
if (!nodeName.Contains(".")) if (!nodeName.Contains("."))
@ -249,9 +249,9 @@ namespace ICSharpCode.Profiler.Controls
public virtual string ShortName public virtual string ShortName
{ {
get { get {
string className = this.FullyQualifiedClassName; string className = FullyQualifiedClassName;
if (className == null) if (className == null)
return this.Name; return Name;
int index = className.LastIndexOf('.'); int index = className.LastIndexOf('.');
return className.Substring(index + 1) + "." + MethodName; return className.Substring(index + 1) + "." + MethodName;
} }
@ -265,7 +265,7 @@ namespace ICSharpCode.Profiler.Controls
if (isExpanded != value) { if (isExpanded != value) {
isExpanded = value; isExpanded = value;
OnPropertyChanged("IsExpanded"); OnPropertyChanged("IsExpanded");
this.IsExpandedChanged(new NodeEventArgs<CallTreeNodeViewModel>(this)); IsExpandedChanged(new NodeEventArgs<CallTreeNodeViewModel>(this));
if (isExpanded) { if (isExpanded) {
DeselectChildren(children); DeselectChildren(children);
@ -285,7 +285,7 @@ namespace ICSharpCode.Profiler.Controls
void IsExpandedChanged(NodeEventArgs<CallTreeNodeViewModel> e) void IsExpandedChanged(NodeEventArgs<CallTreeNodeViewModel> e)
{ {
this.visibleElementCount = 1 + (IsExpanded ? Children.Sum(c => c.VisibleElementCount) : 0); visibleElementCount = 1 + (IsExpanded ? Children.Sum(c => c.VisibleElementCount) : 0);
OnVisibleChildExpandedChanged(e); OnVisibleChildExpandedChanged(e);
if (Parent != null && Parent.IsExpanded) { if (Parent != null && Parent.IsExpanded) {
@ -318,7 +318,7 @@ namespace ICSharpCode.Profiler.Controls
//this.IsSelectedChanged(this); //this.IsSelectedChanged(this);
if (isSelected) { if (isSelected) {
CallTreeNodeViewModel node = this.Parent; CallTreeNodeViewModel node = Parent;
while (node != null) { while (node != null) {
node.IsExpanded = true; node.IsExpanded = true;
node = node.Parent; node = node.Parent;
@ -394,7 +394,7 @@ namespace ICSharpCode.Profiler.Controls
public virtual int VisibleElementCount public virtual int VisibleElementCount
{ {
get { get {
return this.visibleElementCount; return visibleElementCount;
} }
} }

7
src/AddIns/Analysis/Profiler/Frontend/Controls/CompareView.xaml.cs

@ -2,14 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls
{ {

5
src/AddIns/Analysis/Profiler/Frontend/Controls/CustomGridView.cs

@ -3,7 +3,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Markup; using System.Windows.Markup;
@ -41,7 +40,7 @@ namespace ICSharpCode.Profiler.Controls
GridViewColumn primaryColumn; GridViewColumn primaryColumn;
private GridViewColumn PrimaryColumn { GridViewColumn PrimaryColumn {
get { return primaryColumn; } get { return primaryColumn; }
set { set {
if (primaryColumn != value) { if (primaryColumn != value) {
@ -153,7 +152,7 @@ namespace ICSharpCode.Profiler.Controls
} }
} }
protected override System.Windows.Media.Visual GetVisualChild(int index) protected override Visual GetVisualChild(int index)
{ {
return uiElements[index]; return uiElements[index];
} }

48
src/AddIns/Analysis/Profiler/Frontend/Controls/ExtendedTimeLineControl.xaml.cs

@ -3,18 +3,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.Profiler.Controller.Data; using ICSharpCode.Profiler.Controller.Data;
@ -36,26 +26,26 @@ namespace ICSharpCode.Profiler.Controls
public ProfilingDataProvider Provider public ProfilingDataProvider Provider
{ {
get { return this.provider; } get { return provider; }
set { set {
this.provider = value; provider = value;
this.perfCounterList.ItemsSource = this.provider.GetPerformanceCounters(); perfCounterList.ItemsSource = provider.GetPerformanceCounters();
this.perfCounterList.SelectedIndex = 0; perfCounterList.SelectedIndex = 0;
this.timeLine.Provider = provider; timeLine.Provider = provider;
Update(); Update();
} }
} }
public int SelectedStartIndex { public int SelectedStartIndex {
get { return this.timeLine.SelectedStartIndex; } get { return timeLine.SelectedStartIndex; }
set { this.timeLine.SelectedStartIndex = value; } set { timeLine.SelectedStartIndex = value; }
} }
public int SelectedEndIndex { public int SelectedEndIndex {
get { return this.timeLine.SelectedEndIndex; } get { return timeLine.SelectedEndIndex; }
set { this.timeLine.SelectedEndIndex = value; } set { timeLine.SelectedEndIndex = value; }
} }
public event EventHandler<RangeEventArgs> RangeChanged; public event EventHandler<RangeEventArgs> RangeChanged;
@ -68,29 +58,29 @@ namespace ICSharpCode.Profiler.Controls
void Update() void Update()
{ {
this.timeLine.ValuesList.Clear(); timeLine.ValuesList.Clear();
var selectedPerformanceCounter = this.perfCounterList.SelectedItem as PerformanceCounterDescriptor; var selectedPerformanceCounter = perfCounterList.SelectedItem as PerformanceCounterDescriptor;
if (selectedPerformanceCounter == null) if (selectedPerformanceCounter == null)
return; return;
List<TimeLineSegment> segments = new List<TimeLineSegment>(); List<TimeLineSegment> segments = new List<TimeLineSegment>();
var values = this.provider.GetPerformanceCounterValues(this.perfCounterList.SelectedIndex); var values = provider.GetPerformanceCounterValues(perfCounterList.SelectedIndex);
var markers = this.provider.DataSets.Select(item => item.IsFirst).ToArray(); var markers = provider.DataSets.Select(item => item.IsFirst).ToArray();
this.timeLine.MaxValue = selectedPerformanceCounter.MaxValue ?? (values.Any() ? values.Max() : 0); timeLine.MaxValue = selectedPerformanceCounter.MaxValue ?? (values.Any() ? values.Max() : 0);
this.maxLabel.Text = (selectedPerformanceCounter.MaxValue ?? (values.Any() ? values.Max() : 0)).ToString("0"); maxLabel.Text = (selectedPerformanceCounter.MaxValue ?? (values.Any() ? values.Max() : 0)).ToString("0");
this.minLabel.Text = (selectedPerformanceCounter.MinValue ?? (values.Any() ? values.Min() : 0)).ToString("0"); minLabel.Text = (selectedPerformanceCounter.MinValue ?? (values.Any() ? values.Min() : 0)).ToString("0");
this.unitLabel.Text = this.timeLine.Unit = selectedPerformanceCounter.Unit; unitLabel.Text = timeLine.Unit = selectedPerformanceCounter.Unit;
this.timeLine.Format = selectedPerformanceCounter.Format; timeLine.Format = selectedPerformanceCounter.Format;
for (int i = 0; i < values.Length; i++) for (int i = 0; i < values.Length; i++)
segments.Add(new TimeLineSegment() { Value = values[i], DisplayMarker = markers[i], Events = provider.GetEventDataEntries(i) }); segments.Add(new TimeLineSegment() { Value = values[i], DisplayMarker = markers[i], Events = provider.GetEventDataEntries(i) });
this.timeLine.ValuesList.AddRange(segments); timeLine.ValuesList.AddRange(segments);
} }
void PerfCounterListSelectionChanged(object sender, SelectionChangedEventArgs e) void PerfCounterListSelectionChanged(object sender, SelectionChangedEventArgs e)

32
src/AddIns/Analysis/Profiler/Frontend/Controls/HSVColor.cs

@ -13,14 +13,14 @@ namespace ICSharpCode.Profiler.Controls
public float Hue { public float Hue {
get { return hue; } get { return hue; }
set { this.hue = value; } set { hue = value; }
} }
float saturation; float saturation;
public float Saturation { public float Saturation {
get { return saturation; } get { return saturation; }
set { this.saturation = value; } set { saturation = value; }
} }
float value; float value;
@ -74,34 +74,34 @@ namespace ICSharpCode.Profiler.Controls
public Color ToColor() public Color ToColor()
{ {
if (!InInterval(this.hue, 0, 360)) if (!InInterval(hue, 0, 360))
throw new ArgumentException("Hue is not between 0 and 360 degrees!"); throw new ArgumentException("Hue is not between 0 and 360 degrees!");
if (!InInterval(this.saturation, 0, 1)) if (!InInterval(saturation, 0, 1))
throw new ArgumentException("Saturation is not between 0 and 1!"); throw new ArgumentException("Saturation is not between 0 and 1!");
if (!InInterval(this.value, 0, 1)) if (!InInterval(value, 0, 1))
throw new ArgumentException("Value is not between 0 and 1!"); throw new ArgumentException("Value is not between 0 and 1!");
int hi = (int)Math.Floor(this.hue / 60.0f); int hi = (int)Math.Floor(hue / 60.0f);
float f = this.hue / 60.0f - hi; float f = hue / 60.0f - hi;
float p = this.value * (1 - this.saturation); float p = value * (1 - saturation);
float q = this.value * (1 - this.saturation * f); float q = value * (1 - saturation * f);
float t = this.value * (1 - this.saturation * (1 - f)); float t = value * (1 - saturation * (1 - f));
switch (hi) switch (hi)
{ {
case 0: case 0:
return Color.FromRgb((byte)(this.value * 255.0f), (byte)(t * 255.0f), (byte)(p * 255.0f)); return Color.FromRgb((byte)(value * 255.0f), (byte)(t * 255.0f), (byte)(p * 255.0f));
case 1: case 1:
return Color.FromRgb((byte)(q * 255.0f), (byte)(this.value * 255.0f), (byte)(p * 255.0f)); return Color.FromRgb((byte)(q * 255.0f), (byte)(value * 255.0f), (byte)(p * 255.0f));
case 2: case 2:
return Color.FromRgb((byte)(p * 255.0f), (byte)(this.value * 255.0f), (byte)(t * 255.0f)); return Color.FromRgb((byte)(p * 255.0f), (byte)(value * 255.0f), (byte)(t * 255.0f));
case 3: case 3:
return Color.FromRgb((byte)(p * 255.0f), (byte)(q * 255.0f), (byte)(this.value * 255.0f)); return Color.FromRgb((byte)(p * 255.0f), (byte)(q * 255.0f), (byte)(value * 255.0f));
case 4: case 4:
return Color.FromRgb((byte)(t * 255.0f), (byte)(p * 255.0f), (byte)(this.value * 255.0f)); return Color.FromRgb((byte)(t * 255.0f), (byte)(p * 255.0f), (byte)(value * 255.0f));
case 5: case 5:
return Color.FromRgb((byte)(this.value * 255.0f), (byte)(p * 255.0f), (byte)(q * 255.0f)); return Color.FromRgb((byte)(value * 255.0f), (byte)(p * 255.0f), (byte)(q * 255.0f));
} }
return Colors.Black; return Colors.Black;

1
src/AddIns/Analysis/Profiler/Frontend/Controls/HierarchyList.cs

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;

9
src/AddIns/Analysis/Profiler/Frontend/Controls/PercentBar.cs

@ -2,12 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls
@ -18,8 +13,8 @@ namespace ICSharpCode.Profiler.Controls
{ {
base.OnRender(drawingContext); base.OnRender(drawingContext);
if (this.RenderSize.Height > 0 && this.RenderSize.Width > 0) { if (RenderSize.Height > 0 && RenderSize.Width > 0) {
drawingContext.DrawRectangle(new LinearGradientBrush(Colors.Red, Colors.Orange, 0), new Pen(Brushes.Black, 1), new Rect(new Point(0, 2), new Size(this.RenderSize.Width * this.Value, this.RenderSize.Height - 4))); drawingContext.DrawRectangle(new LinearGradientBrush(Colors.Red, Colors.Orange, 0), new Pen(Brushes.Black, 1), new Rect(new Point(0, 2), new Size(RenderSize.Width * Value, RenderSize.Height - 4)));
} }
} }

8
src/AddIns/Analysis/Profiler/Frontend/Controls/PiePiece.cs

@ -2,11 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows; using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls
{ {
@ -99,7 +97,7 @@ namespace ICSharpCode.Profiler.Controls
/// <summary> /// <summary>
/// Draws the pie piece /// Draws the pie piece
/// </summary> /// </summary>
private void DrawGeometry(StreamGeometryContext context) void DrawGeometry(StreamGeometryContext context)
{ {
double centreX = Radius; double centreX = Radius;
double centreY = Radius; double centreY = Radius;

5
src/AddIns/Analysis/Profiler/Frontend/Controls/Profiler.Controls.csproj

@ -7,7 +7,7 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Profiler.Controls</RootNamespace> <RootNamespace>ICSharpCode.Profiler.Controls</RootNamespace>
<AssemblyName>ICSharpCode.Profiler.Controls</AssemblyName> <AssemblyName>ICSharpCode.Profiler.Controls</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Dokumente und Einstellungen\HP\Anwendungsdaten\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> <SourceAnalysisOverrideSettingsFile>C:\Dokumente und Einstellungen\HP\Anwendungsdaten\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -34,7 +34,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

58
src/AddIns/Analysis/Profiler/Frontend/Controls/QueryView.xaml.cs

@ -1,7 +1,6 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.Profiler.Controller.Data;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -12,6 +11,7 @@ using System.Windows.Controls;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.Profiler.Controller; using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.Profiler.Controller.Queries; using ICSharpCode.Profiler.Controller.Queries;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls
@ -40,7 +40,7 @@ namespace ICSharpCode.Profiler.Controls
get { return isQueryModifiable; } get { return isQueryModifiable; }
set { set {
isQueryModifiable = value; isQueryModifiable = value;
this.txtQuery.IsReadOnly = !isQueryModifiable; txtQuery.IsReadOnly = !isQueryModifiable;
} }
} }
@ -59,9 +59,9 @@ namespace ICSharpCode.Profiler.Controls
public IEnumerable<CallTreeNodeViewModel> SelectedItems { public IEnumerable<CallTreeNodeViewModel> SelectedItems {
get { get {
if (this.list == null) if (list == null)
return new List<CallTreeNodeViewModel>().AsEnumerable(); return new List<CallTreeNodeViewModel>().AsEnumerable();
return from i in this.list where i.IsSelected select i; return from i in list where i.IsSelected select i;
} }
} }
@ -87,9 +87,9 @@ namespace ICSharpCode.Profiler.Controls
if (!string.IsNullOrEmpty(txtSearch.Text) && list.Count > 0) { if (!string.IsNullOrEmpty(txtSearch.Text) && list.Count > 0) {
searchTask.Cancel(); searchTask.Cancel();
string text = txtSearch.Text; string text = txtSearch.Text;
int start = this.RangeStart; int start = RangeStart;
int end = this.RangeEnd; int end = RangeEnd;
var provider = this.Provider; var provider = Provider;
AdornerLayer layer = AdornerLayer.GetAdornerLayer(this); AdornerLayer layer = AdornerLayer.GetAdornerLayer(this);
OverlayAdorner ad = new OverlayAdorner(this); OverlayAdorner ad = new OverlayAdorner(this);
@ -199,10 +199,10 @@ namespace ICSharpCode.Profiler.Controls
{ {
if (e.NewSize.Width > 0 && e.PreviousSize.Width > 0) { if (e.NewSize.Width > 0 && e.PreviousSize.Width > 0) {
double adjustedNameColumnWidth = nameColumn.Width + e.NewSize.Width - e.PreviousSize.Width; double adjustedNameColumnWidth = nameColumn.Width + e.NewSize.Width - e.PreviousSize.Width;
double matchingNameColumnWidth = e.NewSize.Width - this.callCountColumn.Width double matchingNameColumnWidth = e.NewSize.Width - callCountColumn.Width
- this.percentColumn.Width - this.timeSpentColumn.Width - percentColumn.Width - timeSpentColumn.Width
- this.timeSpentSelfColumn.Width - this.timeSpentPerCallColumn.Width - timeSpentSelfColumn.Width - timeSpentPerCallColumn.Width
- this.timeSpentSelfPerCallColumn.Width - 25; - timeSpentSelfPerCallColumn.Width - 25;
// always keep name column at least 75 pixels wide // always keep name column at least 75 pixels wide
if (matchingNameColumnWidth < 75) if (matchingNameColumnWidth < 75)
@ -222,25 +222,25 @@ namespace ICSharpCode.Profiler.Controls
public void SetRange(int start, int end) public void SetRange(int start, int end)
{ {
if (this.Provider == null) if (Provider == null)
return; return;
this.RangeStart = start; RangeStart = start;
this.RangeEnd = end; RangeEnd = end;
this.Invalidate(); Invalidate();
this.InvalidateArrange(); InvalidateArrange();
} }
public void Invalidate() public void Invalidate()
{ {
this.isDirty = true; isDirty = true;
if (this.IsVisible) if (IsVisible)
ExecuteQuery(); ExecuteQuery();
} }
void ExecuteQuery() void ExecuteQuery()
{ {
if (!this.isDirty || this.Provider == null) if (!isDirty || Provider == null)
return; return;
if (Provider.DataSets.Count == 0) if (Provider.DataSets.Count == 0)
@ -254,7 +254,7 @@ namespace ICSharpCode.Profiler.Controls
LoadData(); LoadData();
watch.Stop(); watch.Stop();
Debug.Print("update finished in {0}ms", watch.ElapsedMilliseconds); Debug.Print("update finished in {0}ms", watch.ElapsedMilliseconds);
this.isDirty = false; isDirty = false;
} }
void LoadData() void LoadData()
@ -266,7 +266,7 @@ namespace ICSharpCode.Profiler.Controls
layer.Add(ad); layer.Add(ad);
int rangeStart = RangeStart; int rangeStart = RangeStart;
int rangeEnd = RangeEnd; int rangeEnd = RangeEnd;
string query = this.CurrentQuery; string query = CurrentQuery;
ProfilingDataProvider provider = Provider; ProfilingDataProvider provider = Provider;
QueryCompiler compiler = new QueryCompiler(Reporter, query); QueryCompiler compiler = new QueryCompiler(Reporter, query);
@ -308,22 +308,22 @@ namespace ICSharpCode.Profiler.Controls
foreach (var item in list) { foreach (var item in list) {
var currentItem = item; var currentItem = item;
currentItem.RequestBringIntoView += (sender, e) => this.treeView.ScrollIntoView(e.Node); currentItem.RequestBringIntoView += (sender, e) => treeView.ScrollIntoView(e.Node);
} }
} }
} }
public string CurrentQuery { public string CurrentQuery {
get { return this.txtQuery.Text; } get { return txtQuery.Text; }
set { set {
if (IsQueryModifiable) if (IsQueryModifiable)
this.txtQuery.Text = value; txtQuery.Text = value;
} }
} }
void txtQueryTextChanged(object sender, TextChangedEventArgs e) void txtQueryTextChanged(object sender, TextChangedEventArgs e)
{ {
this.CurrentQuery = this.txtQuery.Text; CurrentQuery = txtQuery.Text;
} }
void txtQueryKeyDown(object sender, KeyEventArgs e) void txtQueryKeyDown(object sender, KeyEventArgs e)
@ -335,12 +335,12 @@ namespace ICSharpCode.Profiler.Controls
void btnExecuteQueryClick(object sender, RoutedEventArgs e) void btnExecuteQueryClick(object sender, RoutedEventArgs e)
{ {
OnCurrentQueryChanged(EventArgs.Empty); OnCurrentQueryChanged(EventArgs.Empty);
this.Invalidate(); Invalidate();
} }
void BtnExpandHotPathSubtreeClick(object sender, RoutedEventArgs e) void BtnExpandHotPathSubtreeClick(object sender, RoutedEventArgs e)
{ {
foreach (CallTreeNodeViewModel node in this.SelectedItems.ToArray()) { foreach (CallTreeNodeViewModel node in SelectedItems.ToArray()) {
ExpandHotPathItems(node, node); ExpandHotPathItems(node, node);
} }
} }
@ -356,8 +356,8 @@ namespace ICSharpCode.Profiler.Controls
} }
public ContextMenu TreeViewContextMenu { public ContextMenu TreeViewContextMenu {
get { return this.treeView.ContextMenu; } get { return treeView.ContextMenu; }
set { this.treeView.ContextMenu = this.ringDiagram.ContextMenu = value; } set { treeView.ContextMenu = ringDiagram.ContextMenu = value; }
} }
} }
} }

3
src/AddIns/Analysis/Profiler/Frontend/Controls/RangeEventArgs.cs

@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Windows;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls
{ {
@ -28,7 +27,7 @@ namespace ICSharpCode.Profiler.Controls
public int RangeLength public int RangeLength
{ {
get { return Math.Abs(this.endIndex - this.startIndex); } get { return Math.Abs(endIndex - startIndex); }
} }
} }
} }

35
src/AddIns/Analysis/Profiler/Frontend/Controls/RingDiagramControl.cs

@ -10,7 +10,6 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Windows.Threading;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls
{ {
@ -40,7 +39,7 @@ namespace ICSharpCode.Profiler.Controls
{ {
base.OnPropertyChanged(e); base.OnPropertyChanged(e);
if (e.Property == SelectedRootProperty) if (e.Property == SelectedRootProperty)
Update(this.SelectedRoot); Update(SelectedRoot);
} }
public RingDiagramControl() public RingDiagramControl()
@ -54,17 +53,17 @@ namespace ICSharpCode.Profiler.Controls
{ {
Debug.WriteLine("RingDiagram.Update: new root = " + item); Debug.WriteLine("RingDiagram.Update: new root = " + item);
this.task.Cancel(); task.Cancel();
Debug.WriteLine("hierarchyStack count: " + this.hierarchyStack.Count); Debug.WriteLine("hierarchyStack count: " + hierarchyStack.Count);
while (this.hierarchyStack.Count > 0 && !hierarchyStack.Peek().IsAncestorOf(item)) { while (hierarchyStack.Count > 0 && !hierarchyStack.Peek().IsAncestorOf(item)) {
this.hierarchyStack.Pop(); hierarchyStack.Pop();
} }
Debug.Assert(hierarchyStack.Count == 0 || hierarchyStack.Peek().IsAncestorOf(item)); Debug.Assert(hierarchyStack.Count == 0 || hierarchyStack.Peek().IsAncestorOf(item));
this.Children.Clear(); Children.Clear();
if (item == null) if (item == null)
return; return;
@ -83,28 +82,28 @@ namespace ICSharpCode.Profiler.Controls
ell.MouseLeftButtonDown += (sender, e) => ell.MouseLeftButtonDown += (sender, e) =>
{ {
if (this.hierarchyStack.Count > 1 && this.hierarchyStack.Peek().Level > 1) { if (hierarchyStack.Count > 1 && hierarchyStack.Peek().Level > 1) {
var oldItem = this.hierarchyStack.Pop(); var oldItem = hierarchyStack.Pop();
this.SelectedRoot = this.hierarchyStack.Peek(); SelectedRoot = hierarchyStack.Peek();
this.SelectedRoot.IsSelected = true; SelectedRoot.IsSelected = true;
this.SelectedRoot.IsExpanded = true; SelectedRoot.IsExpanded = true;
oldItem.IsSelected = false; oldItem.IsSelected = false;
} }
}; };
if (hierarchyStack.Count == 0 || hierarchyStack.Peek() != item) if (hierarchyStack.Count == 0 || hierarchyStack.Peek() != item)
this.hierarchyStack.Push(item); hierarchyStack.Push(item);
List<PiePieceDescriptor> pieces = new List<PiePieceDescriptor>(); List<PiePieceDescriptor> pieces = new List<PiePieceDescriptor>();
this.task.Execute( task.Execute(
() => { () => {
if (item.CpuCyclesSpent > 0) if (item.CpuCyclesSpent > 0)
CreateTree(pieces, item, 0, item.CpuCyclesSpent, 0); CreateTree(pieces, item, 0, item.CpuCyclesSpent, 0);
}, },
() => { () => {
this.Children.Add(ell); Children.Add(ell);
this.Children.AddRange(pieces.Select(p => CreatePiePiece(p.Radius, p.WedgeAngle, p.RotationAngle, p.Level, p.Node))); Children.AddRange(pieces.Select(p => CreatePiePiece(p.Radius, p.WedgeAngle, p.RotationAngle, p.Level, p.Node)));
item.BringIntoView(); item.BringIntoView();
}, },
delegate { } delegate { }
@ -165,8 +164,8 @@ namespace ICSharpCode.Profiler.Controls
delegate(object sender, MouseButtonEventArgs e) { delegate(object sender, MouseButtonEventArgs e) {
node.IsExpanded = true; node.IsExpanded = true;
node.IsSelected = true; // expand the path to the node so that the treeview can select it node.IsSelected = true; // expand the path to the node so that the treeview can select it
var oldNode = this.SelectedRoot; var oldNode = SelectedRoot;
this.SelectedRoot = node; SelectedRoot = node;
oldNode.IsSelected = false; oldNode.IsSelected = false;
} }
); );

14
src/AddIns/Analysis/Profiler/Frontend/Controls/SingleTask.cs

@ -48,9 +48,9 @@ namespace ICSharpCode.Profiler.Controls
{ {
dispatcher.VerifyAccess(); dispatcher.VerifyAccess();
if (this.currentTask != null) { if (currentTask != null) {
this.currentTask.Cancel(); currentTask.Cancel();
this.currentTask = null; currentTask = null;
} }
} }
@ -59,10 +59,10 @@ namespace ICSharpCode.Profiler.Controls
if (backgroundAction == null) if (backgroundAction == null)
throw new ArgumentNullException("backgroundAction"); throw new ArgumentNullException("backgroundAction");
this.Cancel(); Cancel();
Task task = Task.Start(backgroundAction); Task task = Task.Start(backgroundAction);
this.currentTask = task; currentTask = task;
currentTask.RunWhenComplete( currentTask.RunWhenComplete(
dispatcher, dispatcher,
() => { () => {
@ -70,8 +70,8 @@ namespace ICSharpCode.Profiler.Controls
// want to raise completionAction if the task // want to raise completionAction if the task
// was successfully completed but another task // was successfully completed but another task
// was started before we received the completion callback. // was started before we received the completion callback.
if (this.currentTask == task) { if (currentTask == task) {
this.currentTask = null; currentTask = null;
if (completionAction != null) if (completionAction != null)
completionAction(); completionAction();
} else { } else {

2
src/AddIns/Analysis/Profiler/Frontend/Controls/Task.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.Profiler.Controls
bool isComplete; bool isComplete;
Action onCompleteActions; Action onCompleteActions;
private Task(Action action) Task(Action action)
{ {
this.action = action; this.action = action;
} }

97
src/AddIns/Analysis/Profiler/Frontend/Controls/TimeLineControl.cs

@ -2,11 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Documents; using System.Windows.Documents;
@ -55,8 +54,8 @@ namespace ICSharpCode.Profiler.Controls
get { return selectedEndIndex; } get { return selectedEndIndex; }
set { set {
selectedEndIndex = value; selectedEndIndex = value;
this.InvalidateMeasure(); InvalidateMeasure();
this.InvalidateVisual(); InvalidateVisual();
OnRangeChanged(new RangeEventArgs(selectedStartIndex, selectedEndIndex)); OnRangeChanged(new RangeEventArgs(selectedStartIndex, selectedEndIndex));
} }
} }
@ -66,8 +65,8 @@ namespace ICSharpCode.Profiler.Controls
get { return selectedStartIndex; } get { return selectedStartIndex; }
set { set {
selectedStartIndex = value; selectedStartIndex = value;
this.InvalidateMeasure(); InvalidateMeasure();
this.InvalidateVisual(); InvalidateVisual();
OnRangeChanged(new RangeEventArgs(selectedStartIndex, selectedEndIndex)); OnRangeChanged(new RangeEventArgs(selectedStartIndex, selectedEndIndex));
} }
} }
@ -85,9 +84,9 @@ namespace ICSharpCode.Profiler.Controls
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
this.pieceWidth = 25; pieceWidth = 25;
Size calculatedSize = base.MeasureOverride(availableSize); Size calculatedSize = base.MeasureOverride(availableSize);
return new Size(Math.Max(this.pieceWidth * this.valuesList.Count + 1, calculatedSize.Width), calculatedSize.Height + 10); return new Size(Math.Max(pieceWidth * valuesList.Count + 1, calculatedSize.Width), calculatedSize.Height + 10);
} }
const int offset = 0; const int offset = 0;
@ -97,26 +96,26 @@ namespace ICSharpCode.Profiler.Controls
{ {
base.OnRender(drawingContext); base.OnRender(drawingContext);
if (this.valuesList.Count == 0) if (valuesList.Count == 0)
return; return;
double oldX = offsetFromTop, oldY = this.RenderSize.Height; double oldX = offsetFromTop, oldY = RenderSize.Height;
StreamGeometry geometry = new StreamGeometry(); StreamGeometry geometry = new StreamGeometry();
using (StreamGeometryContext ctx = geometry.Open()) using (StreamGeometryContext ctx = geometry.Open())
{ {
ctx.BeginFigure(new Point(0, this.RenderSize.Height), true, true); ctx.BeginFigure(new Point(0, RenderSize.Height), true, true);
List<Point> points = new List<Point>(); List<Point> points = new List<Point>();
double maxHeight = this.RenderSize.Height - offsetFromTop; double maxHeight = RenderSize.Height - offsetFromTop;
for (int i = 0; i < this.valuesList.Count; i++) for (int i = 0; i < valuesList.Count; i++)
{ {
double x = this.pieceWidth / 2.0 + this.pieceWidth * i; double x = pieceWidth / 2.0 + pieceWidth * i;
// TODO : support MinValues other than 0 // TODO : support MinValues other than 0
double y = offsetFromTop + (maxHeight - maxHeight * (this.valuesList[i].Value / this.MaxValue)); double y = offsetFromTop + (maxHeight - maxHeight * (valuesList[i].Value / MaxValue));
points.Add(new Point(x, y)); points.Add(new Point(x, y));
@ -124,7 +123,7 @@ namespace ICSharpCode.Profiler.Controls
oldY = y; oldY = y;
} }
points.Add(new Point(oldX, offsetFromTop + this.RenderSize.Height)); points.Add(new Point(oldX, offsetFromTop + RenderSize.Height));
ctx.PolyLineTo(points, true, true); ctx.PolyLineTo(points, true, true);
} }
@ -133,7 +132,7 @@ namespace ICSharpCode.Profiler.Controls
Brush b = new LinearGradientBrush(Colors.Red, Colors.Orange, 90); Brush b = new LinearGradientBrush(Colors.Red, Colors.Orange, 90);
drawingContext.DrawRectangle(Brushes.White, new Pen(Brushes.White, 1), new Rect(new Point(0, 0), this.RenderSize)); drawingContext.DrawRectangle(Brushes.White, new Pen(Brushes.White, 1), new Rect(new Point(0, 0), RenderSize));
var p = new Pen(Brushes.DarkRed, 2); var p = new Pen(Brushes.DarkRed, 2);
@ -141,10 +140,10 @@ namespace ICSharpCode.Profiler.Controls
DateTime time = new DateTime(1,1,1,0,0,0,0); DateTime time = new DateTime(1,1,1,0,0,0,0);
for (int i = 0; i < this.valuesList.Count; i++) { for (int i = 0; i < valuesList.Count; i++) {
if (this.valuesList[i].DisplayMarker) if (valuesList[i].DisplayMarker)
drawingContext.DrawLine(p, new Point(pieceWidth * i, offsetFromTop), drawingContext.DrawLine(p, new Point(pieceWidth * i, offsetFromTop),
new Point(pieceWidth * i, this.RenderSize.Height)); new Point(pieceWidth * i, RenderSize.Height));
if (i % 3 == 0) { if (i % 3 == 0) {
FormattedText textFormat = new FormattedText( FormattedText textFormat = new FormattedText(
@ -156,7 +155,7 @@ namespace ICSharpCode.Profiler.Controls
drawingContext.DrawText(textFormat, new Point(pieceWidth * i, 0)); drawingContext.DrawText(textFormat, new Point(pieceWidth * i, 0));
} }
var events = this.valuesList[i].Events; var events = valuesList[i].Events;
if (events != null && events.Length > 0) { if (events != null && events.Length > 0) {
foreach (EventDataEntry @event in events) { foreach (EventDataEntry @event in events) {
@ -178,43 +177,43 @@ namespace ICSharpCode.Profiler.Controls
new SolidColorBrush(Color.FromArgb(64, Colors.Blue.R, Colors.Blue.G, Colors.Blue.B)), new SolidColorBrush(Color.FromArgb(64, Colors.Blue.R, Colors.Blue.G, Colors.Blue.B)),
new Pen(Brushes.Blue, 1), new Pen(Brushes.Blue, 1),
new Rect( new Rect(
new Point(Math.Min(this.selectedStartIndex, this.selectedEndIndex) * pieceWidth + offset, offsetFromTop), new Point(Math.Min(selectedStartIndex, selectedEndIndex) * pieceWidth + offset, offsetFromTop),
new Point(Math.Max(this.selectedStartIndex, this.selectedEndIndex) * pieceWidth + offset + pieceWidth, this.RenderSize.Height) new Point(Math.Max(selectedStartIndex, selectedEndIndex) * pieceWidth + offset + pieceWidth, RenderSize.Height)
) )
); );
} }
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e) protected override void OnMouseUp(MouseButtonEventArgs e)
{ {
bool valid; bool valid;
Point pos = e.GetPosition(this); Point pos = e.GetPosition(this);
int index = TransformToIndex(pos, out valid); int index = TransformToIndex(pos, out valid);
if (pos.Y >= 40) { if (pos.Y >= 40) {
if (index < this.selectedStartIndex) { if (index < selectedStartIndex) {
this.selectedEndIndex = this.selectedStartIndex; selectedEndIndex = selectedStartIndex;
this.selectedStartIndex = index; selectedStartIndex = index;
} else } else
this.selectedEndIndex = index; selectedEndIndex = index;
} }
this.InvalidateMeasure(); InvalidateMeasure();
this.InvalidateVisual(); InvalidateVisual();
this.ReleaseMouseCapture(); ReleaseMouseCapture();
} }
protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e) protected override void OnMouseDown(MouseButtonEventArgs e)
{ {
this.CaptureMouse(); CaptureMouse();
Point pos = e.GetPosition(this); Point pos = e.GetPosition(this);
bool valid; bool valid;
int index = TransformToIndex(pos, out valid); int index = TransformToIndex(pos, out valid);
if (pos.Y >= 40) if (pos.Y >= 40)
this.selectedStartIndex = this.selectedEndIndex = index; selectedStartIndex = selectedEndIndex = index;
this.InvalidateMeasure(); InvalidateMeasure();
this.InvalidateVisual(); InvalidateVisual();
} }
ToolTip tooltip; ToolTip tooltip;
@ -226,9 +225,9 @@ namespace ICSharpCode.Profiler.Controls
int index = TransformToIndex(pos, out valid); int index = TransformToIndex(pos, out valid);
if (e.LeftButton == MouseButtonState.Pressed) { if (e.LeftButton == MouseButtonState.Pressed) {
this.selectedEndIndex = index; selectedEndIndex = index;
this.InvalidateMeasure(); InvalidateMeasure();
this.InvalidateVisual(); InvalidateVisual();
} else if (tooltip == null && valid) { } else if (tooltip == null && valid) {
tooltip = new ToolTip(); tooltip = new ToolTip();
if (pos.Y < 20) if (pos.Y < 20)
@ -236,14 +235,14 @@ namespace ICSharpCode.Profiler.Controls
else if (pos.Y < 40) else if (pos.Y < 40)
tooltip.Content = CreateTooltipForEvents(index); tooltip.Content = CreateTooltipForEvents(index);
else else
tooltip.Content = "Value: " + this.valuesList[index].Value.ToString(this.Format) + " " + this.Unit; tooltip.Content = "Value: " + valuesList[index].Value.ToString(Format) + " " + Unit;
tooltip .IsOpen = tooltip.Content != null; tooltip .IsOpen = tooltip.Content != null;
} }
} }
object CreateTooltipForEvents(int index) object CreateTooltipForEvents(int index)
{ {
EventDataEntry[] events = this.ValuesList[index].Events; EventDataEntry[] events = ValuesList[index].Events;
TextBlock block = events.Any() ? new TextBlock() : null; TextBlock block = events.Any() ? new TextBlock() : null;
@ -281,14 +280,14 @@ namespace ICSharpCode.Profiler.Controls
protected override void OnLostMouseCapture(MouseEventArgs e) protected override void OnLostMouseCapture(MouseEventArgs e)
{ {
base.OnLostMouseCapture(e); base.OnLostMouseCapture(e);
OnRangeChanged(new RangeEventArgs(this.selectedStartIndex, this.selectedEndIndex)); OnRangeChanged(new RangeEventArgs(selectedStartIndex, selectedEndIndex));
} }
int TransformToIndex(Point point, out bool valid) int TransformToIndex(Point point, out bool valid)
{ {
int value = (int)Math.Floor(point.X / this.pieceWidth); int value = (int)Math.Floor(point.X / pieceWidth);
valid = (0 >= value && value <= this.valuesList.Count - 1); valid = (0 >= value && value <= valuesList.Count - 1);
return Math.Min(Math.Max(0, value), this.valuesList.Count - 1); return Math.Min(Math.Max(0, value), valuesList.Count - 1);
} }
#region MouseHover #region MouseHover
@ -339,7 +338,7 @@ namespace ICSharpCode.Profiler.Controls
mouseHoverStartPoint = newPosition; mouseHoverStartPoint = newPosition;
mouseHoverLastEventArgs = e; mouseHoverLastEventArgs = e;
mouseHoverTimer = new DispatcherTimer(SystemParameters.MouseHoverTime, DispatcherPriority.Background, mouseHoverTimer = new DispatcherTimer(SystemParameters.MouseHoverTime, DispatcherPriority.Background,
OnMouseHoverTimerElapsed, this.Dispatcher); OnMouseHoverTimerElapsed, Dispatcher);
mouseHoverTimer.Start(); mouseHoverTimer.Start();
} }
@ -362,9 +361,9 @@ namespace ICSharpCode.Profiler.Controls
mouseHoverTimer = null; mouseHoverTimer = null;
} }
if (this.tooltip != null) { if (tooltip != null) {
this.tooltip.IsOpen = false; tooltip.IsOpen = false;
this.tooltip = null; tooltip = null;
} }
} }

20
src/AddIns/Analysis/Profiler/Frontend/Controls/TreeListView.cs

@ -2,19 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic; using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Linq;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls
{ {
@ -22,12 +12,12 @@ namespace ICSharpCode.Profiler.Controls
{ {
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {
if (this.SelectedItem is CallTreeNodeViewModel) { if (SelectedItem is CallTreeNodeViewModel) {
CallTreeNodeViewModel item = this.SelectedItem as CallTreeNodeViewModel; CallTreeNodeViewModel item = SelectedItem as CallTreeNodeViewModel;
if (e.Key == Key.Right) { if (e.Key == Key.Right) {
if (item.IsExpanded) { if (item.IsExpanded) {
if (item.Children.Count > 0) if (item.Children.Count > 0)
this.SelectedItem = item.Children.First(); SelectedItem = item.Children.First();
} else { } else {
item.IsExpanded = true; item.IsExpanded = true;
} }
@ -36,7 +26,7 @@ namespace ICSharpCode.Profiler.Controls
if (item.IsExpanded) { if (item.IsExpanded) {
item.IsExpanded = false; item.IsExpanded = false;
} else { } else {
this.SelectedItem = item.Parent; SelectedItem = item.Parent;
} }
e.Handled = true; e.Handled = true;
} }

1
src/AddIns/Analysis/Profiler/Frontend/Controls/WaitBar.cs

@ -4,7 +4,6 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
namespace ICSharpCode.Profiler.Controls namespace ICSharpCode.Profiler.Controls

12
src/AddIns/Analysis/Profiler/X64Converter/Profiler.X64Converter.csproj

@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>X64Converter</RootNamespace> <RootNamespace>X64Converter</RootNamespace>
<AssemblyName>Profiler.X64Converter</AssemblyName> <AssemblyName>Profiler.X64Converter</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> <SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -33,7 +33,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -88,11 +89,18 @@
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
<Name>ICSharpCode.NRefactory.CSharp</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> <ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name> <Name>ICSharpCode.NRefactory</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

133
src/AddIns/Analysis/Profiler/X64Converter/Program.cs

@ -4,12 +4,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.NRefactory.Visitors;
namespace X64Converter namespace X64Converter
{ {
@ -18,38 +15,37 @@ namespace X64Converter
static int Main(string[] args) static int Main(string[] args)
{ {
File.Delete("conversion.log"); File.Delete("conversion.log");
try { try {
List<string> map = new List<string>() List<string> map = new List<string>() {
{
"..\\Controller\\Profiler", "..\\Controller\\Profiler",
"..\\Controller\\Data\\UnmanagedCallTreeNode", "..\\Controller\\Data\\UnmanagedCallTreeNode",
"..\\Controller\\structs" "..\\Controller\\structs"
}; };
foreach (string path in map) foreach (string path in map) {
{ CSharpParser parser = new CSharpParser();
using (IParser parser = ParserFactory.CreateParser(path + ".cs")) string filePath = path + ".cs";
{
parser.Parse();
if (parser.Errors.Count > 0) if (File.Exists(filePath)) {
{ using (StreamReader reader = new StreamReader(filePath)) {
string message = "Parser errors in file " + path + ":\n" + parser.Errors.ErrorOutput; SyntaxTree syntaxTree = parser.Parse(reader, filePath);
if (parser.HasErrors) {
string message = "Parser errors in file " + filePath + ":\n";
foreach (Error error in parser.Errors) {
message += error.Message + "\n";
}
Console.WriteLine(message); Console.WriteLine(message);
File.WriteAllText(path + "64.cs", message); File.WriteAllText(path + "64.cs", message);
return 2; return 2;
} }
var specials = parser.Lexer.SpecialTracker.RetrieveSpecials().Where(item => item is PreprocessingDirective); syntaxTree.AcceptVisitor(new Converter());
parser.CompilationUnit.AcceptVisitor(new Converter(), null); using (StreamWriter writer = new StreamWriter(path + "64.cs")) {
CSharpOutputVisitor output = new CSharpOutputVisitor(); CSharpOutputVisitor output = new CSharpOutputVisitor(writer, FormattingOptionsFactory.CreateSharpDevelop());
SpecialNodesInserter.Install(specials, output); syntaxTree.AcceptVisitor(output);
parser.CompilationUnit.AcceptVisitor(output, null); }
if (!File.Exists(path + "64.cs") || File.ReadAllText(path + "64.cs") != output.Text) {
File.WriteAllText(path + "64.cs", output.Text);
} }
} }
} }
@ -62,102 +58,101 @@ namespace X64Converter
} }
} }
class Converter : AbstractAstTransformer class Converter : DepthFirstAstVisitor<object>
{ {
bool copyAllMembers; bool copyAllMembers;
public override object VisitTypeReference(TypeReference typeReference, object data) public override object VisitSimpleType(SimpleType simpleType)
{ {
if (!typeReference.IsKeyword) simpleType.Identifier = simpleType.Identifier.Replace("32", "64");
typeReference.Type = typeReference.Type.Replace("32", "64"); return base.VisitSimpleType(simpleType);
return base.VisitTypeReference(typeReference, data);
} }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) public override object VisitIdentifierExpression(IdentifierExpression identifierExpression)
{ {
identifierExpression.Identifier = identifierExpression.Identifier.Replace("32", "64"); identifierExpression.Identifier = identifierExpression.Identifier.Replace("32", "64");
return base.VisitIdentifierExpression(identifierExpression, data); return base.VisitIdentifierExpression(identifierExpression);
} }
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
{ {
memberReferenceExpression.MemberName = memberReferenceExpression.MemberName.Replace("32", "64"); memberReferenceExpression.MemberName = memberReferenceExpression.MemberName.Replace("32", "64");
return base.VisitMemberReferenceExpression(memberReferenceExpression, data); return base.VisitMemberReferenceExpression(memberReferenceExpression);
} }
public override object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data) public override object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression)
{ {
pointerReferenceExpression.MemberName = pointerReferenceExpression.MemberName.Replace("32", "64"); pointerReferenceExpression.MemberName = pointerReferenceExpression.MemberName.Replace("32", "64");
return base.VisitPointerReferenceExpression(pointerReferenceExpression, data); return base.VisitPointerReferenceExpression(pointerReferenceExpression);
} }
public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{ {
if (methodDeclaration.Name.EndsWith("32")) if (methodDeclaration.Name.EndsWith("32", StringComparison.Ordinal))
methodDeclaration.Name = methodDeclaration.Name.Replace("32", "64"); methodDeclaration.Name = methodDeclaration.Name.Replace("32", "64");
else { else {
if (!this.copyAllMembers) if (!copyAllMembers)
this.RemoveCurrentNode(); methodDeclaration.Remove();
} }
return base.VisitMethodDeclaration(methodDeclaration, data); return base.VisitMethodDeclaration(methodDeclaration);
} }
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration)
{ {
if (!this.copyAllMembers) if (!copyAllMembers)
this.RemoveCurrentNode(); propertyDeclaration.Remove();
return base.VisitPropertyDeclaration(propertyDeclaration, data); return base.VisitPropertyDeclaration(propertyDeclaration);
} }
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
{ {
if (!this.copyAllMembers) if (!copyAllMembers)
this.RemoveCurrentNode(); fieldDeclaration.Remove();
return base.VisitFieldDeclaration(fieldDeclaration, data); return base.VisitFieldDeclaration(fieldDeclaration);
} }
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{ {
if (!this.copyAllMembers) if (!copyAllMembers)
this.RemoveCurrentNode(); constructorDeclaration.Remove();
return base.VisitConstructorDeclaration(constructorDeclaration, data); return base.VisitConstructorDeclaration(constructorDeclaration);
} }
public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) public override object VisitEventDeclaration(EventDeclaration eventDeclaration)
{ {
if (!this.copyAllMembers) if (!copyAllMembers)
this.RemoveCurrentNode(); eventDeclaration.Remove();
return base.VisitEventDeclaration(eventDeclaration, data); return base.VisitEventDeclaration(eventDeclaration);
} }
public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression)
{ {
if (primitiveExpression.Value is string) if (primitiveExpression.Value is string)
primitiveExpression.Value = ((string)primitiveExpression.Value).Replace("32", "64"); primitiveExpression.Value = ((string)primitiveExpression.Value).Replace("32", "64");
return base.VisitPrimitiveExpression(primitiveExpression, data); return base.VisitPrimitiveExpression(primitiveExpression);
} }
public override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) public override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration)
{ {
if (!this.copyAllMembers) if (!copyAllMembers)
this.RemoveCurrentNode(); destructorDeclaration.Remove();
return base.VisitDestructorDeclaration(destructorDeclaration, data); return base.VisitDestructorDeclaration(destructorDeclaration);
} }
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{ {
if (typeDeclaration.Name.EndsWith("32")) { if (typeDeclaration.Name.EndsWith("32", StringComparison.Ordinal)) {
this.copyAllMembers = true; copyAllMembers = true;
typeDeclaration.Name = typeDeclaration.Name.Replace("32", "64"); typeDeclaration.Name = typeDeclaration.Name.Replace("32", "64");
} else { } else {
if (!typeDeclaration.Modifier.HasFlag(Modifiers.Partial)) if (!typeDeclaration.Modifiers.HasFlag(Modifiers.Partial))
this.RemoveCurrentNode(); typeDeclaration.Remove();
else else
typeDeclaration.Attributes.Clear(); typeDeclaration.Attributes.Clear();
this.copyAllMembers = false; copyAllMembers = false;
} }
return base.VisitTypeDeclaration(typeDeclaration, data); return base.VisitTypeDeclaration(typeDeclaration);
} }
} }
} }

1
src/AddIns/Analysis/Profiler/X64Converter/Properties/AssemblyInfo.cs

@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden // Allgemeine Informationen über eine Assembly werden über die folgenden

6
src/AddIns/Analysis/Profiler/X64Converter/app.config

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

1
src/AddIns/Analysis/UnitTesting/Model/TestBase.cs

@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Input; using System.Windows.Input;

2
src/AddIns/Analysis/UnitTesting/Model/TestNamespace.cs

@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace ICSharpCode.UnitTesting namespace ICSharpCode.UnitTesting
@ -49,5 +50,6 @@ namespace ICSharpCode.UnitTesting
public new TestCollection NestedTests { public new TestCollection NestedTests {
get { return base.NestedTestCollection; } get { return base.NestedTestCollection; }
} }
} }
} }

1
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestClass.cs

@ -222,5 +222,6 @@ namespace ICSharpCode.UnitTesting
} }
base.OnNestedTestsInitialized(); base.OnNestedTestsInitialized();
} }
} }
} }

2
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestMethod.cs

@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
@ -103,5 +104,6 @@ namespace ICSharpCode.UnitTesting
}); });
} }
} }
} }
} }

2
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestProject.cs

@ -26,7 +26,6 @@ namespace ICSharpCode.UnitTesting
{ {
if (options.UseDebugger) if (options.UseDebugger)
return new NUnitTestDebugger(); return new NUnitTestDebugger();
else
return new NUnitTestRunner(options); return new NUnitTestRunner(options);
} }
@ -142,5 +141,6 @@ namespace ICSharpCode.UnitTesting
} }
} }
#endregion #endregion
} }
} }

3
src/AddIns/Analysis/UnitTesting/TestRunner/TestExecutionOptions.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.UnitTesting namespace ICSharpCode.UnitTesting
{ {
@ -18,6 +19,8 @@ namespace ICSharpCode.UnitTesting
/// </summary> /// </summary>
public bool UseDebugger { get; set; } public bool UseDebugger { get; set; }
public IProcessRunner ProcessRunner { get; set; }
/// <summary> /// <summary>
/// Modifies the ProcessStartInfo before the tests are run. /// Modifies the ProcessStartInfo before the tests are run.
/// </summary> /// </summary>

2
src/AddIns/Analysis/UnitTesting/TestRunner/TestProcessRunnerBaseContext.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.UnitTesting
public TestProcessRunnerBaseContext(TestExecutionOptions executionOptions) public TestProcessRunnerBaseContext(TestExecutionOptions executionOptions)
: this(executionOptions, : this(executionOptions,
new ProcessRunner(), executionOptions.ProcessRunner ?? new ProcessRunner(),
new TestResultsReader(), new TestResultsReader(),
SD.FileSystem, SD.FileSystem,
SD.MessageService) SD.MessageService)

Loading…
Cancel
Save