microsoft / CsWin32

A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.
MIT License
1.99k stars 84 forks source link

Need help to choose between friendly and unsafe overloads #1093

Closed netcorefan1 closed 6 months ago

netcorefan1 commented 6 months ago

Hello, I'm in the process of converting all of my old code into CsWin32, but the presence of unsafe overloads makes me doubtful on what I should choose. Are there any advantages with the unsafe versions (speed, memory usage etc) ? I don't care if there is more code to write since all the needed apis will only be written once and exposed through my own wrapper. What I really care is safety. A quick list of what to do and what to not do would be really appreciated and helpful for all the other users that are in the same boat and need to know if going unsafe or not when porting their old code. Thanks