I am trying to ban the usage of Newtonsoft.Json
package in my codebase, and I am trying to use the BannedApiAnalyzers Nuget package (latest stable version, 3.3.4).
My problem is that while I am able to ban specific classes, I am unable to ban the entire namespace.
Consider the following code for example:
var x = Newtonsoft.Json.JsonConvert.SerializeObject(new object());
When my BannedSymbols.txt
file looks like this:
T:Newtonsoft.Json.JsonConvert;Use System.Text.Json instead
,I get a compilation error, as expected.
But when my BannedSymbols.txt
file looks like this: N:Newtonsoft.Json;Use System.Text.Json instead
, the build passes.
Banning individual classes is less maintainable and more prone to errors – I want the entire namespace banned.
What am I missing? How can I ban the entire Newtonsoft.Json
namespace (and its sub-namespaces, like Newtonsoft.Json.Linq
)?