Hacker News new | past | comments | ask | show | jobs | submit login

C# is really bad about this. They seem to be heavy into the Magical Boilerplate coding style in which your "empty" project consists of thousands of lines of duplicated/generated code which you then make slight edits to. My opinion is that if some piece of code is so common that it needs to be inserted into every project - then it should be a library call. Apparently that's a minority opinion though..



This isn't my experience with C# (an empty project starts with a `Class1.cs` file if it's a library or `Program.cs` if it's an application), so you might be using something on top of C# that needs all of that boilerplate.


Sounds like project templates in Visual Studio - which can populate your project with vast amounts of stuff. This can good or bad depending on the context.


An empty ASP.NET core application contains ~35,000 lines of code.


No. There are two files, Program.cs and Startup.cs. Program.cs is 26 lines long, Startup.cs is 35 lines long. Project file is 15 lines long.

Of course, there is whole web server Kestrel referenced somewhere, using NuGet and DLLs full of MSIL. Formulating "depending on compiled library code" like "contains _ lines of code" is, especially in the context of the conversation, arguably dishonest.


No. Just looked, and the only large file generated is the dependency cache (~7000 lines of json) which you never touch and can always be regenerated with dotnet restore.

The rest is ~100-150 lines code+configuration and a readme file (~180 lines).


Look- I get that a lot of this stuff (jquery..) is libraries, and some of it is the visual studio solutions file, but if it's libraries, then why was it copied into my project directory?

   1031 ./.vs/config/applicationhost.config
     19 ./.vs/WebApplication1/v15/.suo
      3 ./WebApplication1/.bowerrc
     10 ./WebApplication1/appsettings.Development.json
      8 ./WebApplication1/appsettings.json
     10 ./WebApplication1/bower.json
     24 ./WebApplication1/bundleconfig.json
     35 ./WebApplication1/Controllers/HomeController.cs
      1 ./WebApplication1/obj/Debug/netcoreapp1.1/CoreCompileInputs.cache
      0 ./WebApplication1/obj/Debug/netcoreapp1.1/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
      0 ./WebApplication1/obj/Debug/netcoreapp1.1/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
      0 ./WebApplication1/obj/Debug/netcoreapp1.1/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     24 ./WebApplication1/obj/Debug/netcoreapp1.1/WebApplication1.AssemblyInfo.cs
   9830 ./WebApplication1/obj/project.assets.json
     17 ./WebApplication1/obj/WebApplication1.csproj.nuget.g.props
      5 ./WebApplication1/obj/WebApplication1.csproj.nuget.g.targets
     25 ./WebApplication1/Program.cs
     27 ./WebApplication1/Properties/launchSettings.json
     60 ./WebApplication1/Startup.cs
      7 ./WebApplication1/Views/Home/About.cshtml
     17 ./WebApplication1/Views/Home/Contact.cshtml
    108 ./WebApplication1/Views/Home/Index.cshtml
     14 ./WebApplication1/Views/Shared/Error.cshtml
     73 ./WebApplication1/Views/Shared/_Layout.cshtml
     18 ./WebApplication1/Views/Shared/_ValidationScriptsPartial.cshtml
      2 ./WebApplication1/Views/_ViewImports.cshtml
      3 ./WebApplication1/Views/_ViewStart.cshtml
     22 ./WebApplication1/WebApplication1.csproj
     37 ./WebApplication1/wwwroot/css/site.css
      0 ./WebApplication1/wwwroot/css/site.min.css
      0 ./WebApplication1/wwwroot/favicon.ico
      1 ./WebApplication1/wwwroot/js/site.js
      0 ./WebApplication1/wwwroot/js/site.min.js
     44 ./WebApplication1/wwwroot/lib/bootstrap/.bower.json
    587 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css
      0 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css.map
      5 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css
      0 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css.map
   6757 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap.css
      0 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map
      5 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css
      0 ./WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map
    105 ./WebApplication1/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot
    287 ./WebApplication1/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.svg
    771 ./WebApplication1/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf
     93 ./WebApplication1/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff
     72 ./WebApplication1/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2
   2377 ./WebApplication1/wwwroot/lib/bootstrap/dist/js/bootstrap.js
      6 ./WebApplication1/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js
     12 ./WebApplication1/wwwroot/lib/bootstrap/dist/js/npm.js
     21 ./WebApplication1/wwwroot/lib/bootstrap/LICENSE
     24 ./WebApplication1/wwwroot/lib/jquery/.bower.json
   9831 ./WebApplication1/wwwroot/lib/jquery/dist/jquery.js
      4 ./WebApplication1/wwwroot/lib/jquery/dist/jquery.min.js
      0 ./WebApplication1/wwwroot/lib/jquery/dist/jquery.min.map
     36 ./WebApplication1/wwwroot/lib/jquery/LICENSE.txt
     39 ./WebApplication1/wwwroot/lib/jquery-validation/.bower.json
    997 ./WebApplication1/wwwroot/lib/jquery-validation/dist/additional-methods.js
      3 ./WebApplication1/wwwroot/lib/jquery-validation/dist/additional-methods.min.js
   1397 ./WebApplication1/wwwroot/lib/jquery-validation/dist/jquery.validate.js
      3 ./WebApplication1/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js
     22 ./WebApplication1/wwwroot/lib/jquery-validation/LICENSE.md
     43 ./WebApplication1/wwwroot/lib/jquery-validation-unobtrusive/.bower.json
    415 ./WebApplication1/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js
      4 ./WebApplication1/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js
     22 ./WebApplication1.sln
  35413 total


That's not an empty .net core project; that's a sample project that you can run and see a whole website which itself is documentation on creating .net core site.

However, I'm not sure Visual Studio gives you any way to avoid this when you use the GUI to start a new core project. It is however possible to create a non-Core ASP.NET project with literally nothing in it.


VS sure does offer you a way to avoid this. Simply choose the "Empty" Template when creating a new ASP.NET Core project. (Duh. :) )


project.assets.json (and everything in /obj) is a build artifact, not source code. Would you include .o files in the weight of a sample C project ?

applicationhost.config (and everything in .vs) is local configuration for your editor (Visual Studio 15, it appears), not source code. Would you include .emacs.d in the weight of a sample project ?

Every folder in /wwwroot/lib/ that contains a .bower.json file is a local package cache, not source code. You don't have to commit it, just run bower when building your solution (if it's not done automatically for you) to restore them. If those were .dll or .pdb files instead of .min.js and .map, would you count them ?

The remaining two hundred lines of code are the contents of the "Sample" project, written to illustrate ASP.NET Core.


I never built the project. So I don't see how any of this stuff can be build artifacts. There should definitely not be copies of any "package caches" in my project folder. Why would I want a separate copy of jquery for every new project? It all shows up as part of the project when in fact that stuff is a logically separate library. Only code that is unique to my project should be in the project folder. Nor should editor config appear in the project folder. Including Jquery should be just one line of source code:

Using jquery;

I really don't care why VS put that stuff in my project- but as far as I'm concerned, if it's code of any kind, and it's in my project, and I didn't write it, then it's boilerplate. If it looks like a duck, and it quacks like a duck, then it's a duck.

I mean if I'm introduced to some other programmers project I now have to wade through this rats nest of package caches and auto generated classes and other trash trying to figure out which little bits are actually unique to the project itself. I really shouldn't have to do that.


As others have said, this is not an empty project, but a sample project template.

(Oh, and /obj is one of the standard build artifact directories for .NET together with /bin...)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: