C# loader: class support - failing test first (TDD) #123 - #858
Open
G00dS0ul wants to merge 3 commits into
Open
Conversation
viferga
reviewed
Aug 22, 2026
| @@ -0,0 +1,20 @@ | |||
| public class Counter | |||
| { | |||
| public int count; // attribute | |||
Member
There was a problem hiding this comment.
static attribute is also needed
Contributor
Author
There was a problem hiding this comment.
Added in 0065cd4 Counter now has public static int total and the test exercises metacall_class_static_set
viferga
reviewed
Aug 22, 2026
| /* C# Netcore */ | ||
| #if defined(OPTION_BUILD_LOADERS_CS) | ||
| { | ||
| const char* cs_scripts[] = { |
Member
There was a problem hiding this comment.
you may need to run make clang-format for formatting the c/c++ code
Member
There was a problem hiding this comment.
If you use vscode you can add clang plugins to automatically format it.
Contributor
Author
There was a problem hiding this comment.
you may need to run
make clang-formatfor formatting the c/c++ code
Done in ffca761 scoped the run to just the two new test sources (clang-format -i on main.cpp and metacall_csharp_class_test.cpp), didn't use make clang-format, to avoid the repo-wide diff
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.
Description
First step toward class support in the C# loader (part of #123 — make the C# loader production-ready). This is a Draft / TDD red-first PR: it adds a failing test only, no loader implementation yet, so we can agree on the test shape before I build the reflection layer. CI is expected to fail on the legs that have DotNET.
The new test
metacall_csharp_class_testmirrors the non-static class section ofmetacall_java_test, using the file layout ofmetacall_csharp_static_class_test. It adds a smallclass.cs(Counter) that exercises the four things class support needs:new Counter(5)count == 5Add(7) == 12Counter.Twice(21) == 42It goes red because
cs_loader_impl_discover()currently registers only top-level functions and never builds aklass, sometacall_class("Counter")returnsNULL.Follow-up PRs (kept intentionally small): interfaces (blocked on the core templates/generics work) and inheritance.
Part of #123 — first of several PRs, so I've deliberately avoided a closing keyword.
Type of change
Checklist:
make testorctest -VV -R). — the new test fails as intended (TDD red); it will pass in the follow-up implementation PR../docker-compose.sh test &> outputand attached the output.OPTION_BUILD_ADDRESS_SANITIZERor./docker-compose.sh test-address-sanitizer &> outputandOPTION_TEST_MEMORYCHECK.OPTION_BUILD_THREAD_SANITIZERor./docker-compose.sh test-thread-sanitizer &> output.Helgrindin case my code works with threading.make clang-formatin order to format my code and my code follows the style guidelines.