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
2.07k stars 87 forks source link

Support multiple NativeMethods.json files #996

Closed Nuklon closed 1 year ago

Nuklon commented 1 year ago

Describe the solution you'd like While multiple NativeMethods.txt seem to work OK, the NativeMethods.json always picks the file in project folder. It'd be nice if it went up the tree and selected the first found NativeMethods.json (similar to Directory.build.props etc) so you can use multiple settings per NativeMethods.txt file.

AArnott commented 1 year ago

We don't support merging multiple NativeMethods.json files. But if you want the project to find a file that isn't in the project directory, you can always add <AdditionalFiles Include="..\..\NativeMethods.json"/> to your project file to point at the one you want CsWin32 to use.

Nuklon commented 1 year ago

In the root is OK but multiple json files would be useful as multiple txt are also supported. Now I have to split this up in multiple projects.

AArnott commented 1 year ago

What would you use support for multiple JSON files for? Can you give an example of content that you would put into each file that should be included by a single project, and describe why you chose to place each setting into each file?

Nuklon commented 1 year ago

I want some types not to use com marshaling, but more importantly, I would like some of the generated types public.

AArnott commented 1 year ago

I would like some of the generated types public.

We don't support generating some public and some non-public APIs. It's either all internal or all (approximately) public. If you want some to be public, you'll probably have to choose for it to all be public for one particular project and emit just the public APIs into that project. Then your other projects can emit internal APIs for their own use.

I want some types not to use com marshaling

allowMarshaling is another option that cannot be mixed. It's either on or off for the whole compilation.

Multiple JSON files will not get around the fundamental limitations that it seems you're hoping to use them to solve.

Nuklon commented 1 year ago

OK, then I guess this can be closed as not planned? :)