<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          在 .NET 6 中使用 dotnet format 格式化代碼

          共 948字,需瀏覽 2分鐘

           ·

          2022-06-29 00:31



          我不得不承認,在 code review 的時候,我花費了很多時間來研究 C# 的代碼格式問題,這是沒有太大意義的工作,我應該專注于其他事情,而不是觀察同事是否忘記格式化代碼,或者是使用了其他不同規(guī)則的代碼編輯器。

          現(xiàn)在,我們可以使用 dotnet format 檢查代碼格式問題。這是 .NET 6 的新功能,.NET CLI 引入了 dotnet format 命令 ,并且它是內(nèi)置的命令。

          需要注意的是,如果你安裝了 .NET 6 Preview 7 SDK 或更高版本,應該使用 dotnet-format 而不是 dotnet format, 否則運行命令會報錯。

            如何使用?

          格式化解決方案中的所有代碼:

          dotnet format ./solution.sln

          格式化單個項目的代碼

          dotnet format ./src/application.csproj

          驗證所有代碼的格式是否正確:

          dotnet format --verify-no-changes

          格式化 src 和 tests 目錄中的所有代碼,并排除 src/submodule-a 目錄的代碼:

          dotnet format --include ./src/ ./tests/ --exclude ./src/submodule-a/

          格式化并輸出詳細信息

          dotnet-format -v diag

          格式化并記錄報告到文件

          dotnet format --report ./report.json

          更多 dotnet-format 的信息,可以查看下面的鏈接

          https://github.com/dotnet/format  


          END

          做了一個 .NET 的學習網(wǎng)站,內(nèi)容涵蓋了 分布式系統(tǒng),數(shù)據(jù)結構與算法,設計模式,操作系統(tǒng),計算機網(wǎng)絡等, 回復 dotnet 獲取網(wǎng)站地址, 回復 面試題 獲取 .NET 面試題。




          瀏覽 56
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  91麻豆亚洲国产成人久久精品 | www.操骚逼 | 网站一级片 | 九九久久免费视频 | 国产精品一色哟哟哟 |