-
Notifications
You must be signed in to change notification settings - Fork 904
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
Add .NET client generator #5201
Conversation
c223b8b
to
e68fd95
Compare
Awesome work @joemphilips, my F# is pretty much inexistent, so I won't be able to verify this, but it seems to be doing what it's supposed to. The I'll cherry-pick 89f76ba into its own PR since I'd like to have that in v0.11.0 whose rc4 gets tagged today. Otherwise this PR just needs some minor python lint fixes and it's perfect to go in. Regarding nuget, that'd require this repo to get the publication secrets, which might not be something that you want to do. Shouldn't be hard to set up a separate cron job that just takes the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the same proposal of this PR #2223 should this F# version stay in the lightningd/plugin
repository that it is more a collection of tools built around core lightning?
0ee2696
to
2a5ec30
Compare
It's a bit different. since it is a complete analog of
I prefer this repo to have a publication secrets instead of running cron in someplace else. Since it is more maintainable. |
I don't see any difference, in this case, this repository should contain all the models generated in a different language? how I see the problem is that we should give the possibility to the user to use If the autogeneration model is useful we should extract the generator and not keep adding languages that from now on two hears can be unmaintained because the maintainer is no longer interested in it.
cln-rpc is an official one, like pylightning for the PR #2223 |
I don't mind having more bindings in the The reason it belongs in the @joemphilips likely we'll require an API key to push releases to the nuget repo, please don't include that in a PR but contact us directly so we can set it up as a secret to be used by Github Actions. |
Do you think that this can be a little bit confusing for people? because part of the binding are in https://github.com/lightningd/plugins and part here? BTW, I'm fine too, I'm just trying to find a guideline in my mind to keep this division between languages! A binding that uses msg gen can use the GitHub action to check if the model generation is updated with a cron job, so I think leaving this makes more hard also the in-flight fix from the maintainer because a PR can take time to enter in the master branch. and also if the maintainer change after a while of the unmaintained job ? or if the repository will kick out before a new maintainer came out? This is a common case that can happen, like me on https://github.com/laanwj/rust-clightning-rpc |
Here's my opinion about @vincenzopalazzo 's concern... I think what we should make clear here is which is ideal
2 seems ideal in terms of the maintainability issue that @vincenzopalazzo has mentioned. So probably these are the right way to go?
In this way I think we can enable consumers to generate wire spec from csv files in a similar way, that means including the functionality of lnspec-codegen into I'm not in hurry so if this seems the right way, I'll wait until the |
It is easy to abstract an extension for the
In my view, these points are related, and it is what I'm doing with https://github.com/vincenzopalazzo/monkeyc however the pack message in relative easy comparing the work required to do the work that a monkeyc is born for.
No! you can have your python implementation here of the generation code, and your F# model in your own repository, you need just to have a scrip in any language you like that clones lightning, generate the F# code and copy this code inside your model directory. However, if you use the chain of responsibility pattern, you could have the python implementation also in your own repository, and release the extension like the python package. A very good example of this "extension" model is serde in rust, which provides the interface for decoding and encoding a data model. each serde extension is released like a rust package. i.e: Considering that we are relying on code generation to generate the types, we could spend a couple of hours making an abstraction of |
msggen now produces F# request/response from schema.json files in a similar way to rust.
`importlib.metadata` is only usable in python 3.8+ And using backport described in python-poetry/poetry#273 (comment) will cause following error in CI. > "importlib_metadata.PackageNotFoundError: No package metadata was found for msggen" So lets just keep it simple by not having version information in genrated code.
2a5ec30
to
1ad422d
Compare
I finally got what you mean by this paragraph. Then this PR is ready, when CI passes. |
I can try to make a draft of it! I put it in my todo list |
According to the conversation in ElementsProject#5201, generated code for 3rd-party generater should not reside in this repository. Instead, only generators under `msggen` should be included. This commit adjusts F# generator to follow the following rule of thumb. 1. no native F# code, only generators, so every primitives are now reside in `msggen/fsharp.py` with plain text. 2. no object equivalent to `RPCClient`, only DTOs must be generated. Implementing client is now the consumers duty.
According to the conversation in ElementsProject#5201, generated code for 3rd-party generater should not reside in this repository. Instead, only generators under `msggen` should be included. This commit adjusts F# generator to follow the following rule of thumb. 1. no native F# code, only generators, so every primitives are now reside in `msggen/fsharp.py` with plain text. 2. no object equivalent to `RPCClient`, only DTOs must be generated. Implementing client is now the consumers duty.
44946c6
to
1c4e609
Compare
I've adjusted my F# generator a bit according to the rule that @vincenzopalazzo has mentioned, see the commit message for 6376342 I'm expecting @vincenzopalazzo to update
|
According to the conversation in ElementsProject#5201, generated code for 3rd-party generater should not reside in this repository. Instead, only generators under `msggen` should be included. This commit adjusts F# generator to follow the following rule of thumb. 1. no native F# code, only generators, so every primitives are now reside in `msggen/fsharp.py` with plain text. 2. no object equivalent to `RPCClient`, only DTOs must be generated. Implementing client is now the consumers duty.
1c4e609
to
efdf80b
Compare
According to the conversation in ElementsProject#5201, generated code for 3rd-party generater should not reside in this repository. Instead, only generators under `msggen` should be included. This commit adjusts F# generator to follow the following rule of thumb. 1. no native F# code, only generators, so every primitives are now reside in `msggen/fsharp.py` with plain text. 2. no object equivalent to `RPCClient`, only DTOs must be generated. Implementing client is now the consumers duty.
efdf80b
to
7cd142b
Compare
According to the conversation in ElementsProject#5201, generated code for 3rd-party generater should not reside in this repository. Instead, only generators under `msggen` should be included. This commit adjusts F# generator to follow the following rule of thumb. 1. no native F# code, only generators, so every primitives are now reside in `msggen/fsharp.py` with plain text. 2. no object equivalent to `RPCClient`, only DTOs must be generated. Implementing client is now the consumers duty.
7cd142b
to
6376342
Compare
Much simpler when def gen_dotnet(generator_chain: GeneratorChain):
fname = "<your path>"
dest = open(fname, "w")
generator_chain.add_generator(DotnetGenerator(dest))
if __name__ == "__main__":
generator_chain = GeneratorChain()
gen_dotnet(generator_chain, meta)
generator_chain.generate(service) And more important you can ship your An on flight draft of the solution #5216 |
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
Feel free to close this issue since #5216 seems to be more promising approach. |
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: ElementsProject/lightning#5201 It must be updated after ElementsProject/lightning#5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution.
This PR can be close, right? |
yes. I will close. |
This PR adds a new file
msggen/fsharp.py
which generates a F# files which can be consumed by .NET projects.It has no external dependency. It can be more user-friendly if I can add deps to NBitcoin and DotNetLightning but I chose simplicity over usability.
I have tested in my own project (both F#, C#). It seems working fine.
Questions:
cln-rpc
. Should I create another PR for it?