Skip to content
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

Prevent methods renaming in Swift #155

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

niparx
Copy link

@niparx niparx commented Oct 30, 2023

If I'm using generated code in Swift project, then Swift will rename my methods into something else (they have some naming rules). That, basically brakes all thing: API then looking totally different. There is a macro NS_SWIFT_NAME, where you can put a name, which Swift will use (something like "I know what I'm doing. Please, Swift, leave method name as it is written in macro."). So, there is an option for that: to add or not to add this macro to every method of generated API.

Some more context about this Swift feature:

@niparx
Copy link
Author

niparx commented Oct 30, 2023

I suppose, some unit test should be created for this as well. Can somebody guide me here?

@a4z
Copy link
Contributor

a4z commented Oct 30, 2023

Thanks a lot for the PR!
It is excellent that you think about testing.

Tests are in the src/it folder.
For running them, please see the running tests documentation

Tests work basically so that there is an expected output file based on the given input.

  • src/it/resources has djinni files in the subfolder
  • src/it/resources/expected is the expected generated result from the djinni files based on the test
  • src/it/resources/result is created by the tests,

The tests do compare the generated files with the expected ones.

The test calls are in src/it/scala/djinni/GeneratorIntegrationTest.scala
From there, you call djinni with arguments and then compare the result with the expected content.

@a4z
Copy link
Contributor

a4z commented Nov 1, 2023

I haven't forgotten about the PR. I am just waiting on a little if tests will be added or not.
(The thumbs-up on my explanation/comment makes me kind of optimistic that we might get some)

@niparx
Copy link
Author

niparx commented Nov 3, 2023

I haven't forgotten about the PR. I am just waiting on a little if tests will be added or not. (The thumbs-up on my explanation/comment makes me kind of optimistic that we might get some)

Not forgotten. Writing tests + some minor improvements after feedback with Swift devs.

@niparx niparx marked this pull request as draft November 3, 2023 13:38
@niparx
Copy link
Author

niparx commented Nov 3, 2023

Converting to Draft, since still in progress

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