microsoft / microsoft/kiota

Format of generated c# code is wrong

Open
#7,898 2 comments 0 reactions 0 assignees View on GitHub
Csharp status:waiting-for-triage type:bug
Dominant language
C#
Stars
3.8k
Forks
333
Avg merge
16h 29m
Merged PRs (30d)
116

Description

### What are you generating using Kiota, clients or plugins?

API Client/SDK

### In what context or format are you using Kiota?

Windows executable

### Client library/SDK language

Csharp

### Describe the bug

No space between if and condition, also no brackets:
`if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body));`

### Expected behavior

The block should at least look like this:
`if (ReferenceEquals(body, null)) { throw new ArgumentNullException(nameof(body)); }`

### How to reproduce

`kiota generate --openapi https://aka.ms/graph/v1.0/openapi.yaml --include-path /me/todo/** --language CSharp --class-name TaskClient --namespace-name MyTaskApp.Client --output ./src/MyTaskApp/Client`

### Open API description file

_No response_

### Kiota Version

1.29.0

### Latest Kiota version known to work for scenario above?(Not required)

1.28.0

### Known Workarounds

Use outdated v1.28.0

### Configuration

_No response_

### Debug output

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by running the reported Kiota generate command with the Graph OpenAPI description and compare its C# output between versions 1.29.0 and 1.28.0. Inspect the generated conditional formatting and confirm that the newer output includes spacing and braces without changing other generated code; done means the regression is reproduced and covered by a verification case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.