Conversation
When XmlProvider is used with Schema and EmbeddedResource, the EmbeddedResource parameter was previously ignored at runtime because GetSchema was inside the 'if not parseResult.IsResource then' guard that suppressed it when a resource was found at design time. This fix moves GetSchema generation outside that guard and adds an IsResource branch that reads the XSD from the embedded resource at runtime using AppDomain.CurrentDomain.GetAssemblies(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Pull request created: #1619 |
| @> | ||
| else | ||
| <@ new StringReader(valueToBeParsedOrItsUri) :> TextReader @> | ||
| | Schema _ -> () // GetSchema is generated below, outside this block |
…urce-466ae4f06439984d
* Initial plan * Add test case for GetSchema with EmbeddedResource in XSD schemas Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
|
🤖 This is an automated note from Repo Assist. The Windows CI failure on this PR is an infrastructure issue, not caused by the code changes. The failing test is All 248 unit tests, all 1 reference test, and all 485 design-time tests pass on Windows (0 failures). The build itself is clean. This PR is safe to review and merge on its merits.
|
…urce-466ae4f06439984d
|
@copilot Fix this error from CI |
…n search Replace AppDomain.CurrentDomain.GetAssemblies() |> Array.find with System.Reflection.Assembly.Load(asmName), which handles assemblies not yet loaded into the AppDomain (e.g. when called from a test project). Suggested in Copilot SWE PR #1623. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Commit pushed: |
…n search (#1623) * Initial plan * Fix CI: Use Assembly.Load instead of AppDomain.GetAssemblies for EmbeddedResource schema Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
…urce-466ae4f06439984d
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 an automated draft PR from Repo Assist, an AI assistant.
Summary
Fixes #1310 —
XmlProviderwithSchema = "..."andEmbeddedResource = "..."now generates aGetSchema()method that reads the XSD from the embedded resource at runtime, instead of failing withDirectoryNotFoundExceptionbecause the design-time file path no longer exists.Root Cause
In
Helpers.fs, theGetSchemamethod was generated inside anif not parseResult.IsResource thenguard. This guard was designed to suppressGetSample/GetSamplesfor providers that embed their sample at design time. However,Schema _was also inside this guard, so whenEmbeddedResourcewas correctly specified and the resource was found at design time (IsResource = true),GetSchemawas never generated — leaving the type without any way to load the schema at runtime.When
EmbeddedResourcewas incorrectly specified (wrong assembly name or resource name),tryGetResourcereturnedNoneandIsResource = false, soGetSchemawas generated — but it baked in the design-time file path viaasyncReadTextAtRuntimeWithDesignTimeRules. This path doesn't exist on the target machine, causingDirectoryNotFoundException.Fix
GetSchemageneration is now moved outside theif not parseResult.IsResource thenblock. A newIsResourcebranch reads the schema from the embedded resource at runtime:The
StreamReader/Streamis not wrapped inusehere — its lifetime is managed byparseSchemaFromTextReader, which creates anXmlReaderwithCloseInput = truethat disposes the underlying reader when schema compilation is complete.Trade-offs
AppDomain.CurrentDomain.GetAssemblies()only finds already-loaded assemblies. SinceGetSchema()is called from user code in the same assembly, that assembly is always loaded. This matches the semantics of the existingreadResourcedesign-time helper.EmbeddedResourcecase (existingGetSample/GetSamplessuppression logic is untouched).Test Status
✅ All 248 existing tests pass (
dotnet test tests/FSharp.Data.Tests/FSharp.Data.Tests.fsproj -c Release).No new test was added because testing
EmbeddedResourcerequires a compiled assembly with the resource embedded, which is difficult to set up in the existing test project. The fix follows the same pattern used in the rest ofHelpers.fsfor embedded-resource handling.