Open bjbr-dev opened 9 years ago
Same here, but I've disabled it using
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name must match first type name", Justification = "File must be named Global.asax.cs")]
public class MvcApplication : HttpApplication
IMO there is no need for special exceptions for this rule, any suppression should work for you.
I don't believe Global.asax
itself can be renamed, but I'm pretty sure Global.asax.cs
can be renamed.
@berkeleybross Can you change class MvcApplication
to partial class MvcApplication
? Rule SA1649 always ignores partial classes.
I've just come across this issue myself migrating an existing project to these analysers. For the case of Global.asax
, changing the name of the Global.asax.cs
file seems like an unnecessary change considering this is how almost every ASP.NET project created prior to ASP.NET 5 will already be.
Adding <auto-generated>
as discussed in #1710 isn't a good solution as many (including myself) implement application start-up and shut-down code in the file, so want it analysed. For now I've gone with the partial
route, but again that's a change just to defeat the analyser.
I'd consider this file to be an exception to the rule (and I'm sure there's others) that should be done on the basis of long-standing convention.
SA1649 is reporting the file name must match the class name for the global.asax.cs files in a standard MVC5 project. The actual class name is "MvcApplication".
I think an exception to the rule should be created for this, since the file is made automatically by visual studio when making a new MVC application.
If no exception can be made, what should the fix be? I'm not exactly sure how Global.asax works, to be honest, and I don't know whether we can change the name of the file (I'm guessing not).