Skip to content

Comments

Fix GetSchema EmbeddedResource: use Assembly.Load instead of AppDomain search#1623

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

Fix GetSchema EmbeddedResource: use Assembly.Load instead of AppDomain search#1623
dsyme merged 3 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() on an XmlProvider with EmbeddedResource was failing at runtime with KeyNotFoundException because AppDomain.CurrentDomain.GetAssemblies() |> Array.find couldn't locate the target assembly when called from a different assembly (e.g. a test project referencing the one containing the type).

Changes

  • Helpers.fs: Replace AppDomain.CurrentDomain.GetAssemblies() |> Array.find (fun a -> a.GetName().Name = asmName) with System.Reflection.Assembly.Load(asmName), which resolves the assembly whether or not it has already been loaded into the AppDomain.
// Before — fails if assembly not yet loaded in AppDomain
let loadedAsm =
    System.AppDomain.CurrentDomain.GetAssemblies()
    |> Array.find (fun a -> a.GetName().Name = asmName)

// After — loads on demand
let loadedAsm = System.Reflection.Assembly.Load(asmName)

🔒 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.

…ddedResource schema

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/MSBuildTempw6V7WL/tmp3a6ea14669e740cca472a3c6310bd265.rsp (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/8.0.123/FSharp/fsc.dll @/tmp/MSBuildTempYyke91/tmp2b30fa5912014de7b5f9e0ff3199adb1.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] Fix GetSchema for embedded XSD resources Fix GetSchema EmbeddedResource: use Assembly.Load instead of AppDomain search Feb 22, 2026
github-actions bot added a commit that referenced this pull request Feb 22, 2026
…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>
@dsyme dsyme marked this pull request as ready for review February 22, 2026 22:05
@dsyme dsyme merged commit 775fd1a 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 22:06
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