zoukankan      html  css  js  c++  java
  • 禁用VS2005中低效重构[存档]

    Optimizing C# Refactoring Performance with Web Projects in VS 2005

    One complaint I've heard a lot is the performance of the new C# refactoring feature with web pages in VS 2005.  VS 2005 added support for enabling refactoring everywhere (for example: even within <% %> blocks defined inline with a .aspx page), which is nice from a feature-completeness perspective.  The problem, though, is that by checking every file and possible context, it can end up slowing down performance considerably.  The more pages you have in a project, the slower and slower refactoring gets (to the point of being unusable).

    Unfortunately, with the current UI there is no way to tell the refactoring engine to "include/exclude" pages or individual projects when you do a refactoring change (ideally there would be a checkbox for indicating whether you wanted <% %> blocks, <script runat="server"> events, etc. checked or not so that you could configure this and turn off the overhead if you don't need it -- which for a lot of people is most/all of the time).  The C# team is investigating ways to enable these scenarios, as well as increase refactoring performance for the first SP.

    One optimization trick that you can make before that, though, is to set a registry entry that will exclude ASP.NET pages and inline .asmx and .asax code from being included as part of a C# refactoring operation.  C# class files defined under the \app_code directory in web site projects will be included as part of the refactoring operation when this registry entry is set, as well as all ASP.NET code-behind pages that are open in VS at the time that you apply the refactoring (note: the C# parser already has these files open so refactoring is very fast).  The re-factoring will also continue to work across all other class libraries and projects in the solution.

    To apply this registry setting:

    1. Close all running instances of VS 2005
    2. Click Start->Run in Windows and run "regedit"
    3. Navigate to this registry location: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\CSharp\Options\Editor
    4. Right-click on the Editor node and choose "New DWORD value"
    5. Name the value "OpenAllVenusFilesOnRefactor" and leave the value as 0

    Then, when you restart VS 2005 and perform a re-factoring - you should find performance very fast.  It isn't as complete a check as before, but for many cases it might end up being much more useful than before.

    Hope this helps,

    Scott

    P.S. VS 2005 Web Application Projects don't compile the .aspx portion of files, and don't support refactoring code within them, so they also don't have an issue with refactoring performance.

    UpdateRaj implemented the trick above and apparently saw his refactoring perf go from 1 minute 10 seconds to less than a second.  Cool! :-)

    posted on Monday, January 02, 2006 1:15 PM

  • 相关阅读:
    ASP.NET之电子商务系统开发1(数据列表)
    ASP.NET之电子商务系统开发2(购物车功能)
    MFC之列表控件
    自己动手写操作系统(二)一个最小的“操作系统”
    自己动手写操作系统(一)环境准备
    windows常用快捷键
    MFC之下拉框
    链表反转&交换链表结点
    TinyHttp前置知识
    单链表基本操作总结
  • 原文地址:https://www.cnblogs.com/net66/p/397178.html
Copyright © 2011-2022 走看看