Thursday, 28 July 2016

ReSharper cleans our code and changes the using directives so that StyleCop rule SA1200 fails. What to do?

If I use the Code Cleanup ReSharper feature I get this start of a file:




using System.Web.UI;

[assembly: WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]

namespace SiteSeeker.Web.WebControls
{
using System;
using System.Collections.Specialized;
using System.Reflection;

using System.Web;
using System.Web.UI;
....


However this triggers the SiteCop rule "SA1200: All using directives must be placed inside of the namespace.". Is there a way to configure ReSharper to turn the assembly line into:



[assembly: WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]



So that I get this beginning of the file:



[assembly: System.Web.UI.WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]

namespace SiteSeeker.Web.WebControls
{
using System;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;

using System.Web.UI;
....


Which will not cause StyleCop to get angry. Or should I go the route and deactivate the SiteCop rule? Use Code Cleanup in ReSharper is something we would like to, as it is convenient and almost works with our StyleCop rules.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...