forked from dotnet/aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
add dotnet new templates (razor view, api controller, mvc controller) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d374607
added razor view
deepchoudhery f237032
fix identity for razor view item template
deepchoudhery 48ff1ac
added api controller
deepchoudhery b8d46e5
fixed api, added mvc controller
deepchoudhery aac33ae
pr comment fixes
deepchoudhery fa429cb
PR comment fixes 2
deepchoudhery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...ectTemplates/Web.ItemTemplates/content/ApiController/.template.config/dotnetcli.host.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/dotnetcli.host" | ||
} |
9 changes: 9 additions & 0 deletions
9
...Web.ItemTemplates/content/ApiController/.template.config/localize/templatestrings.en.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"author": "Microsoft", | ||
"name": "API Controller", | ||
"description": "API Controller with or without read/write actions", | ||
"symbols/namespace/description": "namespace for the generated code", | ||
"symbols/actions/description": "create controller with read/write actions", | ||
"symbols/actions/displayName": "Add ReadWrite Actions", | ||
"postActions/openInEditor/description": "Opens ValueController.cs in the editor" | ||
} |
58 changes: 58 additions & 0 deletions
58
src/ProjectTemplates/Web.ItemTemplates/content/ApiController/.template.config/template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": [ "Web", "ASP.NET" ], | ||
"name": "API Controller", | ||
"generatorVersions": "[1.0.0.0-*)", | ||
"description": "API Controller with or without read/write actions", | ||
"tags": { | ||
"language": "C#", | ||
"type": "item" | ||
}, | ||
"groupIdentity": "Microsoft.AspNetCore.Mvc.ApiController", | ||
"precedence": "9800", | ||
"identity": "Microsoft.AspNetCore.Mvc.ApiController.8.0", | ||
"shortName": "apicontroller", | ||
"sourceName": "ValueController", | ||
"primaryOutputs": [ | ||
{ | ||
"path": "ValueController.cs" | ||
} | ||
], | ||
"defaultName": "ValueController", | ||
"symbols": { | ||
"namespace": { | ||
"description": "namespace for the generated code", | ||
"replaces": "MyApp.Namespace", | ||
"type": "parameter" | ||
}, | ||
"actions": { | ||
"description": "create controller with read/write actions", | ||
"displayName": "Add ReadWrite Actions", | ||
"type": "parameter", | ||
"datatype": "bool", | ||
"defaultValue": "false" | ||
}, | ||
"HostIdentifier": { | ||
"type": "bind", | ||
"binding": "HostIdentifier" | ||
}, | ||
"NameIsController": { | ||
"type": "computed", | ||
"value": "(name == \"ControllerBase\")" | ||
} | ||
}, | ||
"postActions": [ | ||
{ | ||
"id": "openInEditor", | ||
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", | ||
"description": "Opens ValueController.cs in the editor", | ||
"manualInstructions": [ ], | ||
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", | ||
"args": { | ||
"files": "0" | ||
}, | ||
"continueOnError": true | ||
} | ||
] | ||
} |
48 changes: 48 additions & 0 deletions
48
src/ProjectTemplates/Web.ItemTemplates/content/ApiController/ValueController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace MyApp.Namespace | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
#if NameIsController | ||
public class ValuesController : Microsoft.AspNetCore.Mvc.ControllerBase | ||
#else | ||
public class ValuesController : ControllerBase | ||
#endif | ||
{ | ||
#if(actions) | ||
// GET: api/<ValuesController> | ||
[HttpGet] | ||
public IEnumerable<string> Get() | ||
{ | ||
return new string[] { "value1", "value2" }; | ||
} | ||
|
||
// GET api/<ValuesController>/5 | ||
[HttpGet("{id}")] | ||
public string Get(int id) | ||
{ | ||
return "value"; | ||
} | ||
|
||
// POST api/<ValuesController> | ||
[HttpPost] | ||
public void Post([FromBody] string value) | ||
{ | ||
} | ||
|
||
// PUT api/<ValuesController>/5 | ||
[HttpPut("{id}")] | ||
public void Put(int id, [FromBody] string value) | ||
{ | ||
} | ||
|
||
// DELETE api/<ValuesController>/5 | ||
[HttpDelete("{id}")] | ||
public void Delete(int id) | ||
{ | ||
} | ||
#endif | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ectTemplates/Web.ItemTemplates/content/MvcController/.template.config/dotnetcli.host.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/dotnetcli.host" | ||
} |
9 changes: 9 additions & 0 deletions
9
...Web.ItemTemplates/content/MvcController/.template.config/localize/templatestrings.en.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"author": "Microsoft", | ||
"name": "MVC Controller", | ||
"description": "MVC Controller with or without read/write actions", | ||
"symbols/namespace/description": "namespace for the generated code", | ||
"symbols/actions/description": "create controller with read/write actions", | ||
"symbols/actions/displayName": "Add ReadWrite Actions", | ||
"postActions/openInEditor/description": "Opens HomeController.cs in the editor" | ||
} |
58 changes: 58 additions & 0 deletions
58
src/ProjectTemplates/Web.ItemTemplates/content/MvcController/.template.config/template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": [ "Web", "ASP.NET" ], | ||
"name": "MVC Controller", | ||
"generatorVersions": "[1.0.0.0-*)", | ||
"description": "MVC Controller with or without read/write actions", | ||
"tags": { | ||
"language": "C#", | ||
"type": "item" | ||
}, | ||
"groupIdentity": "Microsoft.AspNetCore.Mvc.MvcController", | ||
"precedence": "9800", | ||
"identity": "Microsoft.AspNetCore.Mvc.MvcController.8.0", | ||
"shortName": "mvccontroller", | ||
"sourceName": "HomeController", | ||
"primaryOutputs": [ | ||
{ | ||
"path": "HomeController.cs" | ||
} | ||
], | ||
"defaultName": "HomeController", | ||
"symbols": { | ||
"namespace": { | ||
"description": "namespace for the generated code", | ||
"replaces": "MyApp.Namespace", | ||
"type": "parameter" | ||
}, | ||
"actions": { | ||
"description": "create controller with read/write actions", | ||
"displayName": "Add ReadWrite Actions", | ||
"type": "parameter", | ||
"datatype": "bool", | ||
"defaultValue": "false" | ||
}, | ||
"HostIdentifier": { | ||
"type": "bind", | ||
"binding": "HostIdentifier" | ||
}, | ||
"NameIsController": { | ||
deepchoudhery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"type": "computed", | ||
"value": "(name == \"Controller\")" | ||
} | ||
}, | ||
"postActions": [ | ||
{ | ||
"id": "openInEditor", | ||
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", | ||
"description": "Opens HomeController.cs in the editor", | ||
deepchoudhery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"manualInstructions": [ ], | ||
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", | ||
"args": { | ||
"files": "0" | ||
}, | ||
"continueOnError": true | ||
} | ||
] | ||
} |
88 changes: 88 additions & 0 deletions
88
src/ProjectTemplates/Web.ItemTemplates/content/MvcController/HomeController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace MyApp.Namespace | ||
{ | ||
#if NameIsController | ||
public class HomeController : Microsoft.AspNetCore.Mvc.Controller | ||
#else | ||
public class HomeController : Controller | ||
#endif | ||
{ | ||
// GET: HomeController | ||
public ActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
#if(actions) | ||
// GET: HomeController/Details/5 | ||
public ActionResult Details(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// GET: HomeController/Create | ||
public ActionResult Create() | ||
{ | ||
return View(); | ||
} | ||
|
||
// POST: HomeController/Create | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Create(IFormCollection collection) | ||
{ | ||
try | ||
{ | ||
return RedirectToAction(nameof(Index)); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
|
||
// GET: HomeController/Edit/5 | ||
public ActionResult Edit(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// POST: HomeController/Edit/5 | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Edit(int id, IFormCollection collection) | ||
{ | ||
try | ||
{ | ||
return RedirectToAction(nameof(Index)); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
|
||
// GET: HomeController/Delete/5 | ||
public ActionResult Delete(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// POST: HomeController/Delete/5 | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Delete(int id, IFormCollection collection) | ||
{ | ||
try | ||
{ | ||
return RedirectToAction(nameof(Index)); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
#endif | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ProjectTemplates/Web.ItemTemplates/content/RazorView/.template.config/dotnetcli.host.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/dotnetcli.host" | ||
} |
6 changes: 6 additions & 0 deletions
6
...tes/Web.ItemTemplates/content/RazorView/.template.config/localize/templatestrings.en.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"author": "Microsoft", | ||
"name": "Razor View", | ||
"description": "A Razor view without a page model", | ||
deepchoudhery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"postActions/openInEditor/description": "Opens Index.cshtml in the editor" | ||
deepchoudhery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/ProjectTemplates/Web.ItemTemplates/content/RazorView/.template.config/template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": [ "Web", "ASP.NET" ], | ||
"name": "Razor View", | ||
"generatorVersions": "[1.0.0.0-*)", | ||
"description": "Am empty razor view", | ||
"tags": { | ||
"language": "C#", | ||
"type": "item" | ||
}, | ||
"groupIdentity": "Microsoft.AspNetCore.Mvc.RazorView", | ||
"precedence": "9800", | ||
"identity": "Microsoft.AspNetCore.Mvc.RazorView.8.0", | ||
"shortName": "view", | ||
deepchoudhery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"sourceName": "Index", | ||
"primaryOutputs": [ | ||
{ "path": "Index.cshtml" } | ||
], | ||
"defaultName": "Index", | ||
"symbols": { | ||
"HostIdentifier": { | ||
"type": "bind", | ||
"binding": "HostIdentifier" | ||
} | ||
}, | ||
"postActions": [ | ||
{ | ||
"id": "openInEditor", | ||
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", | ||
"description": "Opens Index.cshtml in the editor", | ||
deepchoudhery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"manualInstructions": [ ], | ||
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", | ||
"args": { | ||
"files": "0" | ||
}, | ||
"continueOnError": true | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
src/ProjectTemplates/Web.ItemTemplates/content/RazorView/Index.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@* | ||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 | ||
*@ | ||
@{ | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.