Oh lol I forgot about that part. Any thoughts on multiplatform Julia Dir lookup? I provided a method to give your own dir but it would probaly be a good idea to have a default lookup. Also there is a kernel32 call which is not multiplatform.
I think those are the only two things that make it not multiplatform. Unfortunately I dont know anything about macOS. If anyone knows how to do the setdlldirectory / finding julia dir on macos, let me know
I think I wrote it in .Net framework aswell since I made this for another project. Ill port it over to .Net 5
I actually just finished developing an interface between Julia and .NET for an internal project based on information from @oheil .
When I started that, I was a newcomer to both Julia and C#/VB.net so it seemed infeasible with the C interface.
So I did it using communications over pipes, like a client-server communication.
Though this takes time, (de-)serialization seems to be fine (i.e negligible to the user) in most cases, even with relatively large arrays (about tens of thousands of double precision numbers).
I do not know if you tackled this issue already but the main missing part for me in the documentation about julia’s C interface was how to use it properly to load and interact with modules and how to handle special types. I was completely lost i the whole packing / unpacking of pointers to structures…
Also, there are some base types that exist in Julia that do not in .NET, so some conversions need to be done explicitely. For instance I discovered that my .NET (maybe it is a matter of version) did not support Int8.
I found almost no documentation, I just straight up read the Julia source code instead lol.
Regarding primitive types that are not cannot be converted, I personally have not run into any issues but I can have it promote them into larger containers if need be (Int8 → Int32 etc) but I havent had any issues so far.
I have just released the .NET 5.0 version of the project
Thanks for the link to the other thread, Ill see if at @Shuhua is willing to work together as I see he has done some work on natively converting C# arrays to Julia etc
Btw, Thoughts on implementing an abstract method interface for functions like what RuntimeMethod has and stuff? Can make it seem like a normal “method” object
Once GitHub - JuliaLang/juliaup: Julia installer and version multiplexer becomes more widely deployed you can just execute juliaup api getconfig1 and get back a JSON with information about installed Julia versions. At the moment this only works on Windows and if the user installed Julia from the Windows store, but I am very, very close to releasing the Mac and Linux version of this as well. The VS Code extension already tries this method to find the Julia binary, and then falls back to other ways if that doesn’t work.
So, this is more a FYI, maybe not entirely ready yet to be used, but should be much more ready in a few weeks.
For the using implementation, probaly have it store them all in a list for each “using JuliaInterface” context? Is it possible to create a variable when a module is “used”?
Then read the list in reverse order so last added using statement is checked first?
Here is the current Julia.NET .NET → Julia Interface:
@netusing Test
@netusing System
val1 = T"ReflectionTestClass".TestStateField[] #< Requires [] to actually get the field. If you dont put [] or () then it will just return the FieldInfo object
val2= T"ReflectionTestClass".StaticMethod[]() #To call a method. If you dont put [] or () then it will just return the MethodInfo object
val3 = T"ReflectionTestClass".StaticGenericMethod[T"Int64"]() "To call a generic method, put the generic types in []
item = T"ReflectionTestClass"".new[](3) #To call a constructor. If you dont put [] or () then it will just return the ConstructorInfo object
val4 = item.InstanceMethod[](); #To call a instance method
val5 = item.g[] #To Access a instance field
myGenericItem = T"ReflectionGenericTestClass`1".new[T"Int64"](3) #To Create a generic instance of an object, put the generic types in [].
boxed5 = sharpbox(5) #Will return the sharp object of the long value "5"
shouldBe5 = shapunbox(boxed5) #Will unbox the sharp object and return to native julia value
myClass = T"Test.ReflectionTestClass" #<= Perform Assembly Search and Return the Sharp Type
myClass2 = P"Test.ReflectionTestClass" #<= Perform one time assembly search and store the sharp type in a internal array (Reccommended for fast lookups)
myClass3 = G"Test.ReflectionTestClass" #Get from internal array
myClass4 = R"Test.ReflectionTestClass" #Remove from internal array
handle = pin(sharpbox(5)) #Pin the Sharp object in the Sharp GC
free(handle) #Will also auto free. You can also treat it like stream and put it in do end block
I moved Julia.NET to JuliadotNET to support it being a julia package.
I made a lot of changes to it recently. It was quite the effort trying to launch .NET from Julia lol.
But it seems to work! So you can now launch c# from julia and julia from c#. The julia->c# still needs a lot of work but it works in my tests
One thing I noticed is that you cant launch .NET from Julia if your in REPL for whatever reason. (Any thoughts on why this may be and how to fix it?)
I will be posting the package to the julia repo in the coming weeks
Have a look at DotNET.jl, I think it is possible to launch .NET but it needs to be .NET version 6.0 or greater. The .NET Framework is a different animal and doesn’t work, if I remember correctly.
Btw, your project looks amazing! I’ve also created something similar with struct mapping so you can use your Julia structs in C#. I’ll have a closer look and compare notes with you when I have some time.
I have been spending some time designing my own fork of julia from scratch (for fun!.. I think…). If I ever get it to work I could theoretically allow you to add a custom JIT compiler. I could add a CLR JIT Compiler with this directly allowing to inline julia into .NET.