C
C#3mo ago
charlie

✅ native code in .net

got a question about the native code in the dotnet universe. why do we need it? is there a way that we can remove the native code so that we can have better support on linux?
28 Replies
Somgör from Human Resources
Doesn't .NET already notify you when certain functions and such are only available on a specific OS? Afaik System.Drawing(.Common) has a warning telling you it's only available on Windows There shouldn't be any big issues running C#/.NET on a Linux system, I do it all the time
charlie
charlie3mo ago
why would we need native code in the first place
Somgör from Human Resources
Why would we not
charlie
charlie3mo ago
because then crtain classes don't exist for different platforms
Somgör from Human Resources
Native code depends on your OS features If for example System.Drawing is only available on Windows it might be, because the system libraries support it In that case you should blame Linux and not dotnet In most cases dotnet runs on any OS perfectly fine
leowest
leowest3mo ago
are u refering to something specific like WPF?
charlie
charlie3mo ago
why blame linux when you can just implement c calls or whatver and just make a pull request
leowest
leowest3mo ago
or some framework that is windows only? because if u are then the answer is that is not that simple using WPF as an example its so tied coupled with DirectX that you would need to completely rewrite it, in order to make it xplatform compatible
charlie
charlie3mo ago
so i'm learning the Cosmos framework https://github.com/CosmosOS/Cosmos . and i'm reading the discord and wondering why we have to make methods directly in C# that do the same thing as native code but can be packaged for other systems where the native code doesnt exist
GitHub
GitHub - CosmosOS/Cosmos: Cosmos is an operating system "constructi...
Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more! - CosmosOS/Cosmos
Somgör from Human Resources
Isn't MAUI already compatible with Linux etc if GUI is the issue Pluh
charlie
charlie3mo ago
isn't there a wy that we can just allow non native cod in a sandbox?
leowest
leowest3mo ago
can u provide some examples? because there are a lot of things that in order to access it you have to access the native code of the specific OS, as c# can't directly access it. by either wrapping around a library or something there is also the standardization problem between all distros
charlie
charlie3mo ago
so, plugs replace native code by writing them in C#. currently most of the community has to work around System.Void and it's related classes because it's a sort of "native" class. being able to work with something that would allow us to use them somewhere else would be nice like Cosmos. because i think we spend more time writing asm like code using X# or actual ASM code to get around this which brings up the point of even doing it in C# in the first place
leowest
leowest3mo ago
Plugs reads to me as the same of what LibraryImport and DllImport does
charlie
charlie3mo ago
GitHub
Cosmos/source/Cosmos.System2_Plugs/System at master · CosmosOS/Cosmos
Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more! - CosmosOS/Cosmos
leowest
leowest3mo ago
GitHub
Cosmos/source/Cosmos.Core_Plugs/Interop/Advapi32Impl.cs at master ·...
Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more! - CosmosOS/Cosmos
charlie
charlie3mo ago
so, from what i know, we re still working on dotnet 6 i think we are working onto dotnet 7
leowest
leowest3mo ago
well I dont know cosmos enough to tell details I just looked portions of it related to what u asked but DllImport exists since .net framework LibraryImport is new when it was introduced I am unware yeah libraryimport apparently was .net 7
charlie
charlie3mo ago
hmm, well we need a plug for the dll import from my testing with it
leowest
leowest3mo ago
but you should probably ask in #advanced tbh or even #allow-unsafe-blocks for things more indepth in terms of native code, interoperability etc
charlie
charlie3mo ago
ah, cheers isnt dotnet open source?
leowest
leowest3mo ago
it is you can also see the source of .net framework https://source.dot.net/ you can browse it there or in the github
charlie
charlie3mo ago
oh shit nice! is there a way to just download like the whole of the system class in one sweep?
leowest
leowest3mo ago
leowest
leowest3mo ago
but I would say no, specially in your case where version diverge but you can try
charlie
charlie3mo ago
oh nice. well i'm goimg to mark his with that checkmark
MODiX
MODiX3mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server
More Posts
✅ WPF - Accessing a TreeViewItem's root UserControl DataContext for a CommandI am trying to execute a Command which exists in the ViewModel bound to the root parent UserControl Can I call myself a software engineer, without knowing the miniscule details of how .NET works?I recently came across a blog post on dev.to saying that framework users are not Engineers, and we s✅ I need in help. How to use razor as html templater.I now using fluid as a templater but a lot of people says that razor is better alternative but I steI need help with fourmsI made a project to do a password checker and generator. i done most of it. But i am struggling how Copying a panelI'm makin a game like wordle clones for games i have a panel i want to copy it if value is wrong the✅ wanting to learn microservices for new job opportunities.I’ve successfully deployed an api to docker and connected to MySQL on my network. Now I’d like to leEnsure folder can be read/written to by current user, even if program is adminI want to ensure that a folder I create is fully accessible by the current user. I'm afraid that if WPF ContextMenu background color problemsI'm trying to implement a dark theme on a ContexMenu. I'm getting some strange artefacts around the ✅ How to handle errors in services/controllersHi! I do most of work in services and then call the method in the controller. What's the proper way Image ListHow can I make something like this? I am currently making an app which I want to give info on certai