Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
morofatwork committed Sep 18, 2022
1 parent 8938c45 commit 116dc84
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"onCommand:csharpextensions.createClass",
"onCommand:csharpextensions.createEnum",
"onCommand:csharpextensions.createInterface",
"onCommand:csharpextensions.createRestController"
"onCommand:csharpextensions.createRestController",
"onCommand:csharpextensions.createBasicRestController"
],
"main": "./dist/extension",
"contributes": {
Expand All @@ -57,6 +58,10 @@
"command": "csharpextensions.createRestController",
"title": "Rest Controller"
},
{
"command": "csharpextensions.createBasicRestController",
"title": "Basic Rest Controller"
},
{
"command": "csharpextensions.createXUnitTest",
"title": "XUnit Test"
Expand All @@ -80,6 +85,10 @@
"group": "10_mvc@1",
"command": "csharpextensions.createRestController"
},
{
"group": "10_mvc@1",
"command": "csharpextensions.createBasicRestController"
},
{
"group": "30_test@0",
"command": "csharpextensions.createXUnitTest"
Expand Down
21 changes: 18 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ export class Extension {
return this.currentVscodeExtension;
}

/**
* The key will be the template filename
*
* @static
* @return {*} {Map<string, Template>}
* @memberof Extension
*/
static getknownTemplates(): Map<string, Template> {
if (this.knownTemplates) {
return this.knownTemplates;
Expand All @@ -178,13 +185,21 @@ export class Extension {
.set('interface', new CSharpTemplate('Interface', 'createInterface'))
.set('enum', new CSharpTemplate('Enum', 'createEnum'))
.set(
'apicontroller',
new CSharpTemplate('ApiController', 'createRestController', [
'restcontroller',
new CSharpTemplate('RestController', 'createRestController', [
'Microsoft.AspNetCore.Mvc',
'Microsoft.Extensions.Logging',
'Microsoft.AspNetCore.Http',
'System',
'System.Collections.Generic'
'System.Collections.Generic',
])
)
.set(
'basicrestcontroller',
new CSharpTemplate('BasicRestController', 'createBasicRestController', [
'Microsoft.AspNetCore.Mvc',
'Microsoft.Extensions.Logging',
'Microsoft.AspNetCore.Http',
])
)
.set('xunit', new CSharpTemplate('XUnit', 'createXUnitTest', ['XUnit']));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
${namespaces}namespace ${namespace}
{
[ApiController]
[ApiController]
[Route("api/[controller]")]
public sealed class ${classname} : ControllerBase
{
Expand All @@ -13,4 +13,4 @@ ${namespaces}namespace ${namespace}
_logger = logger;
}
}
}
}
2 changes: 1 addition & 1 deletion templates/enum.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ${namespaces}namespace ${namespace}
{
${cursor}
}
}
}
2 changes: 1 addition & 1 deletion templates/interface.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ${namespaces}namespace ${namespace}
{
${cursor}
}
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion templates/xunit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ${namespaces}namespace ${namespace}
Assert.True(true);${cursor}
}
}
}
}

0 comments on commit 116dc84

Please sign in to comment.