# C# configuration options
Source: https://speakeasy.com/docs/speakeasy-reference/generation/csharp-config

import { Table } from "@/mdx/components";



 This section details the available configuration options for the C# SDK. All configuration is managed in the `gen.yaml` file under the `csharp` section.

## Version and general configuration

```yml
csharp:
  version: 1.2.3
  author: "Author Name"
  packageName: "custom-sdk"
  dotnetVersion: "net8.0"
  description: "A description of your SDK"
```

<Table 
  data={[
    { name: "version", required: "true", default: "0.0.1", description: "The current version of the SDK." },
    { name: "packageName", required: "true", default: "openapi", description: "The [NuGet package ID](https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-namespaces), also used as the root namespace" },
    { name: "author", required: "true", default: "Speakeasy", description: "The name of the [author](https://learn.microsoft.com/en-us/nuget/create-packages/package-authoring-best-practices#authors) of the published package." },
    { name: "dotnetVersion", required: "false", default: "dotnetVersion", description: "The [version](https://learn.microsoft.com/en-us/dotnet/standard/frameworks) of .NET to target. net8.0 (default), net6.0 and net5.0 supported." },
    { name: "description", required: "false", default: "Uses the OpenAPI spec's description or summary field", description: "A description of the SDK that will be included in the generated .csproj file." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Publishing configuration
```yml
csharp:
  packageTags: "openapi sdk rest"
  includeDebugSymbols: true
  enableSourceLink: true
```

<Table 
  data={[
    { name: "packageTags", required: "false", default: "\"\"", description: "Space-delimited list of tags and keywords used when searching for packages on NuGet." },
    { name: "includeDebugSymbols", required: "false", default: "false", description: "Whether to generate `.pdb` files and publish a `.snupkg` symbol package to NuGet." },
    { name: "enableSourceLink", required: "false", default: "false", description: "Whether to produce and publish the package with Source Link. See [Source Link](https://github.com/dotnet/sourcelink)." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Additional dependencies

```yml
csharp:
  additionalDependencies:
    - package: Newtonsoft.Json
      version: 13.0.3
```

<Table 
  data={[
    { name: "additionalDependencies", required: "false", default: "[]", description: "Add additional dependencies to include in the generated `.csproj` file. Dependencies must be specified as objects with package and version properties." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Method and parameter management
```yml
csharp:
  maxMethodParams: 4
  enableCancellationToken: true
```

<Table
  data={[
    { name: "[maxMethodParams](/docs/customize/methods)", required: "false", default: "4", description: "Maximum number of parameters before an input object is created. `0` means input objects are always used." },
    { name: "enableCancellationToken", required: "false", default: "true", description: "Enables cancellation token support in async methods and hooks." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Security configuration

```yml
csharp:
  flattenGlobalSecurity: true
```

<Table 
  data={[
    { property: "[flattenGlobalSecurity](/docs/customize/authentication/overview)", description: "Enables inline security credentials during SDK instantiation. **Recommended: `true`**", type: "boolean", default: "true" }
  ]}
  columns={[
    { key: "property", header: "Property" },
    { key: "description", header: "Description" },
    { key: "type", header: "Type" },
    { key: "default", header: "Default" }
  ]}
/>

## Module management

```yml
csharp:
  sourceDirectory: "src"
  disableNamespacePascalCasingApr2024: false
```

<Table 
  data={[
    { name: "sourceDirectory", required: "false", default: "src", description: "The name of the source directory." },
    { name: "disableNamespacePascalCasingApr2024", required: "false", default: "false", description: "Whether to disable Pascal Casing sanitization on the `packageName` when setting the root namespace and NuGet package ID." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Import management

```yml
csharp:
  imports:
    option: "openapi"
    paths:
      callbacks: models/callbacks
      errors: models/errors
      operations: models/operations
      shared: models/components
      webhooks: models/webhooks
```

<Table 
  data={[
    { field: "option", required: "false", default: "\"openapi\"", description: "Defines the type of import strategy. Typically set to `\"openapi\"`, indicating that the structure is based on the OpenAPI document." },
    { field: "paths", required: "false", default: "{}", description: "Customizes where different parts of the SDK (e.g., callbacks, errors, and operations) will be imported from." }
  ]}
  columns={[
    { key: "field", header: "Field" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

### Import paths

<Table 
  data={[
    { component: "callbacks", default: "models/callbacks", description: "The directory where callback models will be imported from." },
    { component: "errors", default: "models/errors", description: "The directory where error models will be imported from." },
    { component: "operations", default: "models/operations", description: "The directory where operation models (i.e., API endpoints) will be imported from." },
    { component: "shared", default: "models/components", description: "The directory for shared components, such as reusable schemas, and data models, imported from the OpenAPI spec." },
    { component: "webhooks", default: "models/webhooks", description: "The directory for webhook models, if the SDK includes support for webhooks." }
  ]}
  columns={[
    { key: "component", header: "Component" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Error and response handling
```yml
csharp:
  clientServerStatusCodesAsErrors: true
  responseFormat: "envelope-http"
```

<Table 
  data={[
    { name: "[responseFormat](/docs/customize/responses/responses)", required: "false", default: "envelope-http", description: "Defines how responses are structured. Options: `envelope`, `envelope-http`, or `flat`." },
    { name: "clientServerStatusCodesAsErrors", required: "false", default: "true", description: "Treats `4XX` and `5XX` status codes as errors. Set to `false` to treat them as normal responses." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>