├── .gitattributes ├── .yo-rc.json ├── .gitignore ├── app ├── templates │ ├── classlibrary │ │ ├── Class1.20.cs │ │ ├── Class1.35.cs │ │ ├── Class1.40.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── ClassLibrary.20.csproj │ │ └── ClassLibrary.35.csproj │ └── consoleapp │ │ ├── Program.20.cs │ │ ├── Program.35.cs │ │ ├── Program.40.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── ConsoleApp.20.csproj │ │ └── ConsoleApp.35.csproj └── index.js ├── .editorconfig ├── .jshintrc ├── README.md ├── .travis.yml ├── LICENSE.md ├── package.json └── test └── test-app.js /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-generator": {} 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | npm-debug.log 4 | .npmignore 5 | .tmp 6 | *.sln 7 | *.njsproj 8 | *.suo -------------------------------------------------------------------------------- /app/templates/classlibrary/Class1.20.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace <%= namespace %> 6 | { 7 | public class Class1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/templates/classlibrary/Class1.35.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace <%= namespace %> 7 | { 8 | public class Class1 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /app/templates/classlibrary/Class1.40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace <%= namespace %> 8 | { 9 | public class Class1 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/templates/consoleapp/Program.20.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace <%= namespace %> 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /app/templates/consoleapp/Program.35.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace <%= namespace %> 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /app/templates/consoleapp/Program.40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace <%= namespace %> 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 2, 10 | "latedef": true, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "undef": true, 15 | "unused": true, 16 | "strict": true 17 | } 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-csharp 2 | 3 | [![Build Status](https://travis-ci.org/OmniSharp/generator-csharp.svg?branch=master)](https://travis-ci.org/OmniSharp/generator-csharp) 4 | ![Version](https://img.shields.io/npm/v/generator-csharp.svg) 5 | ![Downloads per month](https://img.shields.io/npm/dm/generator-csharp.svg) 6 | 7 | 8 | 9 | More info coming soon. 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | deploy: 5 | api_key: 6 | secure: aYfHC2cxnvtMKfe3K6ys2nAatEHHA2JG2wIU5WteURwM5kULt+rqZ9cjGFhBep2F/oq4ttJDmnkdn0UC/OzPZ47SEeSfelFAjpiSv7RECULIN2rnZ/y41SivX0H2PxilIWyj7RAd7A43+YNzvRoOy1i4vfNCAiu3tC+HX7TfgO4= 7 | email: sayed.hashimi@gmail.com 8 | provider: npm 9 | on: 10 | branch: release 11 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2013 OmniSharp 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-csharp", 3 | "version": "0.0.1", 4 | "description": "Yeoman generator", 5 | "license": "Apache License 2.0", 6 | "main": "app/index.js", 7 | "repository": "omnisharp/generator-csharp", 8 | "author": { 9 | "name": "Sayed Ibrahim Hashimi", 10 | "email": "sayed.hashimi@gmail.com", 11 | "url": "https://github.com/omnisharp/generator-csharp" 12 | }, 13 | "engines": { 14 | "node": ">=0.10.0" 15 | }, 16 | "scripts": { 17 | "test": "mocha" 18 | }, 19 | "files": [ 20 | "app" 21 | ], 22 | "keywords": [ 23 | "yeoman-generator" 24 | ], 25 | "dependencies": { 26 | "yeoman-generator": "^0.18.9", 27 | "chalk": "^1.0.0", 28 | "yosay": "^1.0.2" 29 | }, 30 | "devDependencies": { 31 | "mocha": "*" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/test-app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var assert = require('yeoman-generator').assert; 5 | var helpers = require('yeoman-generator').test; 6 | var os = require('os'); 7 | 8 | function createProjectTypeTest(type, files) 9 | { 10 | describe('csharp:' + type, function () { 11 | before(function (done) { 12 | helpers.run(path.join(__dirname, '../app')) 13 | .inDir(path.join(os.tmpdir(), './temp-test')) 14 | .withOptions({ 'skip-install': true }) 15 | .withPrompt({ 16 | projecttype: type, 17 | applicationName: "test" 18 | }) 19 | .on('end', done); 20 | }); 21 | 22 | it('creates files', function () { 23 | assert.file(files); 24 | }); 25 | 26 | }); 27 | } 28 | 29 | createProjectTypeTest("classlibrary", [ 30 | 'test/Class1.cs', 31 | 'test/test.csproj', 32 | 'test/Properties/AssemblyInfo.cs' 33 | ]); 34 | 35 | createProjectTypeTest("consoleapp", [ 36 | 'test/Program.cs', 37 | 'test/test.csproj', 38 | 'test/Properties/AssemblyInfo.cs' 39 | ]); -------------------------------------------------------------------------------- /app/templates/classlibrary/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("<%= namespace %>")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("<%= namespace %>")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("983ef147-614d-48cc-9bac-ad1ec5d52305")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /app/templates/consoleapp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("<%= namespace %>")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("<%= namespace %>")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("88238f0f-1b0e-48a3-a094-e6fe680ad33d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /app/templates/classlibrary/ClassLibrary.20.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 983ef147-614d-48cc-9bac-ad1ec5d52305 8 | Library 9 | Properties 10 | <%= namespace %> 11 | <%= namespace %> 12 | v<%= fx %> 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /app/templates/classlibrary/ClassLibrary.35.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 983ef147-614d-48cc-9bac-ad1ec5d52305 8 | Library 9 | Properties 10 | <%= namespace %> 11 | <%= namespace %> 12 | v<%= fx %> 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /app/templates/consoleapp/ConsoleApp.20.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {45E5A124-00C3-42C5-9A4B-4162D91ECF82} 8 | Exe 9 | Properties 10 | <%= namespace %> 11 | <%= namespace %> 12 | v<%= fx %> 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | -------------------------------------------------------------------------------- /app/templates/consoleapp/ConsoleApp.35.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {45E5A124-00C3-42C5-9A4B-4162D91ECF82} 8 | Exe 9 | Properties 10 | <%= namespace %> 11 | <%= namespace %> 12 | v<%= fx %> 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var yeoman = require('yeoman-generator'); 3 | var chalk = require('chalk'); 4 | var yosay = require('yosay'); 5 | var path = require('path'); 6 | 7 | var csharpgenerator = yeoman.generators.Base.extend({ 8 | constructor: function () { 9 | yeoman.generators.Base.apply(this, arguments); 10 | this.option("fx", { 11 | desc: "Which .NET Framework version to load", 12 | type: "Number", 13 | defaults: 4.6, 14 | hide: false 15 | }); 16 | }, 17 | 18 | init: function () { 19 | // Have Yeoman greet the user. 20 | this.log(yosay('Welcome to the marvellous ' + chalk.red('C#') + ' generator!')); 21 | this.templatedata = {}; 22 | switch (this.options.fx) { 23 | case 2: 24 | case 3: 25 | case 3.5: 26 | case 4: 27 | case 4.5: 28 | case 4.6: 29 | this.fx = this.options.fx; 30 | this.templatedata.fx = this.fx.toFixed(1); 31 | break; 32 | default: 33 | this.fx = 0; 34 | this.log(chalk.red('Unknown framework version \'' + this.options.fx.toFixed(1) + '\'')); 35 | } 36 | }, 37 | getInfo: function () { 38 | if (this.fx === 0) { 39 | return; 40 | } 41 | var done = this.async(); 42 | 43 | function askFor() { 44 | var prompts = [{ 45 | type: 'list', 46 | name: 'projecttype', 47 | message: 'What type of project do you want to create?', 48 | choices: [ 49 | { 50 | name: 'Class library', 51 | value: 'classlibrary' 52 | }, 53 | { 54 | name: "Portable class library", 55 | value: 'portableclasslib' 56 | }, 57 | { 58 | name: 'xUnit test project', 59 | value: 'xunit' 60 | }, 61 | { 62 | name: 'Console application', 63 | value: 'consoleapp' 64 | } 65 | ] 66 | }]; 67 | 68 | this.prompt(prompts, function (props) { 69 | this.projecttype = props.projecttype; 70 | askForName.apply(this); 71 | }.bind(this)); 72 | } 73 | 74 | function askForName() { 75 | var app = ''; 76 | 77 | switch (this.projecttype) { 78 | case 'classlibrary': 79 | app = 'ClassLibrary'; 80 | break; 81 | case 'portableclasslib': 82 | app = 'PortableClassLibrary'; 83 | break; 84 | case 'xunit': 85 | app = 'UnitTest'; 86 | break; 87 | case 'consoleapp': 88 | app = 'ConsoleApp'; 89 | break; 90 | default: 91 | this.log('Unknown value for projecttype: [' + this.projecttype + ']'); 92 | askFor.apply(this); 93 | return; 94 | } 95 | 96 | var prompts = [{ 97 | name: 'applicationName', 98 | message: 'What\'s the name of your ' + app.match(/(?:([A-Z][a-z]+)(?=[A-Z]))|(?:([a-z]+)(?=[A-Z]))|(?:(\d+))|(?:([A-Z][a-z]+))|([A-Z]+)/g).join(' ') + '?', 99 | default: app 100 | }]; 101 | this.prompt(prompts, function (props) { 102 | this.templatedata.namespace = props.applicationName; 103 | this.templatedata.applicationname = props.applicationName; 104 | this.applicationName = props.applicationName; 105 | 106 | done(); 107 | }.bind(this)); 108 | } 109 | 110 | askFor.apply(this); 111 | }, 112 | 113 | writing: function () { 114 | if (this.fx === 0) { 115 | return; 116 | } 117 | this.mkdir(this.applicationName); 118 | 119 | switch (this.projecttype) { 120 | case 'classlibrary': 121 | this.sourceRoot(path.join(__dirname, './templates/', this.projecttype)); 122 | switch (this.fx) { 123 | case 2: 124 | case 3: 125 | this.template(this.sourceRoot() + '/Class1.20.cs', this.applicationName + '/Class1.cs', this.templatedata); 126 | break; 127 | case 3.5: 128 | this.template(this.sourceRoot() + '/Class1.35.cs', this.applicationName + '/Class1.cs', this.templatedata); 129 | break; 130 | case 4.0: 131 | case 4.5: 132 | case 4.6: 133 | this.template(this.sourceRoot() + '/Class1.40.cs', this.applicationName + '/Class1.cs', this.templatedata); 134 | break; 135 | } 136 | switch (this.fx) { 137 | case 2: 138 | case 3: 139 | this.template(this.sourceRoot() + '/ClassLibrary.20.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata); 140 | break; 141 | case 3.5: 142 | case 4.0: 143 | case 4.5: 144 | case 4.6: 145 | this.template(this.sourceRoot() + '/ClassLibrary.35.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata); 146 | break; 147 | } 148 | this.mkdir(this.applicationName + '/Properties/'); 149 | this.template(this.sourceRoot() + '/Properties/AssemblyInfo.cs', this.applicationName + '/Properties/AssemblyInfo.cs', this.templatedata); 150 | break; 151 | case 'portableclasslib': 152 | this.log('not implemented yet'); 153 | return; 154 | break; 155 | case 'xunit': 156 | this.log('not implemented yet'); 157 | return; 158 | break; 159 | case 'consoleapp': 160 | this.sourceRoot(path.join(__dirname, './templates/', this.projecttype)); 161 | switch (this.fx) { 162 | case 2: 163 | case 3: 164 | this.template(this.sourceRoot() + '/Program.20.cs', this.applicationName + '/Program.cs', this.templatedata); 165 | break; 166 | case 3.5: 167 | this.template(this.sourceRoot() + '/Program.35.cs', this.applicationName + '/Program.cs', this.templatedata); 168 | break; 169 | case 4.0: 170 | case 4.5: 171 | case 4.6: 172 | this.template(this.sourceRoot() + '/Program.40.cs', this.applicationName + '/Program.cs', this.templatedata); 173 | break; 174 | } 175 | switch (this.fx) { 176 | case 2: 177 | case 3: 178 | this.template(this.sourceRoot() + '/ConsoleApp.20.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata); 179 | break; 180 | case 3.5: 181 | case 4.0: 182 | case 4.5: 183 | case 4.6: 184 | this.template(this.sourceRoot() + '/ConsoleApp.35.csproj', this.applicationName + '/' + this.applicationName + '.csproj', this.templatedata); 185 | break; 186 | } 187 | this.mkdir(this.applicationName + '/Properties/'); 188 | this.template(this.sourceRoot() + '/Properties/AssemblyInfo.cs', this.applicationName + '/Properties/AssemblyInfo.cs', this.templatedata); 189 | break; 190 | } 191 | } 192 | }); 193 | 194 | module.exports = csharpgenerator 195 | --------------------------------------------------------------------------------