So I understand this may appear to be a strange question but I couldnt really find any information on this (maybe I was searching for the wrong thing)
I have a selection of code snippets ive created in visual studio. The snippets work great but what I want to do is to build some sort of code builder addin that will create the .CS files in the project based on several inputs.
Its for use with Selenium in C# to essentially build up a page object model. So for example the user would choose and object they want to add to the page from a dropdown, then click add, and it would add it to the c# code.
Can I create an addin for this and if so wheres the best place to read on up on how to do this, any useful tutorials are articles would be helpful.
Any help would be much appreciated.
Your question is off topic for asking for tutorials, however there are two ways to do what you are looking for.
COM based plugins and T4 code template generators.
The COM plugin kind is if you want a code generator that you expect to use over and over again across all projects you write. They might be "easier" to write as you are just writing C# code but the plugin must be "installed" in to visual studio and if you give the project to someone else the plugin does not travel with the project. The recipient would also need to "install" your plugin to get it to compile on his machine.
The T4 style lets you write the code generation code right inside your project but has a odd syntax, It is fairly similar to how ASP.NET .cshtml pages are generated, you just are generating compliable code instead of a web page. The editor for T4 templates built in to visual studio is not very good, I don't think it even does code highlighting, but there are plugins for visual studio you can get that add more features to the T4 Editor. I have used this one in the past, but a lot of the features are restricted if you do not use the paid version. There are other fully free ones out there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With