Skip to content

Add test case for GetSchema with EmbeddedResource in XSD schemas#1620

Merged
dsyme merged 2 commits intorepo-assist/fix-issue-1310-xsd-embedded-resource-466ae4f06439984dfrom
copilot/sub-pr-1619
Feb 22, 2026
Merged

Add test case for GetSchema with EmbeddedResource in XSD schemas#1620
dsyme merged 2 commits intorepo-assist/fix-issue-1310-xsd-embedded-resource-466ae4f06439984dfrom
copilot/sub-pr-1619

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

GetSchema() was previously not generated when EmbeddedResource was specified alongside Schema in XmlProvider. This adds a test to cover that fix.

Changes

  • tests/FSharp.Data.Tests/XmlProvider.fs: Adds XmlSchemaWithEmbeddedResource — an XmlProvider type using both Schema and EmbeddedResource, pointing to the embedded po.xsd in the FSharp.Data.Tests assembly.

  • tests/FSharp.Data.Reference.Tests/XmlProvider.fs (new): Reference test that calls GetSchema() on the above type and asserts the result has Count = 1. Runs in a project that depends on FSharp.Data.Tests, ensuring the embedded resource is available at runtime and the EmbeddedResource code path in GetSchema() is exercised.

  • FSharp.Data.Reference.Tests.fsproj: Includes the new test file.

// FSharp.Data.Tests/XmlProvider.fs
type XmlSchemaWithEmbeddedResource =
    XmlProvider<Schema = "Data/po.xsd", EmbeddedResource = "FSharp.Data.Tests, FSharp.Data.Tests.Data.po.xsd">

// FSharp.Data.Reference.Tests/XmlProvider.fs
[<Test>]
let ``GetSchema works for XmlProvider with Schema and EmbeddedResource`` () =
    let schema = FSharp.Data.Tests.XmlProvider.XmlSchemaWithEmbeddedResource.GetSchema()
    schema.Count |> should equal 1

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 22, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.worldbank.org
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/8.0.123/FSharp/fsc.dll @/tmp/MSBuildTempYUY93d/tmp63b9a2c8e4d14fc58d6ea7662740852e.rsp (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/8.0.123/FSharp/fsc.dll @/tmp/MSBuildTemp2XEZqy/tmpad61dded71004d498e59624557c29ef2.rsp (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/8.0.123/FSharp/fsc.dll @/tmp/MSBuildTempCANIIk/tmp008d97c0862a481498dc45cb09983cf2.rsp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add test case for fixing GetSchema with EmbeddedResource Add test case for GetSchema with EmbeddedResource in XSD schemas Feb 22, 2026
@dsyme dsyme marked this pull request as ready for review February 22, 2026 19:33
@dsyme dsyme merged commit 644162c into repo-assist/fix-issue-1310-xsd-embedded-resource-466ae4f06439984d Feb 22, 2026
@dsyme dsyme deleted the copilot/sub-pr-1619 branch February 22, 2026 19:33
dsyme added a commit that referenced this pull request Feb 23, 2026
…rce is specified for XSD schemas (#1619)

* Fix #1310: GetSchema now works with EmbeddedResource for XSD schemas

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>

* Add test case for GetSchema with EmbeddedResource in XSD schemas (#1620)

* 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>

* Fix GetSchema EmbeddedResource: use Assembly.Load instead of AppDomain 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>

* Fix GetSchema EmbeddedResource: use Assembly.Load instead of AppDomain 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>

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants