Resharper code cleanup not available on Unityconfig.cs

随声附和 提交于 2019-12-10 20:38:54

问题


I'm using ReSharper 2016.3.2. It works nicely, but I bumped into a weird issue, the code cleanup feature is not available for UnityConfig.cs. The Refactor context menu is disabled, the hotkey for cleanup shows the following message:

The Key combination (Ctrl+E, Ctrl+C) is bound to command (ReSharper_CleanupCode) which is not currently available.

I looked into ReSharper settings, the Elements to skip blocks are empty, where they're present (Search & navigation, Code inspection settings).

If I rename the file, cleanup option works normally. For other ...Config.cs files the cleanup option also works normally, so it seems like this particular filename is ignored.

My question is: where can I disable this behavior?

update

The file is used to configure the DI container, which comes from Unity Nuget.

The content is quite simple, here's a skeleton:

public static void Configure(HttpConfiguration httpConfig)
{
    var container = new UnityContainer();
    //register components

    var unityServiceLocator = new UnityServiceLocator(container);
    ServiceLocator.SetLocatorProvider(() => unityServiceLocator);
    httpConfig.DependencyResolver = new UnityDependencyResolver(container);
}

回答1:


This is because the code comes from a nuget package. ReSharper will disable analysis and other features in code that is part of a nuget package because the idea is it's not user code - it's 3rd party, written by someone else, so ReSharper shouldn't apply your styles to it. Also, I'm not sure, but I think the file might get overwritten if the nuget package is updated.




回答2:


I Restarted visual studio and it solved the issue.



来源:https://stackoverflow.com/questions/42440003/resharper-code-cleanup-not-available-on-unityconfig-cs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!