I can't get the "Filter results from generated files" to work in Resharper 8

StackOverflow https://stackoverflow.com/questions/21933466

  •  14-10-2022
  •  | 
  •  

If I've read the documentation correctly, checking the "Filter results from generated files" option is supposed to hide code-generated files from the results of for instance the commmand ReSharper.ReSharper_GotoFile. This does not happen in my solution.

Evidence: ErrorController.generated.cs is code-generated and should be caught by both the wildcard *.Generated.cs and my manual configuration of the T4MVC-folder. Does not happen:

Search window

Configuration and solution view:

Search and navigation options Generated code options Solution view

Anything I've misunderstood or misconfigured?

有帮助吗?

解决方案

As far as I can see, the documentation is a little misleading, and this setting only affects searching for types, not files. If this setting is on, go to type will filter results from generated files. This doesn't mean that the types won't appear, though.

If, for example, you add a class Foo in a generated file, then trying to navigate to Foo will still show the result from the generated file, because that's the only result, and, ReSharper figures that if you asked for it, you should get it. If, however, there is more than one result, ReSharper will filter out any that are in generated files.

But it's hard to get more than one result - you can have multiple Foo classes in your project, but they'll have different namespaces, so they'll be different. Which means this setting only really works with partial types. If you have a partial class split across two files, one of which is generated, then trying to navigate to that class will only navigate you to the non-generated file (turning off the option displays a little menu asking which file you want to show). Also, ctrl+clicking the class name doesn't swap between the two class declarations (turning off the option does this).

And it only seems to affect types - you can navigate to symbols in those classes, even symbols that are defined in the generated file (again, there's only one symbol, so it doesn't get filtered). Which means the scope of this setting is actually quite limited.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top