Sublime is Sublime 10 | Greg Young
Ok we have been moving right along through the sublime features and getting setup for .net development. I have been half saving the next few posts deliberately until the end as they will be covering the largest arguments I hear against the use of other editors than VS when dealing with .NET code.
But my team uses Visual Studio, I can’t just give up on using project/solution files and use some hipster editor.
This has for a long time been the single largest hurdle in using non-VS editors. If you want to get an idea of how bad it is and you have been following along the posts, try adding a file to a project or reference another project in Sublime. Ouch manually editing project files. How do you know that your manual edit will work when opened in Visual Studio?
To be fair even if it took you 15 seconds per file/reference that you added in Sublime the overall time on the project would be minimal but it is a serious pain in the ass. Nothing makes you feel slower than having to manually edit xml that was automatically done for you previously.
To get some of this functionality we will install a new tool though a whole new tool is not really needed for this. It could be done with some basic shell scripts. The tool is OpenIDE by @ackenpacken. OpenIDE does a whole lot more than what we need it to. I have been chatting with him recently about maybe making it more modular hell even Mighty Moose is contained within it as of now.
OpenIDE supports some of the generic things you would want when working with .NET code. The ability to edit project/solution files. The ability to handle templating for new additions. Reference management. There are also some other tools out there as well such as omnisharp https://github.com/nosami/Omnisharp but I fear all of them are too complex and not modular enough as there hasn’t been much of a push for that kind of tooling. Part of this post series is to help mold demand for these kinds of tools.
Now for OpenIDE install. You can grab the sources for OpenIDE here https://github.com/continuoustests/OpenIDE. Svein has recently added a binary repository here https://github.com/continuoustests/OpenIDE.binaries.git. Pull the binaries repository or build from sources. Put the output into your $PATH. OpenIDE also comes with bash completion if you want to install it which can help greatly! Now you are good to start.
Let’s make sure OpenIDE works: oi
You should get help.
oi package install C-Sharp
In the root of your project type oi init C#
Now oi is setup and ready to go. From the command line let’s try
greg@goblin:~/src/EventStore/src/EventStore$ oi new class esquery/bar Created class esquery.bar Full path /home/greg/src/EventStore/src/EventStore/esquery/bar.cs
Note that I did not put bar.cs just esquery/bar and yes you get tab completion on this.
If I now look at what changed.
greg@goblin:~/src/EventStore/src/EventStore$ git status # On branch dev # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: esquery/esquery.csproj # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # esquery/bar.cs
greg@goblin:~/src/EventStore/src/EventStore$ git diff esquery/esquery.csproj diff --git a/src/EventStore/esquery/esquery.csproj b/src/EventStore/esquery/esqu index dec282f..9f3c95f 100644 --- a/src/EventStore/esquery/esquery.csproj +++ b/src/EventStore/esquery/esquery.csproj @@ -84,6 +84,7 @@ <Compile Include="CommandProcessor.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="bar.cs" /> </ItemGroup> <ItemGroup> <None Include="app.config" />
You can also run this command directly inside of sublime. Just use ctrl+shift+c and type in your command. This is just the beginning though. OpenIDE and such tools can support most of your integration with things like project/solution files.