Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CA2101 triggering when BestFitMapping=false
The documentation for CA2101 indicates that the problem is not the use of single-byte character marshalling, but that when doing so .NET will by default try and substite characters that cannot be directly marshalled. Unfortunately, when a developer actually tries to use BestFitMapping=false, such as when using ANSI-only APIs (which are particularly common on non-Windows operating systems), CA2101 triggers anyway and the developer has no choice but to suppress the Diagnostic or disable the rule, adding noise to their code and reducing trust in the analyzer. CA2101 appears to work correctly in Microsoft.CodeAnalysis.FxCopAnalyzers and in NetAnalyzers through version 5.0.3. BestFitMapping=false only got disabled in version 6.0.0, apparently due to a small mistake when refactoring to take the new InvariantGlobalization setting into account. This commit adds tests for BestFitMapping (which for some reason was completely untested previously) and fixes the refactoring error.
- Loading branch information