# @autorest/csharp 中文文档

规范地址：https://npmcn.com/package/%40autorest/csharp/

版本：3\.0\.0-beta\.20251203\.1
npm 元数据更新时间：2025-12-03T22:23:29.318Z
中文译文更新时间：2026-11-07T07:07:15.329Z
软件包许可：未声明

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40autorest/csharp
原文对照：https://npmcn.com/package/%40autorest/csharp/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：25.5 MB，125 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2020-12-17T22:07:25.471Z
- 最新版本发布：2025-12-03T22:23:29.078Z
- 近 30 天下载量：6793（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：1871（近 12 个月 1 个）

## 中文简介

详情见readme.md

## 安装

```sh
npm install @autorest/csharp
```

也可以使用：`pnpm add @autorest/csharp`、`yarn add @autorest/csharp`、`bun add @autorest/csharp`

## README

# 自动Rest. 共享

> 见 [https://aka.ms/autorest (英语)](https://aka.ms/autorest)

## 配置

```yaml
use-extension:
  "@autorest/modelerfour": "4.26.0"
modelerfour:
  always-create-content-type-parameter: true
pipeline:
  csharpgen:
    input: modelerfour/identity
  csharpgen/emitter:
    input: csharpgen
    scope: output-scope
output-scope:
  output-artifact: source-file-csharp
shared-source-folders: $(this-folder)/Generator.Shared;$(this-folder)/Azure.Core.Shared
```

```yaml
modelerfour:
  flatten-models: true
  flatten-payloads: true
  group-parameters: true
```

```yaml
use-extension:
  "@autorest/testmodeler": "2.6.1"

pipeline:
  test-modeler:
    input: modelerfour/identity
    scope : output-scope
  test-modeler/identity:
    input: test-modeler
  csharpgen:
    input: test-modeler/identity

modelerfour:
  emit-yaml-tags: true

testmodeler:
  use-parents-value: true
  split-parents-value: false
  add-armtemplate-payload-string: true

include-x-ms-examples-original-file: true
#   export-explicit-type: true
```

## 自定义

```yaml
directive:
  - from: swagger-document
    where: $.definitions.PrivateEndpointConnectionProperties
    transform: >
      $.properties.privateLinkServiceConnectionState["x-ms-client-name"] = "connectionState";   
```

## 帮助

```yaml
help-content:
  csharp: # type: Help as defined in autorest-core/help.ts
    activationScope: csharp
    categoryFriendlyName: C# Generator
    settings:
    - key: library-name
      description: The name of your library. This is what will be displayed on NuGet.
      type: string
    - key: shared-source-folders
      description: Pass shared folder paths through here. Common values point to the shared generator assets and shared azure core assets in autorest.csharp
      type: string
    - key: public-clients
      description: Whether to generate public client. Defaults to `false`.
      type: bool
    - key: model-namespace
      description: Whether to add a separate namespace of Models, more specifically adding `{value-from-namespace-flag}.Models`. Defaults to `true`.
      type: bool
```

## 常见问题

### @autorest/csharp 是什么？

详情见readme\.md

### 如何安装 @autorest/csharp？

在项目目录运行 npm install @autorest/csharp，或使用 pnpm add / yarn add / bun add。

### @autorest/csharp 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @autorest/csharp 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @autorest/csharp 可以商用吗？

@autorest/csharp 使用 未声明 许可。package\.json 没有声明许可证。没有许可证的代码默认保留全部权利，商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括，不构成法律意见，请以许可原文为准。

### @autorest/csharp 的下载量有多少？

根据 npm 官方下载统计，@autorest/csharp 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,793 次，日均约 226 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @autorest/csharp 还在维护吗？

最新版本 3\.0\.0-beta\.20251203\.1 发布于 2025/12/04（11 个月前）；至今共发布 1871 个版本，其中过去 12 个月发布了 1 个；首次发布于 2020/12/18。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

