Topic | Value |
---|---|
Id | IDISP014 |
Severity | Info |
Enabled | True |
Category | IDisposableAnalyzers.Correctness |
Code | CreationAnalyzer |
Use a single instance of HttpClient.
https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/
And:
http://byterot.blogspot.se/2016/07/singleton-httpclient-dns.html
private static HttpClient Client =new HttpClient { ... };
Configure the severity per project, for more info see MSDN.
#pragma warning disable IDISP014 // Use a single instance of HttpClient
Code violating the rule here
#pragma warning restore IDISP014 // Use a single instance of HttpClient
Or put this at the top of the file to disable all instances.
#pragma warning disable IDISP014 // Use a single instance of HttpClient
[System.Diagnostics.CodeAnalysis.SuppressMessage("IDisposableAnalyzers.Correctness",
"IDISP014:Use a single instance of HttpClient",
Justification = "Reason...")]