开发者

Apply a context action to an entire file

Is there any way to make Resharper apply a context action at every applicable site in a file?

In particular, in order to comply with coding standards, I 开发者_如何学JAVAwish to apply 'Specify type explicitly' to every 'var' declaration across a number of files.


In general, you can't apply a context action in multiple code positions. However, in the case of specifying type explicitly, you can use Code Cleanup to batch-apply this.

  1. Choose "ReSharper > Tools > Clean up code"
  2. Click "Edit Profiles"
  3. Click "Add" to create a new cleanup profile and specify a name for it (say, "goodbye var").
  4. In the list of profile settings, clear all check boxes to prevent unwanted code style changes.
  5. Under C# > Use 'var' in declaration, select "Do not change" for "Replace direction", and "Always use explicit type" in the other two drop-downs.
  6. Click "OK".
  7. Choose "ReSharper > Tools > Clean up code" once more, choose the "goodbye var" profile, and click "Run".

Note that you can invoke code cleanup in different scopes: step 7 above implies that you're calling it in the scope of the currently opened file. However, you can choose a wider scope (folder, project, solution) in the Solution Explorer and invoke Code Cleanup from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜