Métricas do repositório
- Stars
- (4.100 stars)
- Métricas de merge de PR
- (Mesclagem média 14d 22h) (56 fundiu PRs em 30d)
Description
.NET Core Version: any .NET Core version
Have you experienced this same bug with .NET Framework?: no, regression against Desktop Framework
Problem description:
.NET Core changed the behavior of Encoding.Default to return UTF8 encoding, while Desktop (from which WinForms is derived) returned the Windows ANSI encoding (which is also used for interop). Any usage of Encoding.Default in WinForms is now very likely to be incorrect and must be reviewed and updated.
See issue #3032 and PR #3100, #3141, #3210 for the previously done corrections, but more remain to be fixed.
The correct pattern for porting Desktop Framework usage of Encoding.Default is now to use CodePagesEncodingProvider.Instance.GetEncoding(0) ?? Encoding.UTF8 instead, which retrieves the ANSI encoding Windows uses for interop. (The codepage based encoding is null if Windows was configured to be using UTF8 instead of a normal codepage, see discussion in #3032.)
For call sites which aren't related to interop there needs to be discussion and case-by-case decision of whether to replace Encoding.Default or whether to use UTF8 going forward. They could still be updated to refer to the UTF8 encoding explicitly for clarity.
Expected behavior:
WinForms is updated to respect the changed behavior of Encoding.Default
Minimal repro: n/a (issue raised due to manual inspection of source code, analysis of scenarios should happen as part of the issue, if required)