Add --framework flag to minimize c# preprocessor directives #5122
Labels
Csharp
Pull requests that update .net code
status:waiting-for-author-feedback
Issue that we've responded but needs author feedback to close
status:waiting-for-triage
An issue that is yet to be reviewed or assigned
type:feature
New experience request
Is your feature request related to a problem? Please describe the problem.
Kiota generates code with C# preprocessor directives based on target framework. This code is larger than necessary when the target framework is known.
Consider the following generated code from Microsoft Graph that requires
#nullable
:Client library/SDK language
Csharp
Describe the solution you'd like
The above preprocessor directive may be eliminated with an optional Kiota CLI
--framework
argument, mimicking thedotnet build --framework
argument.For example:
kiota generate -o x.yaml -l csharp --framework net8.0
When --framework argument is missing: Preprocessor directives are generated as they currently are. The code above is generated as-is.
When --framework argument is present: No preprocessor directives are generated since the target framework is known. For example, in the example above, if the
--framework net8.0
is passed, the result would instead be:Additional context
Allowing the user to optionally enter a target framework reduces the amount of generated code and improves readability. Users who use Kiota-generated code across a range of .NET target environments and do not pass the proposed
--framework
argument would see no change in generated code.The text was updated successfully, but these errors were encountered: