Browse Source

Add NRConsistencyCheckAddIn.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
52068795f5
  1. 124
      src/Tools/NRConsistencyCheckAddIn/Adapter.cs
  2. 67
      src/Tools/NRConsistencyCheckAddIn/Commands.cs
  3. 31
      src/Tools/NRConsistencyCheckAddIn/Configuration/AssemblyInfo.cs
  4. 20
      src/Tools/NRConsistencyCheckAddIn/NRConsistencyCheckAddIn.addin
  5. 119
      src/Tools/NRConsistencyCheckAddIn/NRConsistencyCheckAddIn.csproj
  6. 18
      src/Tools/NRConsistencyCheckAddIn/NRConsistencyCheckAddIn.sln
  7. 2
      src/Tools/StressTest/StressTest.sln
  8. 10
      src/Tools/StressTest/StressTest/StressTest.csproj
  9. 6
      src/Tools/StressTest/StressTest/StressTestMenuCommand.cs
  10. 79
      src/Tools/StressTest/StressTest/UserControl.xaml.cs

124
src/Tools/NRConsistencyCheckAddIn/Adapter.cs

@ -0,0 +1,124 @@ @@ -0,0 +1,124 @@
/*
* Created by SharpDevelop.
* User: Daniel
* Date: 10/6/2012
* Time: 17:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.NRefactory.ConsistencyCheck
{
// Adapters from SD to NR.ConsistencyCheck solution model
public class Solution
{
public readonly List<CSharpProject> Projects = new List<CSharpProject>();
public Solution(ICSharpCode.SharpDevelop.Project.Solution solution)
{
foreach (var p in solution.Projects.OfType<MSBuildBasedProject>()) {
if (p.FileName.ToString().EndsWith(".csproj", StringComparison.OrdinalIgnoreCase))
Projects.Add(new CSharpProject(p));
}
var snapshot = SD.ParserService.GetCurrentSolutionSnapshot();
foreach (var p in Projects) {
p.Compilation = snapshot.GetCompilation(p.IProject);
}
}
public IEnumerable<CSharpFile> AllFiles {
get {
return Projects.SelectMany(p => p.Files);
}
}
}
public class CSharpProject
{
public readonly MSBuildBasedProject IProject;
public readonly CompilerSettings CompilerSettings = new CompilerSettings();
public readonly List<CSharpFile> Files = new List<CSharpFile>();
public ICompilation Compilation;
public CSharpProject(MSBuildBasedProject project)
{
this.IProject = project;
CompilerSettings.AllowUnsafeBlocks = GetBoolProperty("AllowUnsafeBlocks") ?? false;
CompilerSettings.CheckForOverflow = GetBoolProperty("CheckForOverflowUnderflow") ?? false;
string defineConstants = project.GetEvaluatedProperty("DefineConstants");
foreach (string symbol in defineConstants.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries))
this.CompilerSettings.ConditionalSymbols.Add(symbol.Trim());
// Parse the C# code files
foreach (var item in project.GetItemsOfType(ItemType.Compile)) {
var file = new CSharpFile(this, FileName.Create(item.FileName));
Files.Add(file);
}
}
bool? GetBoolProperty(string propertyName)
{
string val = IProject.GetEvaluatedProperty(propertyName);
bool result;
if (bool.TryParse(val, out result))
return result;
else
return null;
}
}
public class CSharpFile
{
public readonly CSharpProject Project;
public readonly string FileName;
public readonly string OriginalText;
public SyntaxTree SyntaxTree;
public CSharpUnresolvedFile UnresolvedTypeSystemForFile;
public CSharpFile(CSharpProject project, FileName fileName)
{
this.Project = project;
this.FileName = fileName;
this.OriginalText = File.ReadAllText(fileName);
CSharpParser p = new CSharpParser(project.CompilerSettings);
this.SyntaxTree = p.Parse(this.OriginalText, fileName);
this.UnresolvedTypeSystemForFile = SD.ParserService.GetExistingUnresolvedFile(fileName, null, project.IProject) as CSharpUnresolvedFile;
if (this.UnresolvedTypeSystemForFile == null)
throw new InvalidOperationException("LoadSolutionProjectsThread not yet finished?");
}
public CSharpAstResolver CreateResolver()
{
return new CSharpAstResolver(Project.Compilation, SyntaxTree, UnresolvedTypeSystemForFile);
}
}
sealed class Timer : IDisposable
{
Stopwatch w = Stopwatch.StartNew();
public Timer(string title)
{
Console.Write(title);
}
public void Dispose()
{
Console.WriteLine(w.Elapsed);
}
}
}

67
src/Tools/NRConsistencyCheckAddIn/Commands.cs

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
/*
* Created by SharpDevelop.
* User: Daniel
* Date: 10/6/2012
* Time: 18:05
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.NRefactory.ConsistencyCheck
{
public abstract class ConsistencyCheckCommand : SimpleCommand
{
public sealed override void Execute(object parameter)
{
Execute(parameter as Solution ?? new Solution(ProjectService.OpenSolution));
}
public abstract void Execute(Solution solution);
protected void RunTestOnAllFiles(Solution solution, Action<CSharpFile> runTest)
{
using (new Timer(GetType().Name + "... ")) {
foreach (var file in solution.AllFiles) {
runTest(file);
}
}
}
}
public class RunAllTestsCommand : ConsistencyCheckCommand
{
public override void Execute(Solution solution)
{
new ResolverTestCommand().Execute(solution);
new ResolverTestWithoutUnresolvedFileCommand().Execute(solution);
new ResolverTestRandomizedOrderCommand().Execute(solution);
}
}
public class ResolverTestCommand : ConsistencyCheckCommand
{
public override void Execute(Solution solution)
{
RunTestOnAllFiles(solution, ResolverTest.RunTest);
}
}
public class ResolverTestWithoutUnresolvedFileCommand : ConsistencyCheckCommand
{
public override void Execute(Solution solution)
{
RunTestOnAllFiles(solution, ResolverTest.RunTestWithoutUnresolvedFile);
}
}
public class ResolverTestRandomizedOrderCommand : ConsistencyCheckCommand
{
public override void Execute(Solution solution)
{
RunTestOnAllFiles(solution, RandomizedOrderResolverTest.RunTest);
}
}
}

31
src/Tools/NRConsistencyCheckAddIn/Configuration/AssemblyInfo.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("StressTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StressTest")]
[assembly: AssemblyCopyright("Copyright 2012 Daniel Grunwald")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

20
src/Tools/NRConsistencyCheckAddIn/NRConsistencyCheckAddIn.addin

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
<AddIn name = "NRConsistencyCheck"
author = "Daniel Grunwald"
url = ""
description = "TODO: Put description here">
<Runtime>
<Import assembly = "NRConsistencyCheckAddIn.dll"/>
</Runtime>
<Path name="/SharpDevelop/Workbench/Tools">
<MenuItem id="NR Consistency Check"
type="Menu"
label="NR Consistency Check">
<MenuItem label="Run all tests" class="ICSharpCode.NRefactory.ConsistencyCheck.RunAllTestsCommand" />
<MenuItem label="CSharpAstResolver test" class="ICSharpCode.NRefactory.ConsistencyCheck.ResolverTestCommand" />
<MenuItem label="CSharpAstResolver test (no unresolved file)" class="ICSharpCode.NRefactory.ConsistencyCheck.ResolverTestWithoutUnresolvedFileCommand" />
<MenuItem label="CSharpAstResolver test (randomized order)" class="ICSharpCode.NRefactory.ConsistencyCheck.ResolverTestRandomizedOrderCommand" />
</MenuItem>
</Path>
</AddIn>

119
src/Tools/NRConsistencyCheckAddIn/NRConsistencyCheckAddIn.csproj

@ -0,0 +1,119 @@ @@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{30D10654-A5F5-4AC5-A370-E6DD4D0FAC50}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.NRefactory.ConsistencyCheck</RootNamespace>
<AssemblyName>NRConsistencyCheckAddIn</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<StartAction>Program</StartAction>
<StartProgram>..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.Core">
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.NRefactory.CSharp">
<HintPath>..\..\..\bin\ICSharpCode.NRefactory.CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="NRConsistencyCheckAddIn.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Libraries\NRefactory\ICSharpCode.NRefactory.ConsistencyCheck\FindReferencesConsistencyCheck.cs">
<Link>FindReferencesConsistencyCheck.cs</Link>
</Compile>
<Compile Include="..\..\Libraries\NRefactory\ICSharpCode.NRefactory.ConsistencyCheck\RandomizedOrderResolverTest.cs">
<Link>RandomizedOrderResolverTest.cs</Link>
</Compile>
<Compile Include="..\..\Libraries\NRefactory\ICSharpCode.NRefactory.ConsistencyCheck\ResolverTest.cs">
<Link>ResolverTest.cs</Link>
</Compile>
<Compile Include="..\..\Libraries\NRefactory\ICSharpCode.NRefactory.ConsistencyCheck\TypeSystemTests.cs">
<Link>TypeSystemTests.cs</Link>
</Compile>
<Compile Include="..\..\Libraries\NRefactory\ICSharpCode.NRefactory.ConsistencyCheck\VisitorBenchmark.cs">
<Link>VisitorBenchmark.cs</Link>
</Compile>
<Compile Include="Commands.cs" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Adapter.cs" />
</ItemGroup>
<PropertyGroup>
<StartArguments>/addindir:"$(MsBuildProjectDirectory)\$(OutputPath)"</StartArguments>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

18
src/Tools/NRConsistencyCheckAddIn/NRConsistencyCheckAddIn.sln

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.3
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRConsistencyCheckAddIn", "NRConsistencyCheckAddIn.csproj", "{30D10654-A5F5-4AC5-A370-E6DD4D0FAC50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30D10654-A5F5-4AC5-A370-E6DD4D0FAC50}.Debug|x86.Build.0 = Debug|x86
{30D10654-A5F5-4AC5-A370-E6DD4D0FAC50}.Debug|x86.ActiveCfg = Debug|x86
{30D10654-A5F5-4AC5-A370-E6DD4D0FAC50}.Release|x86.Build.0 = Release|x86
{30D10654-A5F5-4AC5-A370-E6DD4D0FAC50}.Release|x86.ActiveCfg = Release|x86
EndGlobalSection
EndGlobal

2
src/Tools/StressTest/StressTest.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.5522
# SharpDevelop 4.3
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StressTest", "StressTest\StressTest.csproj", "{30D10654-A5F5-4AC5-A370-E6DD4D0FAC50}"
EndProject
Global

10
src/Tools/StressTest/StressTest/StressTest.csproj

@ -7,11 +7,12 @@ @@ -7,11 +7,12 @@
<OutputType>Library</OutputType>
<RootNamespace>StressTest</RootNamespace>
<AssemblyName>StressTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -47,14 +48,13 @@ @@ -47,14 +48,13 @@
<HintPath>..\..\..\..\bin\ICSharpCode.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop.Dom">
<HintPath>..\..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>

6
src/Tools/StressTest/StressTest/StressTestMenuCommand.cs

@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
using System;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace StressTest
{
@ -16,11 +18,11 @@ namespace StressTest @@ -16,11 +18,11 @@ namespace StressTest
{
public override void Run()
{
StressTestViewContent vc = WorkbenchSingleton.Workbench.ViewContentCollection.OfType<StressTestViewContent>().FirstOrDefault();
StressTestViewContent vc = SD.Workbench.ViewContentCollection.OfType<StressTestViewContent>().FirstOrDefault();
if (vc != null)
vc.WorkbenchWindow.SelectWindow();
else
WorkbenchSingleton.Workbench.ShowView(new StressTestViewContent());
SD.Workbench.ShowView(new StressTestViewContent());
}
}

79
src/Tools/StressTest/StressTest/UserControl.xaml.cs

@ -11,6 +11,7 @@ using System.Collections.Generic; @@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@ -18,7 +19,6 @@ using System.Windows.Documents; @@ -18,7 +19,6 @@ using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
@ -37,21 +37,12 @@ namespace StressTest @@ -37,21 +37,12 @@ namespace StressTest
InitializeComponent();
}
void Run(string name, IEnumerable<DispatcherPriority> process)
async void Run(string name, Func<Task> process)
{
var e = process.GetEnumerator();
Stopwatch w = Stopwatch.StartNew();
Action cont = null;
cont = delegate {
if (e.MoveNext()) {
Dispatcher.BeginInvoke(e.Current, cont);
} else {
e.Dispose();
w.Stop();
TaskService.BuildMessageViewCategory.AppendLine(name + " (" + Repetitions + "x): " + w.Elapsed.ToString());
}
};
cont();
await process();
w.Stop();
TaskService.BuildMessageViewCategory.AppendLine(name + " (" + Repetitions + "x): " + w.Elapsed.ToString());
}
int Repetitions {
@ -60,40 +51,42 @@ namespace StressTest @@ -60,40 +51,42 @@ namespace StressTest
void openFileButton_Click(object sender, RoutedEventArgs e)
{
Run("Open File", OpenFile());
Run("Open File", OpenFile);
}
string bigFile = Path.Combine(FileUtility.ApplicationRootPath, @"src\Libraries\NRefactory\Project\Src\Ast\Generated.cs");
string bigFile = Path.Combine(FileUtility.ApplicationRootPath, @"src\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\Parser\mcs\expression.cs");
const DispatcherPriority Idle = DispatcherPriority.ApplicationIdle;
IEnumerable<DispatcherPriority> OpenFile()
async Task OpenFile()
{
for (int i = 0; i < Repetitions; i++) {
IViewContent newContent = FileService.OpenFile(bigFile);
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
newContent.WorkbenchWindow.CloseWindow(true);
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
}
}
void TypeTextButton_Click(object sender, RoutedEventArgs e)
{
Run("Type Comment In C# file", TypeText(typeCommentTextBox.Text));
Run("Type Comment In C# file", () => TypeText(typeCommentTextBox.Text));
}
IEnumerable<DispatcherPriority> TypeText(string theText)
async Task TypeText(string theText)
{
const string csharpHeader = "using System;\n\nclass Test {\n\tpublic void M() {\n\t\t";
const string csharpFooter = "\n\t}\n}\n";
IViewContent vc = FileService.NewFile("stresstest.cs", "");
ITextEditor editor = ((ITextEditorProvider)vc).TextEditor;
ITextEditor editor = vc.GetRequiredService<ITextEditor>();
editor.Document.Text = csharpHeader + csharpFooter;
editor.Caret.Offset = csharpHeader.Length;
TextArea textArea = (TextArea)editor.GetService(typeof(TextArea));
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
for (int i = 0; i < Repetitions; i++) {
foreach (char c in "// " + theText + "\n") {
textArea.PerformTextInput(c.ToString());
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
}
}
vc.WorkbenchWindow.CloseWindow(true);
@ -101,58 +94,58 @@ namespace StressTest @@ -101,58 +94,58 @@ namespace StressTest
void EraseTextButton_Click(object sender, RoutedEventArgs e)
{
Run("Erase Text In C# file", EraseText((eraseTextBackwards.IsChecked == true) ? EditingCommands.Backspace : EditingCommands.Delete));
Run("Erase Text In C# file", () => EraseText((eraseTextBackwards.IsChecked == true) ? EditingCommands.Backspace : EditingCommands.Delete));
}
IEnumerable<DispatcherPriority> EraseText(RoutedUICommand deleteCommand)
async Task EraseText(RoutedUICommand deleteCommand)
{
IViewContent vc = FileService.NewFile("stresstest.cs", "");
ITextEditor editor = ((ITextEditorProvider)vc).TextEditor;
TextArea textArea = (TextArea)editor.GetService(typeof(TextArea));
ITextEditor editor = vc.GetRequiredService<ITextEditor>();
TextArea textArea = editor.GetRequiredService<TextArea>();
editor.Document.Text = File.ReadAllText(bigFile);
editor.Caret.Offset = editor.Document.TextLength / 2;
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
for (int i = 0; i < Repetitions; i++) {
deleteCommand.Execute(null, textArea);
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
}
vc.WorkbenchWindow.CloseWindow(true);
}
void TypeCodeButton_Click(object sender, RoutedEventArgs e)
{
Run("Type Code In C# file", TypeCode());
Run("Type Code In C# file", TypeCode);
}
IEnumerable<DispatcherPriority> TypeCode()
async Task TypeCode()
{
IViewContent vc = FileService.NewFile("stresstest.cs", "");
ITextEditor editor = ((ITextEditorProvider)vc).TextEditor;
TextArea textArea = (TextArea)editor.GetService(typeof(TextArea));
ITextEditor editor = vc.GetRequiredService<ITextEditor>();
TextArea textArea = editor.GetRequiredService<TextArea>();
string inputText = string.Join("\n", File.ReadAllLines(bigFile).Where(l => !string.IsNullOrWhiteSpace(l) && !l.StartsWith("//", StringComparison.Ordinal)));
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
for (int i = 0; i < Math.Min(inputText.Length, Repetitions); i++) {
textArea.PerformTextInput(inputText[i].ToString());
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
while (!textArea.StackedInputHandlers.IsEmpty)
textArea.PopStackedInputHandler(textArea.StackedInputHandlers.Peek());
yield return DispatcherPriority.SystemIdle;
await Dispatcher.Yield(Idle);
}
vc.WorkbenchWindow.CloseWindow(true);
}
void SwitchLayoutButton_Click(object sender, RoutedEventArgs e)
{
Run("Switch Layout", SwitchLayout());
Run("Switch Layout", SwitchLayout);
}
IEnumerable<DispatcherPriority> SwitchLayout()
async Task SwitchLayout()
{
for (int i = 0; i < Repetitions; i++) {
LayoutConfiguration.CurrentLayoutName = "Debug";
yield return DispatcherPriority.SystemIdle;
LayoutConfiguration.CurrentLayoutName = "Default";
yield return DispatcherPriority.SystemIdle;
SD.Workbench.CurrentLayoutConfiguration = "Debug";
await Dispatcher.Yield(Idle);
SD.Workbench.CurrentLayoutConfiguration = "Default";
await Dispatcher.Yield(Idle);
}
}
}

Loading…
Cancel
Save