Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the C# UTF-8 marshaling changes.
No open issues 🎉
What changed in this PR
This PR addresses #5694 by making C# binding string marshaling explicitly UTF-8, preventing Unicode path and text corruption on Windows while retaining .NET Framework 4.5 compatibility.
Changes:
- Adds UTF-8 marshaling for string arguments, return values, and SWIG callbacks.
- Integrates the marshaler and callback configuration into binding generation and SDK builds.
- Adds a Windows regression test covering Unicode paths, IDF load/save, text, containers, and exceptions.
| File | Description |
|---|---|
src/utilities/core/csharp/Utf8.i |
Defines UTF-8 string marshaling typemaps. |
src/utilities/core/csharp/LanguageSpecific.i |
Includes the UTF-8 typemaps. |
src/utilities/CMakeLists.txt |
Registers the new typemap source. |
ProjectMacros.cmake |
Runs callback configuration after SWIG generation. |
csharp/Utf8Marshaler.cs |
Implements UTF-8 conversion and native buffer ownership. |
csharp/test/Utf8Bindings.cs |
Adds Unicode binding regression checks. |
csharp/test/RunUtf8Bindings.cmake |
Compiles and runs the regression executable. |
csharp/test/README.md |
Documents test execution and marshaling ownership. |
csharp/developer/OpenStudio/OpenStudio.csproj.in |
Includes the marshaler in the managed project. |
csharp/ConfigureUtf8Callbacks.cmake |
Applies UTF-8 marshaling attributes to generated callbacks. |
csharp/CMakeLists.txt |
Tracks managed build dependencies and registers the Windows CTest. |
Review effort: Balanced
wnykuang
marked this pull request as draft
November 17, 2026 00:43
Contributor
Author
|
will do a final review and update docs on weekends; I think there should be a better approach. |
Collaborator
|
CI Results for 0451b30:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5694.
C# string marshaling can corrupt Unicode paths on Windows, causing
save()to succeed at a different path. Ordinary text and returned strings are also affected.Use explicit UTF-8 marshaling for string arguments, return values, and SWIG callbacks, with .NET Framework 4.5-compatible conversion code. Add a Windows CTest regression for paths, IDF load/save, text, containers, and exceptions.
Testing
Contribution documentation
The completed contribution proposal for this fix is being submitted to David for review.