Просмотр исходного кода

Changed default formatting rule in crown-tests

Dexter89 12 лет назад
Родитель
Сommit
d27f9ddc77

+ 3 - 3
tools/gui/crown-tests/GtkExt/TreeViewRowTemplate.cs

@@ -16,18 +16,18 @@ namespace crown_tests.GtkExt
 
 		public static TreeViewRowTemplate Create(Type targetType)
 		{
-			return new TreeViewRowTemplate (targetType);
+			return new TreeViewRowTemplate(targetType);
 		}
 
 		public TreeViewRowTemplate SetBinding(String colName, String path)
 		{
-			ColumnBindings.Add (colName, new Binding () { Path = path });
+			ColumnBindings.Add(colName, new Binding() { Path = path });
 			return this;
 		}
 
 		public TreeViewRowTemplate SetBinding(String colName, String path, Func<object, object> Converter)
 		{
-			ColumnBindings.Add (colName, new Binding () { Path = path, Converter = Converter });
+			ColumnBindings.Add(colName, new Binding() { Path = path, Converter = Converter });
 			return this;
 		}
 	}

+ 18 - 18
tools/gui/crown-tests/GtkExt/TreeViewTemplating.cs

@@ -7,57 +7,57 @@ namespace crown_tests.GtkExt
 	{
 		private static Dictionary<Gtk.TreeView, TreeViewTemplateInfo> mTemplateInfo;
 
-		static TreeViewTemplating() {
+		static TreeViewTemplating()
+		{
 			mTemplateInfo = new Dictionary<Gtk.TreeView, TreeViewTemplateInfo>();
 		}
 
 		private static TreeViewTemplateInfo GetInfo(Gtk.TreeView treeView)
 		{
 			TreeViewTemplateInfo info = null;
-			if (!mTemplateInfo.TryGetValue (treeView, out info)) {
-				info = new TreeViewTemplateInfo ();
-				mTemplateInfo [treeView] = info;
+			if (!mTemplateInfo.TryGetValue(treeView, out info)) {
+				info = new TreeViewTemplateInfo();
+				mTemplateInfo[treeView] = info;
 			}
 			return info;
 		}
 
 		public static void AddRowTemplate(Gtk.TreeView treeView, TreeViewRowTemplate template)
 		{
-			GetInfo (treeView).RowTemplates.Add (template);
+			GetInfo(treeView).RowTemplates.Add(template);
 		}
 
 		public static void ApplyTemplating(Gtk.TreeView treeView)
 		{
 			foreach (var col in treeView.Columns) {
-				col.SetCellDataFunc (col.CellRenderers[0], ValuePropertyDataFunc);
+				col.SetCellDataFunc(col.CellRenderers[0], ValuePropertyDataFunc);
 			}
 		}
 
 		private static void ValuePropertyDataFunc(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
 		{
-			var info = GetInfo ((Gtk.TreeView)column.TreeView);
-
+			var info = GetInfo((Gtk.TreeView)column.TreeView);
 
 			var textCell = (cell as Gtk.CellRendererText);
 			textCell.Text = string.Empty;
-			var value = model.GetValue (iter, 0);
+			var value = model.GetValue(iter, 0);
 			if (value == null)
 				return;
 
 			foreach (var rowTemplate in info.RowTemplates) {
-				if (value.GetType () == rowTemplate.TargetType) {
-					Binding b = null;
-					if (!rowTemplate.ColumnBindings.TryGetValue (column.Title, out b))
+				if (value.GetType() == rowTemplate.TargetType) {
+					Binding binding = null;
+					if (!rowTemplate.ColumnBindings.TryGetValue(column.Title, out binding))
 						return;
 
-					var propInfo = value.GetType ().GetProperty (b.Path);
+					var propInfo = value.GetType().GetProperty(binding.Path);
 					if (propInfo == null)
 						return;
 
-					var propValue = propInfo.GetValue (value, null);
-					if (b.Converter != null)
-						propValue = b.Converter (propValue);
-					textCell.Text = propValue == null ? String.Empty : propValue.ToString ();
+					var propValue = propInfo.GetValue(value, null);
+					if (binding.Converter != null)
+						propValue = binding.Converter(propValue);
+					textCell.Text = propValue == null ? String.Empty : propValue.ToString();
 					return;
 				}
 			}
@@ -65,7 +65,7 @@ namespace crown_tests.GtkExt
 
 		private class TreeViewTemplateInfo
 		{
-			public List<TreeViewRowTemplate> RowTemplates = new List<TreeViewRowTemplate> ();
+			public List<TreeViewRowTemplate> RowTemplates = new List<TreeViewRowTemplate>();
 		}
 	}
 }

+ 26 - 26
tools/gui/crown-tests/MainWindow.cs

@@ -10,30 +10,30 @@ namespace crown_tests
 	{
 		private TestContainer mContainer;
 
-		public MainWindow () : 
-			base (Gtk.WindowType.Toplevel)
+		public MainWindow() : 
+			base(Gtk.WindowType.Toplevel)
 		{
-			this.Build ();
+			this.Build();
 
-			twTests.AppendColumn ("Name", new Gtk.CellRendererText ());
-			twTests.AppendColumn ("State", new Gtk.CellRendererText ());
+			twTests.AppendColumn("Name", new Gtk.CellRendererText());
+			twTests.AppendColumn("State", new Gtk.CellRendererText());
 			TreeViewTemplating.AddRowTemplate(twTests, 
-																				TreeViewRowTemplate.Create (typeof (TestCategory))
-																				.SetBinding ("Name", "Name"));
+				TreeViewRowTemplate.Create(typeof(TestCategory))
+																				.SetBinding("Name", "Name"));
 			TreeViewTemplating.AddRowTemplate(twTests, 
-																				TreeViewRowTemplate.Create (typeof (Test))
-																				.SetBinding ("Name", "Name")
-																				.SetBinding ("State", "LastResult", (x) => object.Equals(x, 0) ? "Passed" : "Failed"));
-			TreeViewTemplating.ApplyTemplating (twTests);
+				TreeViewRowTemplate.Create(typeof(Test))
+																				.SetBinding("Name", "Name")
+																				.SetBinding("State", "LastResult", (x) => object.Equals(x, 0) ? "Passed" : "Failed"));
+			TreeViewTemplating.ApplyTemplating(twTests);
 
 
-			LoadConfigData ();
-			LoadTestsData ();
+			LoadConfigData();
+			LoadTestsData();
 		}
 
 		protected void OnDeleteEvent(object sender, DeleteEventArgs a)
 		{
-			Application.Quit ();
+			Application.Quit();
 			a.RetVal = true;
 		}
 
@@ -41,15 +41,15 @@ namespace crown_tests
 
 		private void btnCreate_Click(object o, EventArgs args)
 		{
-			var creator = new TestSourceCreator (mContainer, txtTestFolder.Text);
-			creator.Create ();
+			var creator = new TestSourceCreator(mContainer, txtTestFolder.Text);
+			creator.Create();
 		}
 
 		private void btnExecute_Click(object o, EventArgs args)
 		{
-			var executor = new TestExecutor (mContainer, txtCrownTestsExe.Text);
-			executor.ExecuteAll ();
-			RefreshData ();
+			var executor = new TestExecutor(mContainer, txtCrownTestsExe.Text);
+			executor.ExecuteAll();
+			RefreshData();
 		}
 
 		private void LoadConfigData()
@@ -60,22 +60,22 @@ namespace crown_tests
 
 		private void LoadTestsData()
 		{
-			var testsJsonFullfileName = System.IO.Path.Combine (txtTestFolder.Text, "tests.json");
-			mContainer = JsonConvert.DeserializeObject<TestContainer> (System.IO.File.ReadAllText (testsJsonFullfileName));
+			var testsJsonFullfileName = System.IO.Path.Combine(txtTestFolder.Text, "tests.json");
+			mContainer = JsonConvert.DeserializeObject<TestContainer>(System.IO.File.ReadAllText(testsJsonFullfileName));
 
-			RefreshData ();
+			RefreshData();
 		}
 
 		private void RefreshData()
 		{
 			var treeStore = twTests.Model as Gtk.TreeStore;
 			if (treeStore == null)
-				treeStore = new Gtk.TreeStore (typeof(object));
-			treeStore.Clear ();
+				treeStore = new Gtk.TreeStore(typeof(object));
+			treeStore.Clear();
 			foreach (var category in mContainer.Categories) {
-				var iter = treeStore.AppendValues (category);
+				var iter = treeStore.AppendValues(category);
 				foreach (var test in category.Tests) {
-					treeStore.AppendValues (iter, test);
+					treeStore.AppendValues(iter, test);
 				}
 			}
 

+ 10 - 10
tools/gui/crown-tests/Program.cs

@@ -4,14 +4,14 @@ using Glade;
 
 namespace crown_tests
 {
-  public class Program
-  {
-    public static void Main(string[] args)
-    {
-      Application.Init();
-      var win = new MainWindow();
-      win.ShowAll();
-      Application.Run();
-    }
-  }
+	public class Program
+	{
+		public static void Main(string[] args)
+		{
+			Application.Init();
+			var win = new MainWindow();
+			win.ShowAll();
+			Application.Run();
+		}
+	}
 }

+ 15 - 14
tools/gui/crown-tests/tests/TestCategory.cs

@@ -6,22 +6,23 @@ using System.Text;
 
 namespace crown_tests.tests
 {
-  [JsonObject(MemberSerialization.OptIn)]
-  public class TestCategory
-  {
-    [JsonProperty]
+	[JsonObject(MemberSerialization.OptIn)]
+	public class TestCategory
+	{
+		[JsonProperty]
 		public String Name { get; set; }
-    [JsonProperty]
+
+		[JsonProperty]
 		public String Description { get; set; }
-    [JsonProperty]
-		public List<Test> Tests { get; set; }
 
-    public TestCategory(String name, String description)
-    {
-      Tests = new List<Test>();
-      Name = name;
-      Description = description;
-    }
+		[JsonProperty]
+		public List<Test> Tests { get; set; }
 
-  }
+		public TestCategory(String name, String description)
+		{
+			Tests = new List<Test>();
+			Name = name;
+			Description = description;
+		}
+	}
 }

+ 9 - 9
tools/gui/crown-tests/tests/TestContainer.cs

@@ -6,15 +6,15 @@ using System.Text;
 
 namespace crown_tests.tests
 {
-  [JsonObject(MemberSerialization.OptIn)]
-  public class TestContainer
-  {
-    [JsonProperty]
+	[JsonObject(MemberSerialization.OptIn)]
+	public class TestContainer
+	{
+		[JsonProperty]
 		public List<TestCategory> Categories { get; set; }
 
-    public TestContainer()
-    {
-      Categories = new List<TestCategory>();
-    }
-  }
+		public TestContainer()
+		{
+			Categories = new List<TestCategory>();
+		}
+	}
 }

+ 24 - 26
tools/gui/crown-tests/tests/TestExecutor.cs

@@ -6,32 +6,30 @@ using System.Text;
 
 namespace crown_tests.tests
 {
-  public class TestExecutor
-  {
-    private TestContainer mContainer;
-    private String mExeFullFileName;
+	public class TestExecutor
+	{
+		private TestContainer mContainer;
+		private String mExeFullFileName;
 
-    public TestExecutor(TestContainer container, String exeFullFileName)
-    {
-      mContainer = container;
-      mExeFullFileName = exeFullFileName;
-    }
+		public TestExecutor(TestContainer container, String exeFullFileName)
+		{
+			mContainer = container;
+			mExeFullFileName = exeFullFileName;
+		}
 
-    public void ExecuteAll()
-    {
-      foreach (var category in mContainer.Categories)
-      {
-        foreach (var test in category.Tests)
-        {
-          var p = new Process();
-          p.StartInfo.FileName = mExeFullFileName;
-          p.StartInfo.Arguments = string.Format("/test:\"{0}\"", test.Name);
-          p.Start();
-          p.WaitForExit();
-          test.LastResult = p.ExitCode;
-          System.Threading.Thread.Sleep(1500);
-        }
-      }
-    }
-  }
+		public void ExecuteAll()
+		{
+			foreach (var category in mContainer.Categories) {
+				foreach (var test in category.Tests) {
+					var p = new Process();
+					p.StartInfo.FileName = mExeFullFileName;
+					p.StartInfo.Arguments = string.Format("/test:\"{0}\"", test.Name);
+					p.Start();
+					p.WaitForExit();
+					test.LastResult = p.ExitCode;
+					System.Threading.Thread.Sleep(1500);
+				}
+			}
+		}
+	}
 }

+ 74 - 80
tools/gui/crown-tests/tests/TestSourceCreator.cs

@@ -6,97 +6,91 @@ using System.IO;
 
 namespace crown_tests.tests
 {
-  public class TestSourceCreator
-  {
-    private TestContainer mContainer;
-    private String mDestFolder;
+	public class TestSourceCreator
+	{
+		private TestContainer mContainer;
+		private String mDestFolder;
 
-    public TestSourceCreator(TestContainer container, String destfolder)
-    {
-      mContainer = container;
-      mDestFolder = destfolder;
-    }
+		public TestSourceCreator(TestContainer container, String destfolder)
+		{
+			mContainer = container;
+			mDestFolder = destfolder;
+		}
 
-    public void Create()
-    {
-      if (!Directory.Exists(mDestFolder))
-        Directory.CreateDirectory(mDestFolder);
+		public void Create()
+		{
+			if (!Directory.Exists(mDestFolder))
+				Directory.CreateDirectory(mDestFolder);
 
-      CreateMainFile();
+			CreateMainFile();
 
-      foreach (var category in mContainer.Categories)
-      {
-        String folder = Path.Combine(mDestFolder, category.Name);
-        if (!Directory.Exists(folder))
-          Directory.CreateDirectory(folder);
-        foreach (var test in category.Tests)
-        {
-          MaybeCreateTestFile(folder, test);
-        }
-      }
-    }
+			foreach (var category in mContainer.Categories) {
+				String folder = Path.Combine(mDestFolder, category.Name);
+				if (!Directory.Exists(folder))
+					Directory.CreateDirectory(folder);
+				foreach (var test in category.Tests) {
+					MaybeCreateTestFile(folder, test);
+				}
+			}
+		}
 
-    private void CreateMainFile()
-    {
-      var mainFullFileName = Path.Combine(mDestFolder, "main.cpp");
+		private void CreateMainFile()
+		{
+			var mainFullFileName = Path.Combine(mDestFolder, "main.cpp");
 
-      String content = "";
+			String content = "";
 
-      foreach (var category in mContainer.Categories)
-      {
-        content += "//Category '" + category.Name + "'" + Environment.NewLine;
-        foreach (var test in category.Tests)
-        {
-          content += "#include \"" + test.Name + ".h\"" + Environment.NewLine;
-        }
-      }
+			foreach (var category in mContainer.Categories) {
+				content += "//Category '" + category.Name + "'" + Environment.NewLine;
+				foreach (var test in category.Tests) {
+					content += "#include \"" + test.Name + ".h\"" + Environment.NewLine;
+				}
+			}
 
-      content += Environment.NewLine;
-      content += "#include <string.h>" + Environment.NewLine;
-      content += "int main(int argc, char** argv)" + Environment.NewLine;
-      content += "{" + Environment.NewLine;
-      content += "  if (argc < 2) return -1;" + Environment.NewLine;
-      foreach (var category in mContainer.Categories)
-      {
-        foreach (var test in category.Tests)
-        {
-          content += "  if (strcmp(argv[1], \"/test:" + test.Name + "\") == 0)" + Environment.NewLine;
-          content += "  return " + test.GetFunctionName() + "();" + Environment.NewLine;
-        }
-      }
-      content += "  return -2;" + Environment.NewLine;
-      content += "}" + Environment.NewLine;
-      File.WriteAllText(mainFullFileName, content);
-    }
+			content += Environment.NewLine;
+			content += "#include <string.h>" + Environment.NewLine;
+			content += "int main(int argc, char** argv)" + Environment.NewLine;
+			content += "{" + Environment.NewLine;
+			content += "  if (argc < 2) return -1;" + Environment.NewLine;
+			foreach (var category in mContainer.Categories) {
+				foreach (var test in category.Tests) {
+					content += "  if (strcmp(argv[1], \"/test:" + test.Name + "\") == 0)" + Environment.NewLine;
+					content += "  return " + test.GetFunctionName() + "();" + Environment.NewLine;
+				}
+			}
+			content += "  return -2;" + Environment.NewLine;
+			content += "}" + Environment.NewLine;
+			File.WriteAllText(mainFullFileName, content);
+		}
 
-    private void MaybeCreateTestFile(String fullFolderName, Test test)
-    {
-      var headerFullFileName = Path.Combine(fullFolderName, test.Name + ".h");
-      var sourceFullFileName = Path.Combine(fullFolderName, test.Name + ".cpp");
+		private void MaybeCreateTestFile(String fullFolderName, Test test)
+		{
+			var headerFullFileName = Path.Combine(fullFolderName, test.Name + ".h");
+			var sourceFullFileName = Path.Combine(fullFolderName, test.Name + ".cpp");
 
-      if (File.Exists(headerFullFileName) || File.Exists(sourceFullFileName))
-        return;
+			if (File.Exists(headerFullFileName) || File.Exists(sourceFullFileName))
+				return;
 
-      //Header
-      String headerContent = "";
-      headerContent += "#pragma once" + Environment.NewLine;
-      headerContent += Environment.NewLine;
-      headerContent += "int " + test.GetFunctionName() + "();" + Environment.NewLine;
-      File.WriteAllText(headerFullFileName, headerContent);
+			//Header
+			String headerContent = "";
+			headerContent += "#pragma once" + Environment.NewLine;
+			headerContent += Environment.NewLine;
+			headerContent += "int " + test.GetFunctionName() + "();" + Environment.NewLine;
+			File.WriteAllText(headerFullFileName, headerContent);
 
-      //Source
-      String sourceContent = "";
-      sourceContent += "#include \"" + Path.GetFileName(headerFullFileName) + "\"" + Environment.NewLine;
-      sourceContent += "#include <time.h>" + Environment.NewLine;
-      sourceContent += "#include <stdlib.h>" + Environment.NewLine;
-      sourceContent += Environment.NewLine;
-      sourceContent += "int " + test.GetFunctionName() + "()" + Environment.NewLine;
-      sourceContent += "{" + Environment.NewLine;
-      sourceContent += "  srand(time(NULL));" + Environment.NewLine;
-      sourceContent += "  return rand() % 2;" + Environment.NewLine;
-      sourceContent += "}" + Environment.NewLine;
-      File.WriteAllText(sourceFullFileName, sourceContent);
-    }
-  }
+			//Source
+			String sourceContent = "";
+			sourceContent += "#include \"" + Path.GetFileName(headerFullFileName) + "\"" + Environment.NewLine;
+			sourceContent += "#include <time.h>" + Environment.NewLine;
+			sourceContent += "#include <stdlib.h>" + Environment.NewLine;
+			sourceContent += Environment.NewLine;
+			sourceContent += "int " + test.GetFunctionName() + "()" + Environment.NewLine;
+			sourceContent += "{" + Environment.NewLine;
+			sourceContent += "  srand(time(NULL));" + Environment.NewLine;
+			sourceContent += "  return rand() % 2;" + Environment.NewLine;
+			sourceContent += "}" + Environment.NewLine;
+			File.WriteAllText(sourceFullFileName, sourceContent);
+		}
+	}
 }
 

+ 6 - 0
tools/gui/toolbox.sln

@@ -56,7 +56,13 @@ Global
 		$1.scope = text/x-csharp
 		$0.CSharpFormattingPolicy = $2
 		$2.BeforeMethodDeclarationParentheses = False
+		$2.BeforeMethodCallParentheses = False
+		$2.BeforeConstructorDeclarationParentheses = False
+		$2.BeforeIndexerDeclarationBracket = False
+		$2.BeforeDelegateDeclarationParentheses = False
 		$2.AfterDelegateDeclarationParameterComma = True
+		$2.NewParentheses = False
+		$2.SpacesBeforeBrackets = False
 		$2.inheritsSet = Mono
 		$2.inheritsScope = text/x-csharp
 		$2.scope = text/x-csharp