簡體   English   中英

為服務引用自動生成 XML 時如何阻止 Visual Studio 換行

[英]How to stop Visual Studio from wrapping lines when XML is auto-generated for service references

當您在 Visual Studio 項目中添加或更新服務引用(以前稱為“Web 引用”)時,VS.NET 將在您的應用程序配置中自動生成所有 XML 綁定代碼。

它往往看起來像這樣:

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_IUserService" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="6553600" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://domain.com/services/user.svc"
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserService"
      contract="UserService.IUserService" name="BasicHttpBinding_IUserService" />
  </client>
</system.serviceModel>

我討厭它看起來多么凌亂,所以我通常通過 go 並手動“修復”它以刪除所有換行符。

所以我讓它看起來像這樣:

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_IUserService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="6553600" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://domain.com/services/user.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserService" contract="UserService.IUserService" name="BasicHttpBinding_IUserService" />
  </client>
</system.serviceModel>

這不僅僅是希望它看起來干凈的問題。 我的一些客戶項目有超過 20 個引用,因此它有助於防止配置沒有 10 英尺的垂直滾動。

我一直在尋找可以阻止這種情況的選項,但從未找到任何選項。 今天早上,我突然想到也許我應該問一下。 其他 SO 問題, 例如這個問題,涉及類似的問題,但還沒有解決方案。

在工具 > 選項 > XML > 格式化中取消選中自動格式化選項可能會有所幫助。

我很確定你可以做到這一點。 在選項/文本編輯器/XML 下應該有一個稱為屬性間距的設置。 我有完全相反的設置。 當您在那里時,展開 Wrap line 設置並查看該設置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM