Browse Source

refactored Profiler to work with NewNR

pull/45/head
Tobias Ibounig 13 years ago
parent
commit
a3fcb21f92
  1. 31
      SharpDevelop.sln
  2. 5
      src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestClass.cs
  3. 5
      src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestMember.cs
  4. 5
      src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestProject.cs
  5. 5
      src/AddIns/Analysis/Profiler/Controller/Profiler.Controller.csproj
  6. 2
      src/AddIns/Analysis/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin
  7. 11
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Profiler.AddIn.csproj
  8. 23
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/DomMenuCommand.cs
  9. 7
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/FindReferences.cs
  10. 13
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs
  11. 3
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/ProfileExecutable.cs
  12. 16
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/RunTestWithProfilerCommand.cs
  13. 2
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Dialogs/ProfileExecutableForm.xaml.cs
  14. 5
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Extensions.cs
  15. 3
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/OptionPanels/OptionWrapper.cs
  16. 139
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerProcessRunner.cs
  17. 25
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs
  18. 112
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerTestRunner.cs
  19. 12
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerDisplayBinding.cs
  20. 18
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerView.xaml.cs
  21. 1
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/WpfViewer.cs
  22. 5
      src/AddIns/Analysis/Profiler/Frontend/Controls/Profiler.Controls.csproj
  23. 12
      src/AddIns/Analysis/Profiler/X64Converter/Profiler.X64Converter.csproj
  24. 135
      src/AddIns/Analysis/Profiler/X64Converter/Program.cs
  25. 5
      src/AddIns/Analysis/UnitTesting/Model/ITest.cs
  26. 3
      src/AddIns/Analysis/UnitTesting/Model/TestBase.cs
  27. 10
      src/AddIns/Analysis/UnitTesting/Model/TestNamespace.cs
  28. 9
      src/AddIns/Analysis/UnitTesting/Model/TestSolution.cs
  29. 9
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestClass.cs
  30. 11
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestMethod.cs
  31. 12
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestProject.cs
  32. 3
      src/AddIns/Analysis/UnitTesting/TestRunner/TestExecutionOptions.cs
  33. 2
      src/AddIns/Analysis/UnitTesting/TestRunner/TestProcessRunnerBaseContext.cs

31
SharpDevelop.sln

@ -171,6 +171,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MachineSpecifications", "sr @@ -171,6 +171,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MachineSpecifications", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQuality", "src\AddIns\Analysis\CodeQuality\CodeQuality.csproj", "{D1DF9C2D-3A5E-4985-ACA4-648C604DB562}"
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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
@ -473,6 +483,22 @@ Global @@ -473,6 +483,22 @@ Global
{3DF4060F-5EE0-41CF-8096-F27355FD5511}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DF4060F-5EE0-41CF-8096-F27355FD5511}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DF4060F-5EE0-41CF-8096-F27355FD5511}.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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -558,6 +584,11 @@ Global @@ -558,6 +584,11 @@ Global
{08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {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}
{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}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}
{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}

5
src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestClass.cs

@ -95,5 +95,10 @@ namespace ICSharpCode.MachineSpecifications @@ -95,5 +95,10 @@ namespace ICSharpCode.MachineSpecifications
IType type = compilation.MainAssembly.GetTypeDefinition(fullTypeName);
return type.GetDefinition();
}
public override IEnumerable<string> GetUnitTestNames()
{
return NestedTestCollection.SelectMany(t => t.GetUnitTestNames());
}
}
}

5
src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestMember.cs

@ -68,5 +68,10 @@ namespace ICSharpCode.MachineSpecifications @@ -68,5 +68,10 @@ namespace ICSharpCode.MachineSpecifications
{
return member.DeclaringTypeDefinition.FullName;
}
public override System.Collections.Generic.IEnumerable<string> GetUnitTestNames()
{
yield return member.ReflectionName;
}
}
}

5
src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestProject.cs

@ -135,5 +135,10 @@ namespace ICSharpCode.MachineSpecifications @@ -135,5 +135,10 @@ namespace ICSharpCode.MachineSpecifications
return typeDefinition.Attributes.Any(
attribute => MSpecBehaviorsAttributeFQName.Equals(attribute.AttributeType.FullName));
}
public override IEnumerable<string> GetUnitTestNames()
{
return NestedTestCollection.SelectMany(c => c.GetUnitTestNames());
}
}
}

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

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

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

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

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

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Profiler.AddIn</RootNamespace>
<AssemblyName>ICSharpCode.Profiler.AddIn</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
@ -90,6 +90,7 @@ @@ -90,6 +90,7 @@
<DependentUpon>General.xaml</DependentUpon>
</Compile>
<Compile Include="Src\OptionPanels\OptionWrapper.cs" />
<Compile Include="Src\ProfilerProcessRunner.cs" />
<Compile Include="Src\ProfilerRunner.cs" />
<Compile Include="Src\ProfilerTestRunner.cs" />
<Compile Include="Src\SharpDevelopTranslation.cs" />
@ -140,6 +141,14 @@ @@ -140,6 +141,14 @@
</Reference>
</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">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>

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

@ -5,9 +5,11 @@ using System; @@ -5,9 +5,11 @@ using System;
using System.Collections.ObjectModel;
using System.Linq;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.Profiler.AddIn.Commands
@ -21,7 +23,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -21,7 +23,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
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)
return null;
@ -54,7 +56,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -54,7 +56,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
matchWithSameParameterCount = method;
bool isCorrect = true;
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;
break;
}
@ -67,20 +69,19 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -67,20 +69,19 @@ namespace ICSharpCode.Profiler.AddIn.Commands
return matchWithSameParameterCount ?? matchWithSameName;
}
protected IClass GetClassFromName(string name)
protected ITypeDefinition GetClassFromName(string name)
{
if (name == null)
return null;
if (ProjectService.OpenSolution == null)
return null;
foreach (IProject project in ProjectService.OpenSolution.Projects) {
IProjectContent content = ParserService.GetProjectContent(project);
if (content != null) {
IClass c = content.GetClassByReflectionName(name, true);
if (c != null)
return c;
}
foreach (IProject project in SD.ProjectService.CurrentSolution.Projects) {
ICompilation compilation = SD.ParserService.GetCompilation(project);
IType type = compilation.FindType(new FullTypeName(name));
ITypeDefinition definition = type.GetDefinition();
if (definition != null)
return definition;
}
return null;

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

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

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

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

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

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

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

@ -1,16 +1,26 @@ @@ -1,16 +1,26 @@
// 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.Collections.Generic;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using Mono.CSharp.Linq;
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 UnitTestWriter(new ProfilingDataSQLiteWriter(path), tests.SelectMany(t => t.GetUnitTestNames()).ToArray()), new ProfilerOptions()) }).FireAndForget();
}
}
}

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

@ -58,7 +58,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs @@ -58,7 +58,7 @@ namespace ICSharpCode.Profiler.AddIn.Dialogs
if (runner != null) {
runner.RunFinished += delegate {
WorkbenchSingleton.SafeThreadCall(() => FileService.OpenFile(outputPath));
SD.MainThread.InvokeIfRequired(() => FileService.OpenFile(outputPath));
};
runner.Run();

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

@ -34,15 +34,14 @@ namespace ICSharpCode.Profiler.AddIn @@ -34,15 +34,14 @@ namespace ICSharpCode.Profiler.AddIn
if (!File.Exists(path))
return;
FileService.OpenFile(path);
if (!project.ReadOnly) {
if (!project.IsReadOnly) {
FileProjectItem file = new FileProjectItem(project, ItemType.Content, "ProfilingSessions\\" + Path.GetFileName(path));
ProjectService.AddProjectItem(project, file);
ProjectBrowserPad.RefreshViewAsync();
project.Save();
}
};
WorkbenchSingleton.SafeThreadCall(updater);
SD.MainThread.InvokeIfRequired(updater);
}
}
}

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

@ -5,12 +5,13 @@ using System; @@ -5,12 +5,13 @@ using System;
using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.Profiler.AddIn.OptionPanels
{
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 {
get { return properties.Get("SharedMemorySize", ProfilerOptions.DefaultSharedMemorySize) / 1024 / 1024; }

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

@ -0,0 +1,139 @@ @@ -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;
}
}
}
}

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

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

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

@ -6,11 +6,14 @@ using System.Collections.Generic; @@ -6,11 +6,14 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.Profiler.AddIn;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.Profiler.AddIn
@ -18,52 +21,63 @@ namespace ICSharpCode.Profiler.AddIn @@ -18,52 +21,63 @@ namespace ICSharpCode.Profiler.AddIn
public class ProfilerTestRunner : TestRunnerBase
{
ProfilerRunner runner;
UnitTestingOptions options = new UnitTestingOptions();
TestResultsMonitor testResultsMonitor;
//UnitTestingOptions options = new UnitTestingOptions();
TestResultsReader testResultsReader;
public ProfilerTestRunner()
{
}
public override void Start(SelectedTests selectedTests)
public override void Start(IEnumerable<ITest> selectedTests)
{
ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests);
Start(startInfo, selectedTests);
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
protected override ProcessStartInfo GetProcessStartInfo(IEnumerable<ITest> selectedTests)
{
NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, options);
testResultsMonitor = new TestResultsMonitor();
app.Results = testResultsMonitor.FileName;
NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, UnitTestingOptions.Instance);
testResultsReader = new TestResultsReader();
app.ResultsPipe = testResultsReader.PipeName;
return app.GetProcessStartInfo();
}
void Start(ProcessStartInfo startInfo, SelectedTests selectedTests)
void Start(ProcessStartInfo startInfo, IEnumerable<ITest> selectedTests)
{
LogCommandLine(startInfo);
string path = selectedTests.Project.GetSessionFileName();
string path = selectedTests.FirstOrDefault().ParentProject.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));
SD.MainThread.InvokeIfRequired(() => FileService.OpenFile(path));
AfterFinish(selectedTests, path);
};
testResultsMonitor.TestFinished += OnTestFinished;
testResultsMonitor.Start();
testResultsReader.TestFinished += OnTestFinished;
testResultsReader.Start();
runner.Run();
}
IEnumerable<string> GetUnitTestNames(SelectedTests selectedTests)
IEnumerable<string> GetUnitTestNames(IEnumerable<ITest> selectedTests)
{
IProjectContent content = ParserService.GetProjectContent(selectedTests.Project);
if (selectedTests.Class == null) {
foreach (var project in selectedTests.Select(l => l.ParentProject)) {
foreach (var name in project.GetUnitTestNames()) {
yield return name;
}
}
/*
foreach (ITest test in selectedTests) {
IProject project = test.ParentProject.Project;
ICompilation compilation = SD.ParserService.GetCompilation(project);
compilation.FindType
}
IProjectContent content = selectedTests.FirstOrDefault().ParentProject.Project.ProjectContent;
IEnumerable<NUnitTestClass> selectedNunitTests = (IEnumerable<NUnitTestClass>) selectedTests;
if (selectedNunitTests.FirstOrDefault() == null) {
var testClasses = content.Classes
.Where(c => c.Attributes.Any(a => a.AttributeType.FullyQualifiedName == "NUnit.Framework.TestFixtureAttribute"));
return testClasses
@ -71,40 +85,80 @@ namespace ICSharpCode.Profiler.AddIn @@ -71,40 +85,80 @@ namespace ICSharpCode.Profiler.AddIn
.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
return content.Classes.First(c => c.FullyQualifiedName == selectedNunitTests.FirstOrDefault().ClassName).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 };
return new[] { selectedTests.Class.DotNetName + "." + selectedTests.Member.Name };*/
}
void AfterFinish(SelectedTests selectedTests, string path)
void AfterFinish(IEnumerable<ITest> selectedTests, string path)
{
selectedTests.Project.AddSessionToProject(path);
OnAllTestsFinished(this, new EventArgs());
selectedTests.FirstOrDefault().ParentProject.Project.AddSessionToProject(path);
OnAllTestsFinished();
LoggingService.Info("shutting profiler down...");
}
public override void Stop()
/*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;
if (testResultsReader != null) {
testResultsReader.Dispose();
//testResultsReader.Stop();
//testResultsReader.Read();
testResultsReader = null;
}
}
public override void Dispose()
{
Stop();
}*/
protected override void OnAllTestsFinished()
{
testResultsReader.Join();
base.OnAllTestsFinished();
}
public override void Stop()
{
if (this.runner != null && this.runner.Profiler.IsRunning) {
LoggingService.Info("stopping profiler...");
runner.Stop();
}
if (testResultsReader != null) {
testResultsReader.Dispose();
testResultsReader = null;
}
}
public override void Dispose()
{
testResultsReader.Dispose();
testResultsReader.TestFinished -= OnTestFinished;
}
public override int GetExpectedNumberOfTestResults(IEnumerable<ITest> selectedTests)
{
return GetNumberOfTestMethods(selectedTests);
}
public static int GetNumberOfTestMethods(IEnumerable<ITest> selectedTests)
{
int count = 0;
foreach (ITest test in selectedTests) {
if (test is NUnitTestMethod)
count++;
else
count += GetNumberOfTestMethods(test.NestedTests);
}
return count;
}
}
}

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

@ -7,6 +7,7 @@ using ICSharpCode.Core; @@ -7,6 +7,7 @@ using ICSharpCode.Core;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Profiler.AddIn.Views
{
@ -24,7 +25,7 @@ namespace ICSharpCode.Profiler.AddIn.Views @@ -24,7 +25,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
return true; // definition in .addin does extension-based filtering
}
public ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(OpenedFile file)
public IViewContent CreateContentForFile(OpenedFile file)
{
ProfilingDataSQLiteProvider provider;
try {
@ -46,12 +47,17 @@ namespace ICSharpCode.Profiler.AddIn.Views @@ -46,12 +47,17 @@ namespace ICSharpCode.Profiler.AddIn.Views
return new WpfViewer(file, provider);
}
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
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;
}

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

@ -52,7 +52,7 @@ namespace ICSharpCode.Profiler.AddIn.Views @@ -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));
@ -104,16 +104,14 @@ namespace ICSharpCode.Profiler.AddIn.Views @@ -104,16 +104,14 @@ namespace ICSharpCode.Profiler.AddIn.Views
void UpdateErrorList(IEnumerable<CompilerError> errors)
{
Dispatcher.Invoke(
(Action)(
() => {
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) {
WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
TaskService.ClearExceptCommentTasks();
TaskService.AddRange(tasks);
}
(Action)delegate {
List<SDTask> tasks = errors.Select(error => new SDTask(null, error.ErrorText, error.Column, error.Line, (error.IsWarning) ? TaskType.Warning : TaskType.Error)).ToList();
if (tasks.Count > 0) {
SD.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
TaskService.ClearExceptCommentTasks();
TaskService.AddRange(tasks);
}
)
}
);
}

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

@ -10,6 +10,7 @@ using ICSharpCode.Core.Presentation; @@ -10,6 +10,7 @@ using ICSharpCode.Core.Presentation;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.Profiler.AddIn.Views
{

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

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

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

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>X64Converter</RootNamespace>
<AssemblyName>Profiler.X64Converter</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -33,7 +33,8 @@ @@ -33,7 +33,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -88,11 +89,18 @@ @@ -88,11 +89,18 @@
</BootstrapperPackage>
</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>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.

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

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

5
src/AddIns/Analysis/UnitTesting/Model/ITest.cs

@ -38,6 +38,11 @@ namespace ICSharpCode.UnitTesting @@ -38,6 +38,11 @@ namespace ICSharpCode.UnitTesting
/// </summary>
string DisplayName { get; }
/// <summary>
/// Gets all the names of the unit tests contained in this node.
/// </summary>
IEnumerable<string> GetUnitTestNames();
/// <summary>
/// Raised when the <see cref="Name"/> property changes.
/// </summary>

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

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;
@ -22,6 +23,8 @@ namespace ICSharpCode.UnitTesting @@ -22,6 +23,8 @@ namespace ICSharpCode.UnitTesting
public abstract ITestProject ParentProject { get; }
public abstract IEnumerable<string> GetUnitTestNames();
#region Result
TestResultType result;
bool useCompositeResultsOfNestedTests;

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

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace ICSharpCode.UnitTesting
@ -49,5 +50,14 @@ namespace ICSharpCode.UnitTesting @@ -49,5 +50,14 @@ namespace ICSharpCode.UnitTesting
public new TestCollection NestedTests {
get { return base.NestedTestCollection; }
}
public override IEnumerable<string> GetUnitTestNames()
{
foreach (var test in base.NestedTests) {
foreach (var name in test.ParentProject.GetUnitTestNames()) {
yield return name;
}
}
}
}
}

9
src/AddIns/Analysis/UnitTesting/Model/TestSolution.cs

@ -73,6 +73,15 @@ namespace ICSharpCode.UnitTesting @@ -73,6 +73,15 @@ namespace ICSharpCode.UnitTesting
return Enumerable.Empty<ITest>();
}
public override IEnumerable<string> GetUnitTestNames()
{
foreach (var project in changeListeners.Select(l => l.testProject)) {
foreach (var name in project.GetUnitTestNames()) {
yield return name;
}
}
}
/// <summary>
/// Creates a TestProject for an IProject.
/// This class takes care of changes in the test framework and will recreate the testProject

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

@ -222,5 +222,14 @@ namespace ICSharpCode.UnitTesting @@ -222,5 +222,14 @@ namespace ICSharpCode.UnitTesting
}
base.OnNestedTestsInitialized();
}
public override IEnumerable<string> GetUnitTestNames()
{
foreach (var test in base.NestedTests) {
foreach (var name in test.ParentProject.GetUnitTestNames()) {
yield return name;
}
}
}
}
}

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

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Windows.Input;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
@ -103,5 +104,15 @@ namespace ICSharpCode.UnitTesting @@ -103,5 +104,15 @@ namespace ICSharpCode.UnitTesting
});
}
}
public override IEnumerable<string> GetUnitTestNames()
{
foreach (var test in base.NestedTests) {
foreach (var name in test.ParentProject.GetUnitTestNames()) {
yield return name;
}
}
}
}
}

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

@ -26,8 +26,7 @@ namespace ICSharpCode.UnitTesting @@ -26,8 +26,7 @@ namespace ICSharpCode.UnitTesting
{
if (options.UseDebugger)
return new NUnitTestDebugger();
else
return new NUnitTestRunner(options);
return new NUnitTestRunner(options);
}
protected override bool IsTestClass(ITypeDefinition typeDefinition)
@ -142,5 +141,14 @@ namespace ICSharpCode.UnitTesting @@ -142,5 +141,14 @@ namespace ICSharpCode.UnitTesting
}
}
#endregion
public override IEnumerable<string> GetUnitTestNames()
{
foreach (var test in base.NestedTests) {
foreach (var name in test.ParentProject.GetUnitTestNames()) {
yield return name;
}
}
}
}
}

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

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

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

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

Loading…
Cancel
Save