KreativJos / csharpextensions

C# Extensions for Visual Studio Code
MIT License
73 stars 35 forks source link

Added most common using statements in templates #35

Closed YoussefWaelMohamedLotfy closed 3 years ago

YoussefWaelMohamedLotfy commented 3 years ago

Added in APIController, Class, and Interface for simplifing the coding task.

KreativJos commented 3 years ago

Seems like a good idea. But it changes the current default. Personally, I think it is a good change, but it would be nice to have an option for it. Could you add that? It should be something like this (should be enough):

package.json - configuration

"csharpextensions.includeNamespaces": {
    "type": "boolean",
    "default": true,
    "description": "If created classes should include default namespaces"
}

extension.ts - openTemplateAndSaveNewFile, after let text = etc:

const includeNamespaces = vscode.workspace.getConfiguration().get('csharpextensions.includeNamespaces', true);

if (includeNamespaces) {
    text = text.replace('${namespaces}', `using System;${EOL}using System.Collections.Generic;${EOL}using System.Linq;${EOL}using System.Threading.Tasks;`)
}

And then replace the added namespaces in the templates with ${namespaces}.

YoussefWaelMohamedLotfy commented 3 years ago

Kindly check the new additions as you requested. I hope all is correct.

KreativJos commented 3 years ago

So, Is the new release ready after these changes?

If the issues are resolved and the pull-request is merged, I will create a new release. That just takes me a few minutes. I can merge it if it is a working version, with the option for users to switch back to the current way it works.

KreativJos commented 3 years ago

Resolved via #38