简体   繁体   中英

Disable CodeLens in specific files

How to disable CodeLens in specific file(s) in Visual Studio 2019, like tool-generated one?

Our project is using some extra long tool-generated code (about 400k lines...Well, lets say its the burden of the past and we cant get rid of it, its doing really useful work :) ) and when i (almost always accidentaly) open them, Visual studio slow down to crawl. When we used ReSharper, disabling CodeAnalytic for this specific file(s) really helped, so disabling CodeLens should help too... I gues...

Maybe this is duplicate, i tried google, but its really cluttered with "Disable reference count" or "Disable whole CodeLens".

As an alternative to hiding Code Lens, you could hide the source files to avoid opening them on accident.

In your project file, you can set the InProject metadata on the files to false to prevent them from showing up in Solution Explorer. They are still part of the project during compilation, but that way it's much harder to open them on accident in VS.

  <ItemGroup>
    <Compile Include="Hidden.cs">
      <InProject>false</InProject>
    </Compile>
  </ItemGroup>

This will make it harder to open these files on the rare occasions that you do want to. You can still open the files with File -> Open, or using code navigation like Go to Definition, but they won't appear in the Solution Explorer tree.

This property only seems to work for non-SDK style projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM