8000 Support `internal` access modifiers for generated types by OleRoss · Pull Request #183 · bottlenoselabs/c2cs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support internal access modifiers for generated types #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

OleRoss
Copy link
Contributor
@OleRoss OleRoss commented Apr 18, 2025

Motivation

First of all, thank you for providing this library. In my use case, I am generating bindings and only use them inside the assembly. I could not find a way to configure the access modifiers of the generated types, so this is my proposal to add them.

Changes

  • Added xml docs to AllocatorExtensions
  • Added AreTypeAccessModifiersPublic to c# generation options
    • public (true, default) or internal (false)
    • Iterate over all members in Runtime.g.cs and update modifiers
    • Update modifier in ClassName.g.cs

Only tested by hand. I did not find any unit tests covering settings. If there are any, please point me towards those.

OleRoss added 3 commits April 18, 2025 11:45
- Options are public (true, default) or internal (false)
- Iterate over all members in Runtime.g.cs and update modifiers
- Update modifier in ClassName.g.cs
No test is available in c2cs/artifacts/bin/c2cs.Tests/release/c2cs.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again
@lithiumtoast
Copy link
Member

Hey @OleRoss.

Thanks for the interest.

  1. Could you rename AreTypeAccessModifiersPublic to something that begins with IsEnabledXYZ? Both in the sanitized and un-sanitized classes? Perhaps like IsEnabledAccessModifierInternal?
  2. Do you have Rider installed? I ask because it's free now. I usually select the text or the whole document with a Code > Reformat and Cleanup ... > Built-in: Full Cleanup. This formats the XML documentation as well. Simple things like having a <typeparamref name="T"/> becomes <typeparamref name="T" />.

@OleRoss
Copy link
Contributor Author
OleRoss commented Apr 19, 2025
  1. Renamed to IsEnabledAccessModifierInternal
  2. I did the cleanup. However, the cleanup settings of my installation seem to differ from the current code style of the project, so I hope the cleanup is fine. The XML docs at least look ok.

@lithiumtoast
Copy link
Member

@OleRoss Is this ready to be merged as is?

As for automated tests, it would be good to look into but not a deal breaker as this feature is relatively small. You can check out the code folders in src/cs/tests/c2cs.Tests/Functions for examples. Each folder here is a relatively high level test that references C code and the .json config file in src/c/tests/functions. These generally match the tests in the c2ffi project as well.

@OleRoss
Copy link
Contributor Author
OleRoss commented Apr 21, 2025

From my side, yes, it is ready to merge.

If you like the testing structure in the pr #186, I could add tests there later.

@lithiumtoast lithiumtoast merged commit a318993 into bottlenoselabs:main Apr 23, 2025
3 checks passed
@lithiumtoast
Copy link
Member

I can do a release to NuGet if you want @OleRoss. Or are you using the tool by running it locally?

@OleRoss
Copy link
Contributor Author
OleRoss commented Apr 24, 2025

I am using the dotnet tool via the nuget package. So, a new nuget package would be appreciated

@lithiumtoast
Copy link
Member

I am using the dotnet tool via the nuget package. So, a new nuget package would be appreciated

Having issues with NuGet.org login. I'll try again this weekend.

@OleRoss
Copy link
Contributor Author
OleRoss commented Apr 25, 2025

No worries, thanks for your effort.

@lithiumtoast
Copy link
Member

@OleRoss Thanks for your patience. I resolved the NuGet.org license issue and was able to re-generate API key to upload packages to NuGet.org. You'll see your changes as part of the release:

I'll take a look at your changes for tests soon. Cheers.

@OleRoss
Copy link
Contributor Author
OleRoss commented May 2, 2025

@lithiumtoast No worries. Take your time, and thank you for creating the new version. The changes work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0