Resharper code cleanup not available on Unityconfi

2019-07-04 14:48发布

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);
}

2条回答
贪生不怕死
2楼-- · 2019-07-04 15:09

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.

查看更多
甜甜的少女心
3楼-- · 2019-07-04 15:33

I Restarted visual studio and it solved the issue.

查看更多
登录 后发表回答