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

Opt-out or opt-in for build constants #4931

Closed
svrooij opened this issue Jul 3, 2024 · 2 comments
Closed

Opt-out or opt-in for build constants #4931

svrooij opened this issue Jul 3, 2024 · 2 comments
Labels
Csharp Pull requests that update .net code status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question

Comments

@svrooij
Copy link

svrooij commented Jul 3, 2024

Is your feature request related to a problem? Please describe the problem.

The dotnet code generated has a ton of build constants (for nullability compatibility for everything pre .net3.1). Can we get rid of them? Possibly by using an opt-in if you want them (loose the years old compatibility), or by using an opt-out (and not making a breaking change for people using Kiota on anything pre .net core 3.1)

The following 9 lines will only be 2 lines, everywhere in the generated client.

#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
        public async Task<List<.....App>?> GetAsync(Action<RequestConfiguration<....Apps.AppsRequestBuilder.AppsRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
        {
#nullable restore
#else
        public async Task<List<......App>> GetAsync(Action<RequestConfiguration<.....Apps.AppsRequestBuilder.AppsRequestBuilderGetQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
        {
#endif

Client library/SDK language

Csharp

Describe the solution you'd like

I would like to see all the build constants gone. I mean dotnet core 3.1 stopped being supported almost 2 years ago, so I think it's time to say goodbye to it.

And developers still targeting anything that doesn't support nullability might still want to opt-in to have code they can build by adding an optional parameter (but this would be a breaking change for them).

Additional context

No response

@svrooij svrooij added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Jul 3, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Jul 3, 2024
@msgraph-bot msgraph-bot bot added the Csharp Pull requests that update .net code label Jul 3, 2024
@baywet
Copy link
Member

baywet commented Jul 3, 2024

Hi @svrooij.
Thank you for bringing this up. The main reason why we have conditions here is because the code we generate is compatible with C# 7 .1
This is so we are compatible with net framework which was one of the requirements when we originally built the C# generation.
We've had many discussions on the topic over the last two years see the following issues:

I don't think there is much value into rehashing the same arguments over again come up we're unlikely to change any of that before a new major version.
Let us know if you have further questions or comments.

@baywet baywet added question status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Jul 3, 2024
@baywet baywet moved this from Needs Triage 🔍 to Waits for author 🔁 in Kiota Jul 3, 2024
@svrooij
Copy link
Author

svrooij commented Jul 3, 2024

Backwards compatibility can be accomplished by implementing this as opt-out, which would not break any existing functionality. I envision something like --nullable-compatible which would tell the generator yes I know I want opt-out of the old stuff.

But as discussed this would result in 50+ permutations. I was not able to find the previous issue because I search for the wrong key words, closing this one and following along the other issue.

@svrooij svrooij closed this as completed Jul 3, 2024
@github-project-automation github-project-automation bot moved this from Waits for author 🔁 to Done ✔️ in Kiota Jul 3, 2024
@svrooij svrooij closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Csharp Pull requests that update .net code status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question
Projects
Archived in project
Development

No branches or pull requests

2 participants