Resharper是否具备类似Roslynator的快速代码预览功能?
Great question! Yes, ReSharper does offer a feature that lets you preview code changes on the fly—just like Roslynator’s quick preview—though it’s not turned on by default. Here’s how it works and how to enable it:
Inline Quick-Fix Previews: ReSharper can show code change previews directly in your editor as you hover over a suggested quick-fix, no extra clicks needed. To activate this:
- Open ReSharper’s options by going to
ReSharper > Options(or use the shortcutAlt+R, O) - Head to
Environment > Editor > Visualization - Toggle on the checkbox labeled "Show preview of quick-fix changes in editor"
- Hit Save to apply the setting
- Open ReSharper’s options by going to
The "Preview Code" Button (Default Behavior): If you’re only seeing the option to click
Preview Coderight now, that’s because inline previews are disabled out of the box. Once you flip the setting above, you’ll start seeing highlighted code changes inline immediately when you hover over a fix suggestion, just like you do with Roslynator.For Complex Refactorings: Keep in mind that for bigger refactorings (like renaming a symbol across files or extracting a method), ReSharper will still bring up a dedicated preview window to show you all affected changes. But for quick, one-off fixes (like fixing a missing using directive or simplifying an if statement), the inline preview will give you that instant glance you’re looking for.
Note: Depending on your specific ReSharper version, the exact wording of the setting might be slightly different, but you’ll find it under the Editor Visualization section for sure.
内容的提问来源于stack exchange,提问作者Veerakran Sereerungruangkul

