Skip to content

fix(csharp): try fallback entrypoint on .NET Framework - #4977

Merged
CurtHagenlocher merged 2 commits into
apache:mainfrom
amoeba:csharp-importer-netfx-fallback
Oct 28, 2026
Merged

CurtHagenlocher merged 2 commits into
apache:mainfrom
amoeba:csharp-importer-netfx-fallback

Conversation

@amoeba

@amoeba amoeba commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

When no entrypoint is specified, the driver manager tries the entrypoint derived from the driver's file name (e.g. AdbcDriverSqliteInit) and then falls back to AdbcDriverInit. On the netstandard2.0 build (used on .NET Framework), the fallback was never tried: that build uses its own NativeLibrary shim, whose GetExport returns IntPtr.Zero for a missing export instead of throwing EntryPointNotFoundException, and the fallback only ran when an exception was thrown. So on .NET Framework, a driver that exports only AdbcDriverInit failed to load with "Unable to find ... export", while the same driver loaded fine on .NET 8 and later.

This PR adds a test for this case and tries the fallback entrypoint whether the first lookup throws or returns IntPtr.Zero.

Bug found and PR created with Opus 5.5.

@amoeba

amoeba commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Windows CI should fail for 0d42b93.

@amoeba

amoeba commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Windows CI failed as expected in https://github.com/apache/arrow-adbc/actions/runs/40782252801/job/123146586705?pr=4977:

[xUnit.net 00:00:11.95]     Apache.Arrow.Adbc.Tests.CAdbcDriverImporterFallbackTests.LoadWithFallback_MissingEntrypoint_UsesFallback [FAIL]
  Failed Apache.Arrow.Adbc.Tests.CAdbcDriverImporterFallbackTests.LoadWithFallback_MissingEntrypoint_UsesFallback [20 ms]
  Error Message:
   System.ArgumentException : Unable to find AdbcTestNoSuchEntrypoint export
Parameter name: file
  Stack Trace:
     at Apache.Arrow.Adbc.C.CAdbcDriverImporter.Load(String file, Boolean canUnload, String entryPoint, String fallbackEntryPoint) in D:\a\arrow-adbc\arrow-adbc\csharp\src\Apache.Arrow.Adbc\C\CAdbcDriverImporter.cs:line 103
   at Apache.Arrow.Adbc.C.CAdbcDriverImporter.LoadWithFallback(String file, String entryPoint, String fallbackEntryPoint) in D:\a\arrow-adbc\arrow-adbc\csharp\src\Apache.Arrow.Adbc\C\CAdbcDriverImporter.cs:line 61
   at Apache.Arrow.Adbc.Tests.CAdbcDriverImporterFallbackTests.LoadWithFallback_MissingEntrypoint_UsesFallback() in D:\a\arrow-adbc\arrow-adbc\csharp\test\Apache.Arrow.Adbc.Tests\CAdbcDriverImporterFallbackTests.cs:line 38

@amoeba
amoeba marked this pull request as ready for review October 28, 2026 22:59

@CurtHagenlocher CurtHagenlocher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that was an embarrassing lack of test coverage on my part :/. Thanks!

@CurtHagenlocher
CurtHagenlocher merged commit f143572 into apache:main Oct 28, 2026
11 of 13 checks passed
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