Background
In the current implementation, CA1031 (do not catch general exception types) and CA2000 (dispose objects before losing scope) are suppressed globally in src/CryptoExchanges.Net.Binance/CryptoExchanges.Net.Binance.csproj via the NoWarn property:
<NoWarn>$(NoWarn);CA1812;CA1056;CA1031;CA2000;CA1305;CA1032;CS1591</NoWarn>
This was a deliberate maintainer decision to keep the initial PR unblocked, but project-wide suppression can mask real exception-handling and disposal defects in runtime-critical HTTP paths.
Goal
Remove CA1031 and CA2000 from the project-level NoWarn list and instead add targeted #pragma warning disable / #pragma warning restore suppressions (or [SuppressMessage] attributes) at the smallest possible scope in the files where these warnings legitimately fire, each accompanied by an inline comment explaining why the broad catch or the non-disposed resource is justified in that specific context.
Files likely affected
src/CryptoExchanges.Net.Binance/BinanceHttpClient.cs — broad catch blocks in EnsureSuccessAsync
src/CryptoExchanges.Net.Binance/BinanceExchangeClient.cs — PingAsync catch-all, SocketsHttpHandler / HttpClient ownership
src/CryptoExchanges.Net.DependencyInjection/ServiceCollectionExtensions.cs — HttpClient / BinanceExchangeClient factory lambdas
Acceptance criteria
References
Background
In the current implementation,
CA1031(do not catch general exception types) andCA2000(dispose objects before losing scope) are suppressed globally insrc/CryptoExchanges.Net.Binance/CryptoExchanges.Net.Binance.csprojvia theNoWarnproperty:This was a deliberate maintainer decision to keep the initial PR unblocked, but project-wide suppression can mask real exception-handling and disposal defects in runtime-critical HTTP paths.
Goal
Remove
CA1031andCA2000from the project-levelNoWarnlist and instead add targeted#pragma warning disable/#pragma warning restoresuppressions (or[SuppressMessage]attributes) at the smallest possible scope in the files where these warnings legitimately fire, each accompanied by an inline comment explaining why the broad catch or the non-disposed resource is justified in that specific context.Files likely affected
src/CryptoExchanges.Net.Binance/BinanceHttpClient.cs— broad catch blocks inEnsureSuccessAsyncsrc/CryptoExchanges.Net.Binance/BinanceExchangeClient.cs—PingAsynccatch-all,SocketsHttpHandler/HttpClientownershipsrc/CryptoExchanges.Net.DependencyInjection/ServiceCollectionExtensions.cs—HttpClient/BinanceExchangeClientfactory lambdasAcceptance criteria
CA1031removed from project-levelNoWarnCA2000removed from project-levelNoWarnReferences