![]() |
|
[C#] [Tut]Make your own simple C# Compiler - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] [Tut]Make your own simple C# Compiler (/showthread.php?tid=1268612) |
[Tut]Make your own simple C# Compiler - BaussHacker - May 4, 2011 First of all create a new form. Then we need to set it up simple. First thing we do is making a panel. Drag the panel to the form and set the dock to "Top". Drag a toolstrip into the panel. Now drag another panel into the form and set the dock to "Right". And then a last panel into our form. The dock of that should be "Fill". It should look something like this now: Spoiler (Click to View) The next thing we do is dragging a tabcontrol into the panel3. Delete the 2tabs it have and make the dock "Fill". Now in the panel2 put a label, a textbox, 2 radiobuttons and a listbox. The label should have the text "Assembly name". The first radiobutton should have the text "Class Library" and it should be checked. The second should have the text "Console application". The listbox should have dock to "Bottom". Now it should look something like this: Spoiler (Click to View) The next thing we do is adding a 2 dropdowns to our toolstrip. One called "File" and one called "Project". Set the File displaystyle to "Text". Make sure ShowDropDownArrow is set to "false". Following dropdownitems should be added. Code New FileSet the Project displaystyle to "Text". Make sure Make sure ShowDropDownArrow is set to "false". Following dropdownitems should be added. Code Compile And RunIt should all look like this now: Spoiler (Click to View) Now the base GUI is done and we will start on the coding. First thing we do is adding the "New File". Double click on it and you should get this code: Code private void newFileToolStripMenuItem_Click(object sender, EventArgs e)Replace it with: Code private void newFileToolStripMenuItem_Click(object sender, EventArgs e)Now we can create new files. Now click on the Open File. You should get this code: Code private void openFileToolStripMenuItem_Click(object sender, EventArgs e)Replace it with: Code private void openFileToolStripMenuItem_Click(object sender, EventArgs e)Now click the Save File and you should get this code: Code private void saveFileToolStripMenuItem_Click(object sender, EventArgs e)Replace it with: Code private void saveFileToolStripMenuItem_Click(object sender, EventArgs e)Now go to the dropdown Project and click on Add Reference. You should get this code: Code private void addReferenceToolStripMenuItem_Click(object sender, EventArgs e)Replace it with: Code private void addReferenceToolStripMenuItem_Click(object sender, EventArgs e)Now make a new class and call it Compiler. Replace it all with this: Code using System;If you want to get all the errors throwing at the compilation, then use results.Errors. You can make a textbox at the bottom of your IDE which can show the errors. The same goes for output. Now we just need to make the compilation done. Click on the Compile And Run. You should get this code: Code private void compileAndRunToolStripMenuItem_Click(object sender, EventArgs e)Replace it with: Code private void compileAndRunToolStripMenuItem_Click(object sender, EventArgs e)Now click on the Compile Only and you should get this code: Code private void compileOnlyToolStripMenuItem_Click(object sender, EventArgs e)Replace it with: Code private void compileOnlyToolStripMenuItem_Click(object sender, EventArgs e)Now you have your own simple C# Compiler. I hope you liked it and find it useful. 🤝 * - MaxPain - May 4, 2011 Awesome Idea And Great Job As Always BauussHacker * - BaussHacker - May 4, 2011 Thank you for the feedback :) #Edit If anybody needs help or anything with adding new features etc. Let me know. * - Logic_Bomber - May 4, 2011 Good tutorial thanks for sharing dude! * - BaussHacker - May 4, 2011 (May 4, 2011 02:01 PM)Logic_Bomber Wrote: Good tutorial thanks for sharing dude! Thank you a lot. Finally someone replied, is there anything I should add, edit or remove? 😉 * - Logic_Bomber - May 5, 2011 I'm not sure but i will show it to a couple of friends and ask them if they think u should add anything * - tflo - May 5, 2011 Lol look at this: http://www.elitepvpers.de/forum/co2-programming/1163559-tut-make-your-own-simple-c-compiler.html. * - Redeemz - May 5, 2011 Great work as always! Keep it up this was a good, useful idea. I will not be making one, but there are things in here i can reference later on for future projects :) * - Zer0Fact0r - May 5, 2011 What you can improve? Your code in general. It's quite horrid. Also in case anyone gets the wrong idea, you're not actually making a compiler. You're just making your own editor that uses Microsoft's C# compiler. * - Odinbiorn - Jul 23, 2011 Very interesting. Perhaps you are not getting many replies per views due to the title being miss-leading. I apologise if I am wrong, but would this not be creating your own IDE, rather than compiler? I notice you use Codedom in this, would it be possible for you to create a tutorial on using codedom? (very interesting tool that I can't find much documentation for which is not for vb.net) * - Ethereal - Jul 23, 2011 (Jul 23, 2011 02:56 AM)Odinbiorn Wrote: Very interesting. Yes, you are right, but you are also gravedigging. |