SuperAPI AI 工具集

connection-properties

智能体与模型

查看项目

更新于 10-16 00:31

技能介绍

用途:帮助 C# 开发者实现 Aspire 资源的连接属性,并验证其符合 IResourceWithConnectionString.GetConnectionProperties 的规则,同时把属性清单写入同目录 README.md。

主要能力:

  • 按规则生成常见连接属性:Host、Port、Password(可用时)、UserName(可用时)、Uri(服务资源 URL,形如 [protocol]://[username]:[password]@[host]:[port]/[subresource]?parameter=...)、DatabaseName、JdbcConnectionString。
  • Azure 属性仅在资源上下文可能部署于 Azure 时使用,值为 "true";且仅当资源具有 IsContainer、IsEmulator 或 InnerResource 属性时才可定义。
  • 若缺少 JdbcConnectionString 且存在该资源的 JDBC 连接在线文档,则补充创建。
  • 若资源类实现 IResourceWithParent,则连接属性应继承父资源属性,再定义自身属性覆盖对应值(如 Uri)。继承使用 ConnectionPropertiesExtensions.CombineProperties: IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() => Parent.CombineProperties([ new("Database", ReferenceExpression.Create($"{DatabaseName}")), new("Uri", UriExpression), new("JdbcConnectionString", JdbcConnectionString), ]);

文档:每个 Azure 资源的同目录 README.md 需更新,加入 GetConnectionProperties 中定义的连接属性列表。每个资源单独一张表,表头为 Property Name 与 Description;Uri 和 JdbcConnectionString 必须在描述中写明格式。属性以环境变量 [RESOURCE]_[PROPERTY] 暴露,例如名为 db1 的资源的 Uri 属性为 DB1_URI。Connection Properties 应位于外部链接(如 Additional documentation)之前。

适用场景:Aspire 资源与 README 的连接属性创建、补齐与核对。

限制:资料未提供更多命令行用法、依赖版本或平台细节。