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

Incompatible .net Standard output #3829

Closed
scottlocknet opened this issue Nov 28, 2023 · 5 comments · Fixed by #3842
Closed

Incompatible .net Standard output #3829

scottlocknet opened this issue Nov 28, 2023 · 5 comments · Fixed by #3842
Assignees
Labels
Csharp Pull requests that update .net code help wanted Issue caused by core project dependency modules or library type:bug A broken experience WIP
Milestone

Comments

@scottlocknet
Copy link
Contributor

I've run into an issue with the c# code generated. It appears the writer is using c# 9 syntax for checking nulls. In the request builder, it does a 'if (id is not null)...' instead of a compatible 'if (id != null)...'.

@github-project-automation github-project-automation bot moved this to Todo in Kiota Nov 28, 2023
@baywet baywet self-assigned this Nov 28, 2023
@baywet baywet added question Csharp Pull requests that update .net code labels Nov 28, 2023
@baywet baywet added this to the Backlog milestone Nov 28, 2023
@baywet
Copy link
Member

baywet commented Nov 28, 2023

Hi @scottlocknet,
Thanks for using kiota and for reaching out.
Would you mind providing a snippet of what you are referring to please? It'd help locate the code and understand the issue better.

@scottlocknet
Copy link
Contributor Author

scottlocknet commented Nov 28, 2023

Not sure if I know how to ref a spot in code. I see in the Kiota/src/Kiota.Builder/Writers/CSharp/CSharpConventionService.cs on line 99, it has -> nullCheck = $"if ({identName} is not null) ";

That appears to be the piece that is producing the code that doesn't run with C# 7.3 (standard).

https://github.com/microsoft/kiota/blob/38c194ece93277ba3935c0e90bc8e2105b0760a2/src/Kiota.Builder/Writers/CSharp/CSharpConventionService.cs#L99C51-L99C51

Code that was generated looked like this:

    public class UsersWithUserIDRequestBuilder : BaseRequestBuilder {
        /// <summary>
        /// Instantiates a new UsersWithUserIDRequestBuilder and sets the default values.
        /// </summary>
        /// <param name="pathParameters">Path parameters for the request</param>
        /// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
        /// <param name="userID">The unique identifier of User</param>
        public UsersWithUserIDRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter, int? userID = default) : base(requestAdapter, "{+baseurl}/odata/AttDepartments({id})/users({userID}){?%24select,%24expand}", pathParameters) {
            if (userID is not null) PathParameters.Add("userID", userID);  /// * problem here with .net standard 2.0
        }

Thanks for the response. I love this tooling and it has saved us (me lol) many hours!

@baywet baywet modified the milestones: Backlog, Kiota v1.9 Nov 29, 2023
@baywet baywet assigned scottlocknet and unassigned baywet Nov 29, 2023
@baywet baywet added type:bug A broken experience help wanted Issue caused by core project dependency modules or library Needs: Author Feedback and removed question Needs: Attention 👋 labels Nov 29, 2023
@baywet
Copy link
Member

baywet commented Nov 29, 2023

Thanks for providing the details. Since you've identified the source of the issue in the code, would you mind submitting a pull request to address it please?

@scottlocknet
Copy link
Contributor Author

Sorry, I'm unable to get a push to work (getting 403) to submit the PR. I haven't pushed to a public repo, so I must be missing something about security (token or otherwise).

@baywet
Copy link
Member

baywet commented Nov 30, 2023

you should

  1. create a fork repository first under your user.
  2. add the remote to your fork git remote add downstream url where URL is the url of the fork you've just created.
  3. push the branch to the fork git push branchName downstream where branch name is the name of the branch you've worked on.
  4. create the pull request (make sure you select compare across forks)

Let us know if you have further questions.

scottlocknet added a commit to scottlocknet/kiota that referenced this issue Nov 30, 2023
Producing incompatible is not null check
@github-project-automation github-project-automation bot moved this from Todo to Done in Kiota Nov 30, 2023
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 help wanted Issue caused by core project dependency modules or library type:bug A broken experience WIP
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants