Giter VIP home page Giter VIP logo

scaffolding's Introduction

Scaffolding

This repository contains the code for the following features.

ASP.NET Scaffolding

ASP.NET scaffolding: this can be used to generate boilerplate code for web apps to improve developer productivity

For more info on ASP.NET scaffolding, see the scaffolding readme here at README

dotnet msidentity

This is a .NET tool which can be used to configure ASP.NET Core projects to use the Microsoft identity platform. The tool can be used to configure ASP.NET Core projects to authenticate with the Microsoft identity platform.

For more info on the dotnet msidentity tool, see the readme here at README

Reporting security issues and bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Related projects

These are some other repos for related projects:

Code of conduct

See CODE-OF-CONDUCT

scaffolding's People

Contributors

ajaybhargavb avatar ajcvickers avatar aspnetci avatar brennanconroy avatar bricelam avatar chengtian avatar davidfowl avatar deepchoudhery avatar dotnet-maestro[bot] avatar dougbu avatar eilon avatar haok avatar juntaoluo avatar kichalla avatar mikeharder avatar natemcmaster avatar ntaylormullen avatar pakrym avatar pradeepkadubandi avatar prafullbhosale avatar pranavkm avatar ryanbrandenburg avatar rynowak avatar scottaddie avatar seancpeters avatar tlmii avatar troydai avatar vijayrkn avatar yecril71pl avatar zahalzel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scaffolding's Issues

Scaffolding readme should probably change to reflect the new structure of Startup class

Currently when I scaffold on an empty project, I receive the following read me text...

Couple of things:

  • I think this should reflect the new Startup class setup of Configure, ConfigureServices to make it more clear...
  • Also should StaticFiles middleware be registered before MVC?
Scaffolding has generated all the files and added the required dependencies.

However the Application's Startup code may required additional changes for things to work end to end.

Add the following namespace usings if not already added:

using Microsoft.AspNet.Routing;
using Microsoft.Framework.DependencyInjection;

Add the following code to the end of Configure method in your Application's Startup class if not already done:

            // Set up application services
            app.UseServices(services =>
            {
                // Add MVC services to the services container
                services.AddMvc();

            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

Suggestion:List the files that were added by a K gen command.

After running K gen command..

We should get some logging like:

K gen controller -m Person -dc PersnContext
Added controller 'Conroller\PersonController.cs'
Added database context file 'Model\PersonCOntext'
Added View \Views\Person\Create.cshtml
.
.
.

error compiling sources

Hi,
I just updated the repository clone, added to a custom scaffolders solution and tried recompiled, but I receive several errors

3>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AspNet\Microsoft.Web.AspNet.targets(143,5): error : Initiate build in the design time host failed with the following error: Could not load file or assembly 'a1bdf404-2a84-4219-84c6-6f06386d4d7a$Microsoft.Framework.Runtime.Roslyn' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))
6>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AspNet\Microsoft.Web.AspNet.targets(143,5): error : Initiate build in the design time host failed with the following error: Could not load file or assembly '8147ab57-b6e5-4219-9b53-c2a54be0e337$Microsoft.Framework.Runtime.Roslyn' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))

5>D:\Sorgenti\VNext\Scaffolders\ScaffoldingSourceRoot\Microsoft.Framework.CodeGeneration.Common\CommonUtilities.cs(36,52): ASP.NET 5.0 error CS0012: The type 'ImmutableArray<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
5>D:\Sorgenti\VNext\Scaffolders\ScaffoldingSourceRoot\Microsoft.Framework.CodeGeneration.Common\CommonUtilities.cs(36,52): ASP.NET Core 5.0 error CS0012: The type 'ImmutableArray<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

and so on

Make scaffolding work as nuget packages

2 things need to happen for this:

  • We need changes to make the scaffolding packages to package content (templates)
  • Code changes necessary to get the template folder locations from nuget package location

CTP3: k gen and k gen --help/ kgen -? to provide some information to user.

K Gen >> This should list all the Scaffolders that are available.
Something like:
/* Here is the list of scaffolders that you have. Try K gen --help for more options */
Bug

K gen- help/ k gen --help /K gen -? should provide some generic help on KGen.

Example: try Kgen View -? or K gen controller -? for more specific help.

CTP3: System.InvalidOperationException surfaced to user when view file alreday exists.

Command:
D:\school\MVC6\MVC6>k gen view create create1.cshtml.cshtml -m Person -dc Person
ContextTest

ACTUAL:
System.InvalidOperationException: There was an error running the GenerateCode me
thod: View file D:\school\MVC6\MVC6\Views\Person\create.cshtml exists, use -f op
tion to overwrite
at Microsoft.Framework.CodeGeneration.ActionInvoker.b__1()
at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Exec
ute(String[] args)
at Microsoft.Framework.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.Framework.CodeGeneration.Program.Main(String[] args)

EXPECTED: The message to be like:
There was an error running the GenerateCode method: View file D:\school\MVC6\MVC6\Views\Person\create.cshtml exists, use -f option to overwrite

Review if a package description is required for these packages

Scaffolding\src\Microsoft.Framework.CodeGeneration
Scaffolding\src\Microsoft.Framework.CodeGeneration.Common
Scaffolding\src\Microsoft.Framework.CodeGeneration.Core
Scaffolding\src\Microsoft.Framework.CodeGeneration.EntityFramework
Scaffolding\src\Microsoft.Framework.CodeGeneration.Templating
Scaffolding\src\Microsoft.Framework.CodeGenerators.Mvc

Use the new helper method HttpNotFound instead of using HttpStatusCodeResult

Currently when I scaffold a controller, I see the following...we can change all the references to new HttpStatusCodeResult(404); byreturn HttpNotFound(); instead...

// GET: Person/Details/5
public IActionResult Details(System.Int32? id)
{
    if (id == null)
    {
        return new HttpStatusCodeResult(404);
    }

    Person person = _db.Person.Single(m => m.Id == id);
    if (person == null)
    {
        return new HttpStatusCodeResult(404);
    }

    return View(person);
}

Let the scaffolded view's layout take the default one

Currently when I scaffold a controller, the generated views have the Layout explicitly set to null like below...

@model IEnumerable<WebApplication7.Models.Person>

@{
    Layout = null;
}

Since the layout could possibly be set by _ViewStart.cshtml, we could just avoid this explicit setting enabling the views to take the styling etc. provided by the layout that the viewstart provides...

CTP4: Adding a model w/o the namespace gives errors.

ACTUAL: C:\school\EmptyTest2\Src\EmptyTest2>k gen controller -m Student -dc StudentConte
xt
There was an error running the GenerateCode method: There was an error creating
a DbContext :(3,7): error CS1001: Identifier expected
(3,7): error CS1002: ; expected
(3,7): error CS1022: Type or namespace definition, or end-of-file expected
(3,8): error CS0116: A namespace cannot directly contain members such as fields
or methods
(3,24): error CS1001: Identifier expected
(3,24): error CS1514: { expected
(3,25): error CS1022: Type or namespace definition, or end-of-file expected
(28,6): error CS1513: } expected

EXPECTED: It to work w/o the namespace name.

Remove REST style route from ScaffoldingReadMe.txt

I tried scaffolding on an Empty project and following is the read-me that gets generated

Remove the following REST style route as currently we do not support REST style from conventional routing and expect users to use attribute routing instead..

routes.MapRoute(
name: "api",
template: "{controller}/{id?}");

SaccfoldingReadMe.txt

Scaffolding has generated all the files and added the required dependencies.

However the Application's Startup code may required additional changes for things to work end to end.

Add the following namespace usings if not already added:

using Microsoft.AspNet.Routing;
using Microsoft.Framework.DependencyInjection;

Add the following code to the end of Configure method in your Application's Startup class if not already done:

            // Set up application services
            app.UseServices(services =>
            {
                // Add MVC services to the services container
                services.AddMvc();

            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

support for github, npm and bower

Hi all,
Has been planned support to integrated download source from github repositories and add packages to npm, bower and grunt config files when writing scaffolders? I seen several yeoman generators (mean.io) that start downloading files grom github: the main advantage in hosting sources in github is that I can see changes when a new version is uploaded.

CTP3: Update the behaviour of -l and -ul flags

  1. K gen controller -m Person -dc PersonContext -L layoutPage.cshtml
    -L, should imply use layout(-ul)
  2. K gen controller -m Person -dc PersonContext

When there is NO UL or L falg psassed. Then e should set layout to Null.

  1. K gen controller -m Person -dc PersonContext - ul

Set the layout page to empty in this case.

Suggestion: We should give the option to specify the output folder in which the generated files should go.

Scenario description:

  1. I create a Controller by name Person1 based off a model Person w/o Views. This will Create Person1Controller.
  2. Now, I want to generate Views. These have to go to a specific folder Vises\Person1.
  3. The only Option I have now is to go to Views\Person1 and then do K gen. But K gen is NOT supported here :-).

OR

We can give
K gen View create -m Person -dc PersonContext -outputFolder "View\Person1"

how can I debug it?

Hi,
I would like to debug to understand better how it works, but I don't userstand very well how can I start it so I can debug with vs.
Selection the .CodeGeneration project and debug tells me that there are not generators installed.
I created a webapp application, I added the reference in the project.json using
"Microsoft.Framework.CodeGenerators.Mvc": ""
so I suppose is trying to use the local package in the solution.
If I try to run K gen .... I'm not able to debug it.
Am I missing something?

Luca

CTP4: Handle cases where dbcontext is not present in an EMpty MVC app.

Actual: There was an error running the GeneratedCode: Scaffolding will not be able to add a new DBContext if the application does not refrence ENtityFramework.SqlServer pachage, add a dependency to that package and try scaffolding again.

Expected: This dependency to be added automatically as the command is run.

Scaffolding: Add success messeges

Right after scaffolding a model or vm, when the create or edit forms are submitted successfully and request is redirected to the Index view, there is no success message displayed.

In Ruby (sometimes) on Rails, there is a div id='notice' in the default layout which displays the status of the previous transaction and scaffold complements its existence by saying flash[:notice] = "#{model_name} successfully created", where flash[:notice] is roughly equals to ViewBag["notice"].

Please consider introducing similar pattern to vNext.

Thanks!

Preview: Fix up create.cshtml generated file

  1. Add a model Person to default starter web.

    public class Person
    {
    public int Id { get; set; }
    public string lastname { get; set; }
    }

  2. Do K gen controller -m Person -dc Personctxt.

  3. This generated controller and Views

  4. Verify the contents in Views\Create.cshtml file
    ACTUAL: Look at the contents in view\create.cshtml file. This has an ID label added. We did not generate this in Dev12.

EXECTED: The Id to be not there:

@


@Html.LabelFor(model => model.Id, htmlAttributes: new { @Class = "control-label col-md-2" })

@Html.EditorFor(model => model.Id, new { htmlAttributes = new { @Class = "form-control" } })
@Html.ValidationMessageFor(model => model.Id, "", new { @Class = "text-danger" })

@

Controller uses wrong namespace name

Current implementation for controller uses the app name of model type as the assembly name (This is not right in the scenario where you are running k gen on a TestWebApp but the model type is in different assembly). Should fix this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.