Browse Source

remove samples/NRefactoryDemo (now included in the NRefactory repository)

pull/297/head
Siegfried Pammer 12 years ago
parent
commit
1a8356f76c
  1. 27
      samples/NRefactoryDemo/AssemblyInfo.cs
  2. 83
      samples/NRefactoryDemo/AstView.Designer.cs
  3. 247
      samples/NRefactoryDemo/AstView.cs
  4. 120
      samples/NRefactoryDemo/AstView.resx
  5. 112
      samples/NRefactoryDemo/EditDialog.Designer.cs
  6. 42
      samples/NRefactoryDemo/EditDialog.cs
  7. 120
      samples/NRefactoryDemo/EditDialog.resx
  8. 327
      samples/NRefactoryDemo/MainForm.Designer.cs
  9. 162
      samples/NRefactoryDemo/MainForm.cs
  10. 120
      samples/NRefactoryDemo/MainForm.resx
  11. 87
      samples/NRefactoryDemo/NRefactoryDemo.csproj
  12. 18
      samples/NRefactoryDemo/NRefactoryDemo.sln
  13. 2
      src/Automated.proj

27
samples/NRefactoryDemo/AssemblyInfo.cs

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("NRefactory Demo")]
[assembly: AssemblyDescription("Graphical application to demonstrate NRefactory")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("icsharpcode.net")]
[assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2006, Daniel Grunwald")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

83
samples/NRefactoryDemo/AstView.Designer.cs generated

@ -1,83 +0,0 @@ @@ -1,83 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2006, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace NRefactoryDemo
{
partial class AstView : System.Windows.Forms.UserControl
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the control.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.tree = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// tree
//
this.tree.Dock = System.Windows.Forms.DockStyle.Fill;
this.tree.HideSelection = false;
this.tree.Location = new System.Drawing.Point(0, 0);
this.tree.Name = "tree";
this.tree.ShowRootLines = false;
this.tree.Size = new System.Drawing.Size(186, 182);
this.tree.TabIndex = 0;
this.tree.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TreeKeyDown);
//
// AstView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tree);
this.Name = "AstView";
this.Size = new System.Drawing.Size(186, 182);
this.ResumeLayout(false);
}
private System.Windows.Forms.TreeView tree;
}
}

247
samples/NRefactoryDemo/AstView.cs

@ -1,247 +0,0 @@ @@ -1,247 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2006, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections;
using System.Windows.Forms;
using System.Reflection;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory;
namespace NRefactoryDemo
{
public partial class AstView
{
CompilationUnit unit;
public CompilationUnit Unit {
get {
return unit;
}
set {
unit = value;
UpdateTree();
}
}
void UpdateTree()
{
tree.Nodes.Clear();
tree.Nodes.Add(new CollectionNode("CompilationUnit", unit.Children));
tree.SelectedNode = tree.Nodes[0];
}
public AstView()
{
InitializeComponent();
}
public void DeleteSelectedNode()
{
if (tree.SelectedNode is ElementNode) {
INode element = (tree.SelectedNode as ElementNode).element;
if (tree.SelectedNode.Parent is CollectionNode) {
if (MessageBox.Show("Remove selected node from parent collection?", "Remove node", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
IList col = (tree.SelectedNode.Parent as CollectionNode).collection;
col.Remove(element);
(tree.SelectedNode.Parent as CollectionNode).Update();
}
} else if (tree.SelectedNode.Parent is ElementNode) {
if (MessageBox.Show("Set selected property to null?", "Remove node", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
// get parent element
element = (tree.SelectedNode.Parent as ElementNode).element;
string propertyName = (string)tree.SelectedNode.Tag;
element.GetType().GetProperty(propertyName).SetValue(element, null, null);
(tree.SelectedNode.Parent as ElementNode).Update();
}
}
} else if (tree.SelectedNode is CollectionNode) {
if (MessageBox.Show("Remove all elements from selected collection?", "Clear collection", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
IList col = (tree.SelectedNode as CollectionNode).collection;
col.Clear();
(tree.SelectedNode as CollectionNode).Update();
}
}
}
public void EditSelectedNode()
{
TreeNode node = tree.SelectedNode;
while (!(node is ElementNode)) {
if (node == null) {
return;
}
node = node.Parent;
}
INode element = ((ElementNode)node).element;
using (EditDialog dlg = new EditDialog(element)) {
dlg.ShowDialog();
}
((ElementNode)node).Update();
}
public void ApplyTransformation(IAstVisitor visitor)
{
if (tree.SelectedNode == tree.Nodes[0]) {
unit.AcceptVisitor(visitor, null);
UpdateTree();
} else {
string name = visitor.GetType().Name;
ElementNode elementNode = tree.SelectedNode as ElementNode;
CollectionNode collectionNode = tree.SelectedNode as CollectionNode;
if (elementNode != null) {
if (MessageBox.Show(("Apply " + name + " to selected element '" + elementNode.Text + "'?"),
"Apply transformation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
elementNode.element.AcceptVisitor(visitor, null);
elementNode.Update();
}
} else if (collectionNode != null) {
if (MessageBox.Show(("Apply " + name + " to all elements in selected collection '" + collectionNode.Text + "'?"),
"Apply transformation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
foreach (TreeNode subNode in collectionNode.Nodes) {
if (subNode is ElementNode) {
(subNode as ElementNode).element.AcceptVisitor(visitor, null);
}
}
collectionNode.Update();
}
}
}
}
static TreeNode CreateNode(object child)
{
if (child == null) {
return new TreeNode("*null reference*");
} else if (child is INode) {
return new ElementNode(child as INode);
} else {
return new TreeNode(child.ToString());
}
}
class CollectionNode : TreeNode
{
internal IList collection;
string baseName;
public CollectionNode(string text, IList children) : base(text)
{
this.baseName = text;
this.collection = children;
Update();
}
public void Update()
{
if (collection.Count == 0) {
Text = baseName + " (empty collection)";
} else if (collection.Count == 1) {
Text = baseName + " (collection with 1 element)";
} else {
Text = baseName + " (collection with " + collection.Count + " elements)";
}
Nodes.Clear();
foreach (object child in collection) {
Nodes.Add(CreateNode(child));
}
Expand();
}
}
class ElementNode : TreeNode
{
internal INode element;
public ElementNode(INode node)
{
this.element = node;
Update();
}
public void Update()
{
Nodes.Clear();
Type type = element.GetType();
Text = type.Name;
if (Tag != null) { // HACK: after editing property element
Text = Tag.ToString() + " = " + Text;
}
if (!(element is INullable && (element as INullable).IsNull)) {
AddProperties(type, element);
if (element.Children.Count > 0) {
Nodes.Add(new CollectionNode("Children", element.Children));
}
}
}
void AddProperties(Type type, INode node)
{
if (type == typeof(AbstractNode))
return;
foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)) {
if (pi.DeclaringType != type) // don't add derived properties
continue;
if (pi.Name == "IsNull")
continue;
object value = pi.GetValue(node, null);
if (value is IList) {
Nodes.Add(new CollectionNode(pi.Name, (IList)value));
} else if (value is string) {
Text += " " + pi.Name + "='" + value + "'";
} else {
TreeNode treeNode = CreateNode(value);
treeNode.Text = pi.Name + " = " + treeNode.Text;
treeNode.Tag = pi.Name;
Nodes.Add(treeNode);
}
}
AddProperties(type.BaseType, node);
}
}
void TreeKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Delete) {
DeleteSelectedNode();
} else if (e.KeyData == Keys.Space || e.KeyData == Keys.Enter) {
EditSelectedNode();
}
}
}
}

120
samples/NRefactoryDemo/AstView.resx

@ -1,120 +0,0 @@ @@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

112
samples/NRefactoryDemo/EditDialog.Designer.cs generated

@ -1,112 +0,0 @@ @@ -1,112 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2006, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace NRefactoryDemo
{
partial class EditDialog : System.Windows.Forms.Form
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.propertyGrid = new System.Windows.Forms.PropertyGrid();
this.panel1 = new System.Windows.Forms.Panel();
this.okButton = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// propertyGrid
//
this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid.HelpVisible = false;
this.propertyGrid.Location = new System.Drawing.Point(0, 0);
this.propertyGrid.Name = "propertyGrid";
this.propertyGrid.PropertySort = System.Windows.Forms.PropertySort.Alphabetical;
this.propertyGrid.Size = new System.Drawing.Size(477, 436);
this.propertyGrid.TabIndex = 0;
this.propertyGrid.ToolbarVisible = false;
//
// panel1
//
this.panel1.Controls.Add(this.okButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(0, 436);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(477, 38);
this.panel1.TabIndex = 1;
//
// okButton
//
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(390, 6);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 0;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
//
// EditDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.okButton;
this.ClientSize = new System.Drawing.Size(477, 474);
this.Controls.Add(this.propertyGrid);
this.Controls.Add(this.panel1);
this.Name = "EditDialog";
this.Text = "EditDialog";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.PropertyGrid propertyGrid;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Panel panel1;
}
}

42
samples/NRefactoryDemo/EditDialog.cs

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2006, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace NRefactoryDemo
{
public partial class EditDialog
{
public EditDialog(object element)
{
InitializeComponent();
propertyGrid.SelectedObject = element;
}
}
}

120
samples/NRefactoryDemo/EditDialog.resx

@ -1,120 +0,0 @@ @@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

327
samples/NRefactoryDemo/MainForm.Designer.cs generated

@ -1,327 +0,0 @@ @@ -1,327 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2006, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace NRefactoryDemo
{
partial class MainForm : System.Windows.Forms.Form
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.codeTextBox = new System.Windows.Forms.TextBox();
this.astPanel = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.transformationComboBox = new System.Windows.Forms.ComboBox();
this.applyTransformation = new System.Windows.Forms.Button();
this.editNodeButton = new System.Windows.Forms.Button();
this.deleteSelectedNode = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.arrowUpPictureBox = new System.Windows.Forms.PictureBox();
this.arrowDownPictureBox = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.clearSpecialsButton = new System.Windows.Forms.Button();
this.specialsLabel = new System.Windows.Forms.Label();
this.generateVBButton = new System.Windows.Forms.Button();
this.parseVBButton = new System.Windows.Forms.Button();
this.generateCSharpButton = new System.Windows.Forms.Button();
this.parseCSharpButton = new System.Windows.Forms.Button();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.arrowUpPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.arrowDownPictureBox)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.codeTextBox);
this.splitContainer1.Panel1MinSize = 50;
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.astPanel);
this.splitContainer1.Panel2.Controls.Add(this.groupBox2);
this.splitContainer1.Panel2.Controls.Add(this.panel1);
this.splitContainer1.Panel2MinSize = 150;
this.splitContainer1.Size = new System.Drawing.Size(512, 411);
this.splitContainer1.SplitterDistance = 146;
this.splitContainer1.TabIndex = 0;
//
// codeTextBox
//
this.codeTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.codeTextBox.Location = new System.Drawing.Point(0, 0);
this.codeTextBox.Multiline = true;
this.codeTextBox.Name = "codeTextBox";
this.codeTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.codeTextBox.Size = new System.Drawing.Size(512, 146);
this.codeTextBox.TabIndex = 0;
this.codeTextBox.Text = "using System;\r\nclass MainClass\r\n{\r\n // This is the entry method of the applicati" +
"on\r\n public static void Main()\r\n {\r\n Console.WriteLine(\"Hello, World!\");\r\n " +
" }\r\n}";
//
// astPanel
//
this.astPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.astPanel.Location = new System.Drawing.Point(128, 60);
this.astPanel.Name = "astPanel";
this.astPanel.Size = new System.Drawing.Size(384, 201);
this.astPanel.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.transformationComboBox);
this.groupBox2.Controls.Add(this.applyTransformation);
this.groupBox2.Controls.Add(this.editNodeButton);
this.groupBox2.Controls.Add(this.deleteSelectedNode);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Left;
this.groupBox2.Location = new System.Drawing.Point(0, 60);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(128, 201);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Apply transformations";
//
// transformationComboBox
//
this.transformationComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.transformationComboBox.DropDownWidth = 200;
this.transformationComboBox.FormattingEnabled = true;
this.transformationComboBox.Items.AddRange(new object[] {
"CSharpConstructsVisitor",
"ToVBNetConvertVisitor",
"VBNetConstructsConvertVisitor",
"ToCSharpConvertVisitor"});
this.transformationComboBox.Location = new System.Drawing.Point(9, 78);
this.transformationComboBox.Name = "transformationComboBox";
this.transformationComboBox.Size = new System.Drawing.Size(112, 21);
this.transformationComboBox.TabIndex = 2;
//
// applyTransformation
//
this.applyTransformation.Location = new System.Drawing.Point(13, 105);
this.applyTransformation.Name = "applyTransformation";
this.applyTransformation.Size = new System.Drawing.Size(96, 23);
this.applyTransformation.TabIndex = 3;
this.applyTransformation.Text = "Run visitor";
this.applyTransformation.UseVisualStyleBackColor = true;
this.applyTransformation.Click += new System.EventHandler(this.ApplyTransformationClick);
//
// editNodeButton
//
this.editNodeButton.Location = new System.Drawing.Point(9, 49);
this.editNodeButton.Name = "editNodeButton";
this.editNodeButton.Size = new System.Drawing.Size(110, 23);
this.editNodeButton.TabIndex = 1;
this.editNodeButton.Text = "Edit node";
this.editNodeButton.UseVisualStyleBackColor = true;
this.editNodeButton.Click += new System.EventHandler(this.EditNodeButtonClick);
//
// deleteSelectedNode
//
this.deleteSelectedNode.Location = new System.Drawing.Point(9, 20);
this.deleteSelectedNode.Name = "deleteSelectedNode";
this.deleteSelectedNode.Size = new System.Drawing.Size(110, 23);
this.deleteSelectedNode.TabIndex = 0;
this.deleteSelectedNode.Text = "Delete node";
this.deleteSelectedNode.UseVisualStyleBackColor = true;
this.deleteSelectedNode.Click += new System.EventHandler(this.DeleteSelectedNodeClick);
//
// panel1
//
this.panel1.Controls.Add(this.arrowUpPictureBox);
this.panel1.Controls.Add(this.arrowDownPictureBox);
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Controls.Add(this.generateVBButton);
this.panel1.Controls.Add(this.parseVBButton);
this.panel1.Controls.Add(this.generateCSharpButton);
this.panel1.Controls.Add(this.parseCSharpButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(512, 60);
this.panel1.TabIndex = 0;
//
// arrowUpPictureBox
//
this.arrowUpPictureBox.Location = new System.Drawing.Point(404, 3);
this.arrowUpPictureBox.Name = "arrowUpPictureBox";
this.arrowUpPictureBox.Size = new System.Drawing.Size(29, 54);
this.arrowUpPictureBox.TabIndex = 2;
this.arrowUpPictureBox.TabStop = false;
this.arrowUpPictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.ArrowUpPictureBoxPaint);
//
// arrowDownPictureBox
//
this.arrowDownPictureBox.Location = new System.Drawing.Point(123, 3);
this.arrowDownPictureBox.Name = "arrowDownPictureBox";
this.arrowDownPictureBox.Size = new System.Drawing.Size(29, 54);
this.arrowDownPictureBox.TabIndex = 2;
this.arrowDownPictureBox.TabStop = false;
this.arrowDownPictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.ArrowDownPictureBoxPaint);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.clearSpecialsButton);
this.groupBox1.Controls.Add(this.specialsLabel);
this.groupBox1.Location = new System.Drawing.Point(3, -2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(114, 59);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
//
// clearSpecialsButton
//
this.clearSpecialsButton.Location = new System.Drawing.Point(31, 30);
this.clearSpecialsButton.Name = "clearSpecialsButton";
this.clearSpecialsButton.Size = new System.Drawing.Size(75, 23);
this.clearSpecialsButton.TabIndex = 1;
this.clearSpecialsButton.Text = "Clear";
this.clearSpecialsButton.UseVisualStyleBackColor = true;
this.clearSpecialsButton.Click += new System.EventHandler(this.ClearSpecialsButtonClick);
//
// specialsLabel
//
this.specialsLabel.Location = new System.Drawing.Point(6, 16);
this.specialsLabel.Name = "specialsLabel";
this.specialsLabel.Size = new System.Drawing.Size(100, 23);
this.specialsLabel.TabIndex = 0;
this.specialsLabel.Text = "# specials saved";
//
// generateVBButton
//
this.generateVBButton.Location = new System.Drawing.Point(281, 31);
this.generateVBButton.Name = "generateVBButton";
this.generateVBButton.Size = new System.Drawing.Size(117, 23);
this.generateVBButton.TabIndex = 3;
this.generateVBButton.Text = "Generate VB code";
this.generateVBButton.UseVisualStyleBackColor = true;
this.generateVBButton.Click += new System.EventHandler(this.GenerateVBButtonClick);
//
// parseVBButton
//
this.parseVBButton.Location = new System.Drawing.Point(158, 31);
this.parseVBButton.Name = "parseVBButton";
this.parseVBButton.Size = new System.Drawing.Size(117, 23);
this.parseVBButton.TabIndex = 1;
this.parseVBButton.Text = "Parse VB code";
this.parseVBButton.UseVisualStyleBackColor = true;
this.parseVBButton.Click += new System.EventHandler(this.ParseVBButtonClick);
//
// generateCSharpButton
//
this.generateCSharpButton.Location = new System.Drawing.Point(281, 6);
this.generateCSharpButton.Name = "generateCSharpButton";
this.generateCSharpButton.Size = new System.Drawing.Size(117, 23);
this.generateCSharpButton.TabIndex = 2;
this.generateCSharpButton.Text = "Generate C# code";
this.generateCSharpButton.UseVisualStyleBackColor = true;
this.generateCSharpButton.Click += new System.EventHandler(this.GenerateCSharpButtonClick);
//
// parseCSharpButton
//
this.parseCSharpButton.Location = new System.Drawing.Point(158, 6);
this.parseCSharpButton.Name = "parseCSharpButton";
this.parseCSharpButton.Size = new System.Drawing.Size(117, 23);
this.parseCSharpButton.TabIndex = 0;
this.parseCSharpButton.Text = "Parse C# code";
this.parseCSharpButton.UseVisualStyleBackColor = true;
this.parseCSharpButton.Click += new System.EventHandler(this.ParseCSharpButtonClick);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(512, 411);
this.Controls.Add(this.splitContainer1);
this.Name = "MainForm";
this.Text = "NRefactoryDemo";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.arrowUpPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.arrowDownPictureBox)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.Button editNodeButton;
private System.Windows.Forms.ComboBox transformationComboBox;
private System.Windows.Forms.Button applyTransformation;
private System.Windows.Forms.Button deleteSelectedNode;
private System.Windows.Forms.Panel astPanel;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button parseCSharpButton;
private System.Windows.Forms.Button generateCSharpButton;
private System.Windows.Forms.Button parseVBButton;
private System.Windows.Forms.Button generateVBButton;
private System.Windows.Forms.PictureBox arrowUpPictureBox;
private System.Windows.Forms.PictureBox arrowDownPictureBox;
private System.Windows.Forms.Label specialsLabel;
private System.Windows.Forms.Button clearSpecialsButton;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TextBox codeTextBox;
private System.Windows.Forms.SplitContainer splitContainer1;
}
}

162
samples/NRefactoryDemo/MainForm.cs

@ -1,162 +0,0 @@ @@ -1,162 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2006, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.NRefactory.Visitors;
namespace NRefactoryDemo
{
/// <summary>
/// Graphical application to demonstrate NRefactory.
/// </summary>
public partial class MainForm
{
[STAThread]
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
AstView astView = new AstView();
public MainForm()
{
// The InitializeComponent() call is required for Windows Forms designer support.
InitializeComponent();
astView.Dock = DockStyle.Fill;
astPanel.Controls.Add(astView);
ParseCSharpButtonClick(null, null);
transformationComboBox.SelectedIndex = 0;
}
void ClearSpecialsButtonClick(object sender, EventArgs e)
{
SetSpecials(new ISpecial[0]);
}
IList<ISpecial> savedSpecialsList;
void SetSpecials(IList<ISpecial> specialsList)
{
savedSpecialsList = specialsList;
if (specialsList.Count == 1)
specialsLabel.Text = "1 special saved";
else
specialsLabel.Text = specialsList.Count + " specials saved";
}
void ArrowDownPictureBoxPaint(object sender, PaintEventArgs e)
{
Size size = arrowDownPictureBox.Size;
e.Graphics.DrawLine(Pens.Black, size.Width / 2, 0, size.Width / 2, size.Height);
e.Graphics.DrawLine(Pens.Black, 0, size.Height - size.Width / 2, size.Width / 2, size.Height);
e.Graphics.DrawLine(Pens.Black, size.Width - 1, size.Height - size.Width / 2, size.Width / 2, size.Height);
}
void ArrowUpPictureBoxPaint(object sender, PaintEventArgs e)
{
Size size = arrowUpPictureBox.Size;
e.Graphics.DrawLine(Pens.Black, size.Width / 2, 0, size.Width / 2, size.Height);
e.Graphics.DrawLine(Pens.Black, 0, size.Width / 2, size.Width / 2, 0);
e.Graphics.DrawLine(Pens.Black, size.Width - 1, size.Width / 2, size.Width / 2, 0);
}
void ParseCSharpButtonClick(object sender, EventArgs e)
{
Parse(SupportedLanguage.CSharp, codeTextBox.Text);
}
void ParseVBButtonClick(object sender, EventArgs e)
{
Parse(SupportedLanguage.VBNet, codeTextBox.Text);
}
void Parse(SupportedLanguage language, string text)
{
using (IParser parser = ParserFactory.CreateParser(language, new StringReader(text))) {
parser.Parse();
// this allows retrieving comments, preprocessor directives, etc. (stuff that isn't part of the syntax)
SetSpecials(parser.Lexer.SpecialTracker.RetrieveSpecials());
// this retrieves the root node of the result AST
astView.Unit = parser.CompilationUnit;
if (parser.Errors.Count > 0) {
MessageBox.Show(parser.Errors.ErrorOutput, "Parse errors");
}
}
}
void GenerateCSharpButtonClick(object sender, EventArgs e)
{
GenerateCode(new CSharpOutputVisitor());
}
void GenerateVBButtonClick(object sender, EventArgs e)
{
GenerateCode(new VBNetOutputVisitor());
}
void GenerateCode(IOutputAstVisitor outputVisitor)
{
// re-insert the comments we saved from the parser into the output
using (SpecialNodesInserter.Install(savedSpecialsList, outputVisitor)) {
astView.Unit.AcceptVisitor(outputVisitor, null);
}
codeTextBox.Text = outputVisitor.Text.Replace("\t", " ");
}
void DeleteSelectedNodeClick(object sender, EventArgs e)
{
astView.DeleteSelectedNode();
}
void ApplyTransformationClick(object sender, EventArgs e)
{
try {
string typeName = typeof(ToCSharpConvertVisitor).Namespace + "." + transformationComboBox.SelectedItem.ToString();
Type type = typeof(ToCSharpConvertVisitor).Assembly.GetType(typeName);
astView.ApplyTransformation((IAstVisitor)Activator.CreateInstance(type));
} catch (Exception ex) {
MessageBox.Show(ex.ToString(), "Error");
astView.Unit = astView.Unit; // complete refresh
}
}
void EditNodeButtonClick(object sender, EventArgs e)
{
astView.EditSelectedNode();
}
}
}

120
samples/NRefactoryDemo/MainForm.resx

@ -1,120 +0,0 @@ @@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

87
samples/NRefactoryDemo/NRefactoryDemo.csproj

@ -1,87 +0,0 @@ @@ -1,87 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>NRefactoryDemo</RootNamespace>
<AssemblyName>NRefactoryDemo</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63199047-9D5D-474C-B3CC-62ABBB071B67}</ProjectGuid>
<SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs" />
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="AstView.Designer.cs">
<DependentUpon>AstView.cs</DependentUpon>
</Compile>
<Compile Include="AstView.cs" />
<EmbeddedResource Include="AstView.resx">
<DependentUpon>AstView.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="EditDialog.Designer.cs">
<DependentUpon>EditDialog.cs</DependentUpon>
</Compile>
<Compile Include="EditDialog.cs" />
<EmbeddedResource Include="EditDialog.resx">
<DependentUpon>EditDialog.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

18
samples/NRefactoryDemo/NRefactoryDemo.sln

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

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.5571
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryDemo", "NRefactoryDemo.csproj", "{63199047-9D5D-474C-B3CC-62ABBB071B67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63199047-9D5D-474C-B3CC-62ABBB071B67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63199047-9D5D-474C-B3CC-62ABBB071B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63199047-9D5D-474C-B3CC-62ABBB071B67}.Release|Any CPU.Build.0 = Release|Any CPU
{63199047-9D5D-474C-B3CC-62ABBB071B67}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

2
src/Automated.proj

@ -119,8 +119,6 @@ @@ -119,8 +119,6 @@
Properties="Configuration=Release;BranchName=$(BranchName)"/>
<MSBuild Projects="$(SamplesSrc)\NAnt\NAnt.AddIn.sln"
Properties="Configuration=Release;BranchName=$(BranchName)"/>
<MSBuild Projects="$(SamplesSrc)\NRefactoryDemo\NRefactoryDemo.sln"
Properties="Configuration=Release;BranchName=$(BranchName)"/>
<MSBuild Projects="$(SamplesSrc)\PInvokeAddIn\PInvokeAddIn.sln"
Properties="Configuration=Release;BranchName=$(BranchName)"/>
<MSBuild Projects="$(SamplesSrc)\SdaUser\SdaUser.sln"

Loading…
Cancel
Save