CodeSmith Generator 是一種可幫助您更快速地完成工作的工具使您的代碼和您的路徑更加快速。從技術上來說它是驅動原始程式碼產生器,可自動創建一個常見應用程式原始程式碼的任何一種語言。
是一個軟體發展工具,從技術上講它是驅動原始程式碼產生器,可自動創建一個常見應用程式原始程式碼的任何一種語言 (C#、 JAVA、 VB、 PHP、 ASP.NET、 SQL 等) 範本。
包含許多有用的範本以及整個組的範本生成經驗證的體系結構。您可以自行選用簡易地修改任何版本或自行編寫來生成您的代碼。
CodeSmith Generator的語法幾乎與ASP.NET完全相同,所以如果你熟悉ASP.NET那您便能夠快速學會範本中的語法。您可在您的範本中以使用C#, VB.NET 或JScript.NET語法或在您的範本中的輸出任何ASCII-based (text based) 語法。
CodeSmith Generator能為您做甚麼?
CodeSmith Generator可幫助您在短時間內產生出更高品質、更一致的代碼和使軟體發展人員更有效率。
- 減少反覆的代碼
- 短時間內產生更少漏洞的代碼
- 經由您的標準產生一致性代碼
- 創建您自己的任何一種語言的自訂範本
視頻介紹
新版介紹
添加了Visual Studio 2017,C#6,VB 14和.NET 4.7支持,並且在CI /構建服務器場景中使用CodeSmith Generator非常簡單。此外,還添加了許多NuGet包,使您可以更輕鬆地在應用程式中以編程方式使用CodeSmith Generator engine 。
整個產品中還進行了許多其他改進和錯誤修復。
Visual Studio 2017
添加了Visual Studio 2017支持,我們還對Visual Studio集成進行了許多整體改進。Visual Studio集成現在作為獨立的VSIX安裝程式提供,您可以從Visual Studio Marketplace 以及Visual Studio中直接獲取。
C#6和VB 14
我們為C#6和VB 14添加了編輯器支持(IntelliSense)。現在,您可以輕鬆利用模板內的字符串插值,空條件和其他功能來提高工作效率。
Generate On Build / MSBuild Support
通過將其更改為使用CodeSmith.Generator.Task NuGet package 而不是引用CodeSmith Generator安裝中包含的預安裝的MSBuild目標文件,大大簡化了對.csp文件的Generate On Build支持 。
所以現在你可以安裝CodeSmith.Generator.Task NuGet package 來啟用項目中的Generate on Build支持。此外,在持續集成(CI)/構建服務器方案中運行CodeSmith Generator時,可以將Generator:License環境變量設置為CodeSmith Generator服務器許可證密鑰。就這麼簡單!在構
注意:如果您收到有關缺少目標文件的錯誤,則需要從項目文件中刪除舊目標文件引用。通過右鍵單擊項目中的.csp文件並切換Generate On Build選項,可以自動完成此操作。
.NET 4.7
通過升級到最新版本的.NET Framework,我們使您能夠在模板中使用新的API和庫,並為我們的用戶界面帶來改進的功能,如高DPI支持。
This table shows the features included in the different versions of CodeSmith Generator. Please use this as a guide to determine which version is most suitable for your needs.
Feature | Generator | Generator SDK | Generator Server |
Simple Template Syntax | |||
Execute Custom Templates | |||
Auto SQL Script Execution | |||
Extensible Metadata | |||
SchemaExplorer Schema Discovery API | |||
Rich XML Support | |||
Sub Template Support | |||
Useful Sample Templates | |||
Console Client | |||
Template Explorer Client | |||
Template Editor | |||
Template IntelliSense | |||
Generator Map Support | |||
Visual Studio Integration | |||
Generator API | |||
Template Caching | |||
Template Debugging | |||
Merge Capabilities | |||
Generator Project Support | |||
MSBuild Support | |||
ActiveSnippet Support |
License介紹
Generator Licenses Generator Server |
SDK Products SDK License Commercial SDK License |
Enterprise Products Site License Enterprise License |
Generator Templates
CodeSmith Generator ships with a complete template set that helps you get up and running in no time flat. These template sets include ActiveSnippet Templates, Database Templates, Example Templates, Framework Templates and various other templates. Why waste time with repetitive tasks? Use ActiveSnippets and focus on other parts of your application.
ActiveSnippet Templates
ActiveSnippet's allow you to quickly reduce the amount of time it takes to get your job done. Any template can be used as an ActiveSnippet. CodeSmith Generator ships with active snippets that will speed up the process of creating custom events and exceptions. Also you can quickly generate an enumeration or properties from database meta data.
Database Templates
Whether you are looking for an easier ways to create a business object, document your database, script your table data, execute or create stored procedures, generator is here to save you time and headaches.
The Business Object template is a template that is a great template to use if your looking to quickly create an entity for your project. Many developers also use this template as a base template when they need to create a new POCO (Plain Old CLR Object), Data Transfer Object or Domain Class template.
The Script Table Data and Extended Properties template allows you to generate a SQL script that can be used to migrate your data between database servers or import existing data into newly created databases.
The DbDocumenter template will create a nicely formatted html document of your entire database.
The Stored Procedure template will create (Insert, Update, Delete, Select) Stored Procedures based on a Database Table. Everything is configurable to fit your unique requirements.
The Command Wrapper template will create a wrapper around any SQL Stored Procedure or SQL Function. An easy to use API allows you to execute a stored procedure or function by calling Execute() which will return get back a strongly typed object or result. When used in conjunction with the Stored Procedure templates, you can quickly get data from your database.
The Typed DataSet template creates typed DataSet and DataAdapter classes based on a database table of your choosing.
Example Templates
We provide a set of example templates that demonstrate how to use various Generator features in your own custom template.
The ASP.NET folder contains a template that will show you how to use Master Templates that will generate an ASP.NET default.aspx page. (Watch the Master Templates Video)
The Basic Samples folder contains templates that display the use of Master Templates, Partial templates and Linq To Objects in your templates.
The Maps folder is a great example on how and when to use CodeSmith Generator Maps.
The Merge folder contains templates that will show you how to use Preserve Region and Insert Region Merge Strategies across different file types and languages. (Watch the Merge Strategies Video)
The Photo Gallery folder contains templates combine using a Master Templates and code behind to create a generic photo gallery from a directory of image files.
The Xml folder contains templates that show you how to generate from an Xml data source using the XmlProperty. (Watch the XmlProperty Video)
Other Templates
The Other templates folder contains various templates that ease the use working with AJAX, Custom Collections (ArrayList, HashTable, Queues, SortedList and more) and WIX (Windows Installer Xml toolset).
CodeSmith Generator requires the following system and hardware requirements.
Hardware Requirements
CodeSmith Generator is compiled against the .NET Framework 4.8. To install and use CodeSmith Generator your computer must meet Microsoft's minimum requirements for installing the .NET Framework 4.8.
Software Requirements
Here is a list of the software requirements CodeSmith Generator needs in order to operate correctly. Please note that CodeSmith Generator is fully tested running under UAC. By default, CodeSmith Generator will use user accessible directories (My Documents and AppData) to store samples and other related data.
- .NET Framework 4.8
- FIPS Compliance is required for activation purposes (offline and online).
- Registry Access
- Run time access to HKEY_CURRENT_USER, CodeSmith Generator stores it's settings in the HKEY_CURRENT_USER\Software\CodeSmith folder
- Install time access to HKEY_CLASSES_ROOT, Allows CodeSmith Generator to register Windows file associations.
- Visual Studio 2022 (optional)