如何使用NArrange進行代碼優化

Narrange是一個.NET代碼管理工具。它可以對源代碼自動進行美化和把類成員分成一個組、區域。目前支持C#、VB.NET,將來會支持更多.NET上的語言。

主要的作用是:

◆ 減少程序員的開發時間
◆ 使得編碼風格變得標準
◆ 能減少代碼衝突
◆ 能代碼進行分組
◆ 很好的靈活性

csdn下載:http://download.csdn.net/detail/luolunz/5640737

下載地址:http://sourceforge.net/projects/narrange/?source=dlp

 

注意:Narrange目前並不支持漢語,漢語註釋等代碼在經過了格式化之後,會變成亂碼

Narrange常用命令如下,一般使用【空格/b】進行代碼格式化,使用【空格/r】對已經格式化的代碼進行還原----注意:Narrange只會保留最後一次格式化的源碼格式,所以在你格式化代碼後,應該確保代碼能正常運行,再進行下一次的格式化。多次格式化後,會導致最初的代碼格式消失(永久性)

The command line usage is as follows:

narrange-console <input> [output] [/c:configuration]
        [/b] [/r] [/t]


input   Specifies the source code file, project, solution or 
        directory to arrange.

output  For a single source file, specifies the output file
        to write arranged code to.
        [Optional] If not specified the input source
        file will be overwritten.

/c      Configuration - Specifies the XML configuration file to use.
        [Optional] If not specified the default
        configuration will be used.

/b      Backup - Specifies to create a backup before arranging
        [Optional] If not specified, no backup will be created.
        Only valid if an output file is not specified
        and cannot be used in conjunction with Restore.

/r      Restore - Restores arranged files from the latest backup
        [Optional] When this flag is provided, no files will be arranged.
        Only valid if an output file is not specified
        and cannot be used in conjunction with Backup.

/t      Trace - Detailed logging

 

爲了使用方便,通常在Visual Studio中添加外部工具的方式來使用Narrange

  1. From the Tools menu, select External Tools.
  2. Add a new entry for NArrange.
    • For the Command, select the location of narrange-console.exe.
    • For arguments, pass the solution, project or file path macro depending on your preference. When choosing this, you may want to take into consideration your revision control system (i.e. whether or not files are marked as read-only). NArrange cannot arrange read-only files. It is recommended to pass the /b argument to specify that an automatic backup be created in your user temp directory.

    插入格式化,外邊工具,輸入Title、執行目錄所在的路徑以及可執行文件名,還有參數即可,注意【空格/b】

插入格式化還原,外邊工具,輸入Title、執行目錄所在的路徑以及可執行文件名,還有參數即可,注意【空格/r】

 

  1. It is also recommended to setup a restore command using the same parameters, replacing /b with /r. However, be careful when using restore as it will revert any edits made to a file since the last NArrange.

     

 

發佈了112 篇原創文章 · 獲贊 19 · 訪問量 29萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章