Conversation
…e encodings On .NET 6+ (net8.0 target), code-page encodings such as windows-1250 are not available by default -- Encoding.GetEncoding(1250) throws. Add a conditional (NET6_0_OR_GREATER) registration of CodePagesEncodingProvider.Instance in asyncRead so that CsvProvider (and other providers) can read files with non-UTF encodings on modern .NET without requiring users to call RegisterProvider manually. netstandard2.0 is unaffected: CodePagesEncodingProvider requires the System.Text.Encoding.CodePages package there, so the #if guard skips registration on that target. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
✅ Pull request created: #1612 |
12 tasks
dsyme
approved these changes
Feb 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This pull request was created by Repo Assist, an automated AI assistant.
Closes #1453
Root Cause
On .NET 6+ (the
net8.0design-time target), code-page encodings such as windows-1250 (cp1250) are not registered by default.Encoding.GetEncoding(1250)throws:The fix in
PR #1503(closed) correctly identified the problem but added the registration in the wrong location (CsvProvider.fs); encoding resolution actually happens inIO.fs'sasyncReadwhen opening a local file with a non-default encoding.Fix
In
IO.fs, insideasyncRead, wrap the existingencodingStrresolution with a one-timeCodePagesEncodingProviderregistration, guarded by#if NET6_0_OR_GREATER:CodePagesEncodingProvider.Instanceis available in-box on .NET 6+; thenetstandard2.0target is left unchanged (registering there would require theSystem.Text.Encoding.CodePagespackage which is not currently a dependency).RegisterProvideris idempotent so calling it per-read is harmless.Trade-offs
net8.0target;netstandard2.0remains limited to standard encodings without the extra package.Test Status
Build: ✅
dotnet build FSharp.Data.sln -c Release— 0 errors, 23 pre-existing warningsTests: ✅ 3,310 passed; 19 failures all pre-existing network failures (HTTP 403 in sandboxed CI) unrelated to this change
Warning
The following domains were blocked by the firewall during workflow execution:
schemas.microsoft.comtomasp.netwww.google.com