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

Generated c# interface for Client with internal modifier on DTO classes should be internal too #1363

Open
jonnybi opened this issue Jun 2, 2018 · 11 comments

Comments

@jonnybi
Copy link

jonnybi commented Jun 2, 2018

A public interface ist generated for a client that has access modifier set to internal and DTO classes have access modifier internal too.
The generated interface should have internal modifier too.

@RicoSuter
Copy link
Owner

The problem is that internal (or any fine grained modifieres) cannot be expressed by Swagger/JSON Schema...

@bangonkali
Copy link

Interesting. We could generate multiple results instead, one carrying the Swagger/Json Schema and the other is an optional file containing information regarding access modifiers.

@RicoSuter
Copy link
Owner

RicoSuter commented Jun 5, 2018

I think it would be better to implement a custom json schema processor class (NJsonSchema) which adds a new property (extension, via ExtensionData), eg ‘x-modifier’ and extend the template engine so that you can easily modify the modifieres with a custom extension...

@RicoSuter
Copy link
Owner

Ping me if you have time to help here... thx

@PolaEdward
Copy link

If the DTOs are being generated as internal, then the interface should follow the same, otherwise you will get
[CS0050] Inconsistent accessibility: return type....
So the simple fix is to use whatever access modifier used for DTOs for the interface also.

@jmevel
Copy link

jmevel commented Mar 13, 2024

Any update on this one?

@pbolduc
Copy link

pbolduc commented Mar 15, 2024

I think this file Client.Interface.liquid would need to use the TypeAccessModifier (The DTO class/enum access modifier). However, I was unable find the code/template that generates the DTO model types to verify the correct variable. Where are the models generated?

@RicoSuter Does this make sense? If this change was added would it be accepted in a PR? Did I identify the the correct variable that can be updated in the interface template reference? The interface must have at most the same level of access modified as the models it uses.

@pbolduc
Copy link

pbolduc commented Mar 17, 2024

Access Modifiers

Valid Modifiers:

  • public
  • internal

Invalid Modifiers

All of these modifieds will error out with CS1527 Elements defined in a namespace cannot be explicitly declared as private, protected, protected internal, or private protected

  • private
  • protected
  • protected internal
  • private protected

Combinations

valid class model interface
Yes public public public used when not granting access to the class, only the interface/types
Yes public public internal use case?
No public internal public Model is less accessible than method
No public internal internal Model is less accessible than method
Yes internal public public used when not granting access to the class, only the interface/types
Yes internal public internal used when you just want to expose the models
No internal internal public Model is less accessible than method
Yes internal internal internal used when hiding the generated client inside an assembly, by exposing a manually written service wrapping the calls

@jmevel
Copy link

jmevel commented Jun 12, 2024

Hi,

@RicoSuter or anyone else with enough rights on this repo, would that be possible to have a look at #4820 and see what's going on with the Macos build?

PR is (I think) ready to be merged but is stuck because of this...

Thanks a lot 🙏

@lahma
Copy link
Collaborator

lahma commented Jun 12, 2024

MacOS build failures should be fixed by #4896 , but it's not necessary to accept pending PRs. I should be OK if both Ubuntu and Windows build succeed.

@jmevel
Copy link

jmevel commented Jun 13, 2024

Ok that's good news.
#4896 is quite a big PR 😳

Thanks for your fast reply !

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

No branches or pull requests

7 participants