This moves a bit of logic into a base type to prevent lots of duplicates. I've only converted csharp and aspnet5 generators, not csharp 2.0. This base class should provide enough flexibility to support other C# based client and server generators.