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

CS8625 warnings on generated code #4727

Closed
andrueastman opened this issue May 27, 2024 · 4 comments
Closed

CS8625 warnings on generated code #4727

andrueastman opened this issue May 27, 2024 · 4 comments
Assignees
Labels
Csharp Pull requests that update .net code Status: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience

Comments

@andrueastman
Copy link
Member

Related to #4692

There is still a minor problem that causes CS8625 warnings on code like the following:

#nullable enable
        public async Task<UntypedNode?> DeleteAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
        {
#nullable restore
#else
        public async Task<UntypedNode> DeleteAsync(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
        {
#endif
            var requestInfo = ToDeleteRequestInformation(requestConfiguration);
            return await RequestAdapter.SendAsync<UntypedNode>(requestInfo, /* CS8625 ==> */default, null, cancellationToken).ConfigureAwait(false);
        }

warning CS8625: Cannot convert null literal to non-nullable reference type

Without delving further to determine if this manual fixup causes other issues, the warning goes away when patched as follows:

return await RequestAdapter.SendAsync<UntypedNode>(requestInfo, default!, null, cancellationToken).ConfigureAwait(false);

However, in my opinion, the generated code should compile without warnings and should not require manual fixups.

Originally posted by @johnholliday in #4692 (comment)

@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota May 27, 2024
@andrueastman andrueastman added the type:bug A broken experience label May 27, 2024
@andrueastman andrueastman added the Csharp Pull requests that update .net code label May 27, 2024
@andrueastman andrueastman moved this from Needs Triage 🔍 to Todo 📃 in Kiota Jun 3, 2024
@andrueastman andrueastman added this to the Backlog milestone Jun 5, 2024
@baywet
Copy link
Member

baywet commented Jun 10, 2024

Thanks for creating this.
This second parameter is of type ParsableFactory<ModelType> factory. Which I'm suspecting passing "default" actually translates to "null". We should instead be passing UntypedNode.CreateFromDiscriminatorValue. What do you think?

@andrueastman
Copy link
Member Author

Yeah. You're totally right.
The evaluation of the parameter should pass the UntypedNode.CreateFromDiscriminatorValue in this case.

@baywet baywet modified the milestones: Backlog, Kiota v1.17 Jun 11, 2024
@andrueastman andrueastman self-assigned this Jul 12, 2024
@andrueastman
Copy link
Member Author

After double checking this with the latest version, the generator already generates parameter correctly as UntypedNode.CreateFromDiscriminatorValue.

Testing with description from https://github.com/microsoft/kiota/files/15387323/Kiota.Test.zip also yields no CS8625 warnings as well.

@johnholliday Any chance you can confirm this is still an issue?

@andrueastman andrueastman added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Jul 12, 2024
@andrueastman andrueastman moved this from Todo 📃 to Waits for author 🔁 in Kiota Jul 12, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot removed this from the Kiota v1.17 milestone Jul 19, 2024
@github-project-automation github-project-automation bot moved this from Waits for author 🔁 to Done ✔️ in Kiota Jul 19, 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: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience
Projects
Archived in project
Development

No branches or pull requests

2 participants