Skip to content

[BUG]: CS0854 Compiler Error When Using Optional Arguments in Expression Trees #331

@cilerler

Description

@cilerler

What happened?

In the example below, the call to ProjectsV2(first: 10) inside the Select lambda results in this compiler error:

CS0854 - An expression tree may not contain a call or invocation that uses optional arguments.

It would be helpful to provide clearer guidance or workarounds.

var query = new Query()
                .Repository(owner: owner, name: repo)
                .Issue(number: issueNumber)
                .Select(i => new
		                {
			          i.Id,
			          i.Title,
			          i.Number,
			          Projects = i.ProjectsV2(first: 10).Nodes        // <=== CS0854
			            .Select(p => new
			              {
				              p.Number,
				              p.Title
			              })
		                });

Versions

Nuget: Octokit.GraphQL 0.40.0-beta

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    🔥 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions