Reputation: 715
My background: I have a file with a large number of lines that cause this warning (where this specific warning is meaningless to me because the array sizes are identical).
To rule out some obscure project settings, I created a simple toy example. Here, I use the rule set "Microsoft All Rules". The following still gives me warnings, including CA1814:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
#pragma warning disable 1814
var test = new int[0,0,0];
var b = new Banana();
#pragma warning restore 1814
return;
}
}
class Banana : IDisposable
{
public void Dispose()
{
Console.WriteLine("What a waste");
}
}
}
I'm not sure if this is somehow related, but even with all these errors, I can build the project fine using Warning level: 4, Treat warnings as errors: "All".
edit: I also tried CA1814 instead of just 1814
Upvotes: 1
Views: 1419
Reputation: 14853
CS1814 is not a compiler warning, per se; it is a Code Analysis warning. You have enabled static code analysis on your project, and have opted into all of the rules. You may not care to follow all of them, though, and that's what you're running up against.
You probably want to customize your ruleset. You can do that in one of two ways:
For the first approach, add the following attribute to the top of the file or method:
[SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional")]
Upvotes: 1