Conversation
When StrictBooleans=true: - Columns with only 0/1 values are inferred as int (not bool) - Columns with only yes/no values are inferred as string (not bool) - Only columns with exclusively true/false values become bool This implements the feature requested in issue #1417, endorsed by @dsyme. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Pull request created: #1621 |
| preferOptionals | ||
| missingValues | ||
| inferenceMode | ||
| strictBooleans |
There was a problem hiding this comment.
@copilot You;ll need to fix up the code in TypeProviderInstantiation.fs too for Csv since you've added an argument
match args.[0] with
| "Csv" ->
Csv { Sample = args.[1]
Separators = args.[2]
InferRows = Int32.MaxValue
Schema = args.[3].Replace(';', ',')
HasHeaders = args.[4] |> bool.Parse
IgnoreErrors = false
SkipRows = 0
AssumeMissingValues = args.[5] |> bool.Parse
PreferOptionals = args.[6] |> bool.Parse
Quote = '"'
MissingValues = args.[7]
Culture = args.[8]
Encoding = args.[9]
CacheRows = false
ResolutionFolder = ""
EmbeddedResource = ""
PreferDateOnly = false }
Check whole file carefully
|
🤖 This is an automated response from Repo Assist. Thanks for the review,
This follows the same pattern as existing fields like The Copilot SWE agent created PR #1622 to address your feedback — but I believe the fix is already present. Happy to make further adjustments if there's something I've missed!
|
Add entries for: - #1613: CSS pseudo-class NotSupportedException fix (#1383) - #1617: ConvertDateTimeOffset xs:dateTime fallback fix (#1437) - #1618: Microsoft.Build security bump - #1619: XmlProvider EmbeddedResource GetSchema fix (#1310) - #1621: StrictBooleans parameter for CsvProvider - #1625: CsvProvider.InferRows multiline quoted field fix (#1439) - #1626: XSD group reference cycle guard (#1419) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🤖 This is a draft PR from Repo Assist, an automated AI assistant.
Closes #1417
Summary
Adds a new
StrictBooleansstatic parameter toCsvProvider(defaultfalse, fully backward-compatible).When
StrictBooleans=true:0/1values are inferred asintinstead ofboolyes/novalues are inferred asstringinstead ofbooltrue/falsevalues becomeboolThis was explicitly endorsed by @dsyme in issue #1417.
Root Cause
FSharp.Data's boolean inference is intentionally broad:"0","1","yes","no","true","false"all parse as booleans viaTextConversions.AsBoolean. For CSVs where0/1represent numeric IDs or flags, this produces surprisingboolcolumns.Implementation
Changes are minimal and surgical:
CsvInference.fs: AddedstrictBooleans: boolparam toinferCellType,inferType, andinferColumnTypes. Whentrue, post-processes inferred types:Bit0/Bit1→int; non-true/falseboolean values →string. TheCsvFile.InferColumnTypesmethod gets an F# optional?strictBooleansparameter (backward-compatible).HtmlInference.fs: Updated call to passfalsefor the new required positional param.CsvProvider.fs: AddedStrictBooleansas static parameter at index 17 (afterPreferDateOnly).tests/FSharp.Data.Tests/CsvProvider.fs: Added 3 new test cases verifying the feature.tests/FSharp.Data.DesignTime.Tests/TypeProviderInstantiation.fsandInferenceTests.fs: Updated test infrastructure to includeStrictBooleans=false(no behavior change for existing tests).Trade-offs
inferCellTypekeeps the change isolated to CsvProvider without touching shared inference code.StrictBooleans=falsedefault preserves 100% backward compatibility.Test Status
✅ Linux build: All projects build with 0 errors
⚠️ FSharp.Data.DesignTime.Tests XML: 18 pre-existing failures (network tests blocked by sandbox firewall + known
✅ FSharp.Data.Tests: 251/251 tests pass (includes 3 new
StrictBooleanstests)✅ FSharp.Data.DesignTime.Tests CSV: 20/20 CSV tests pass
IncludeFromWeb.xsdbug tracked in PR #1619) — not caused by this PRWarning
The following domains were blocked by the firewall during workflow execution:
schemas.microsoft.comtomasp.net