在 Visual Studio 2010 中记录 (XML) 应用程序设置

发布于 2024-08-31 17:10:46 字数 400 浏览 3 评论 0原文

我最近使用 Visual Studio (2010) 创建了一个 (C#) 项目,并使用了一些设置(我在“属性”下创建的)。

我发现唯一可以为我的文档添加一些 XML 注释的地方是 Settings.Designer.cs。 然而,该文件是自动生成的,因此每当我更改设置时,注释都会消失。

甚至 Visual Studio 也开始发出警告,“缺少公开可见类型或成员的 XML 注释......”

我的问题是: 将 XML 注释添加到我的“设置”的最简洁方法是什么?

  • 还有比 Settings.Designer.cs 更好的地方吗?
  • 我应该停止自动生成文件吗?如何?
  • 还有其他办法吗?

顺便说一下,我正在使用 Sandcastle 帮助文件生成器

I recently created a (C#) project with Visual Studio (2010) and used some Settings (which I created under Properties).

The only place I found where I can add some XML comments for my documentation, would be in Settings.Designer.cs.
However this file is auto-generated so whenever I change the Settings, the comments are gone.

Even Visual Studio gives started giving mewarnings, "Missing XML comment for publicity visibly type or member .... "

My question here is:
What is the neatest way to add XML comments to my Settings?

  • Is there a better place than Settings.Designer.cs?
  • Should I stop the file from being auto-generated? How?
  • Any other way?

I'm using Sandcastle Help File Builder by the way

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三生池水覆流年 2024-09-07 17:10:46

如果您打开设置(使用默认设计器),您可以在属性窗口中找到属性“描述”。填写它,它将在自动生成的文件中用作 XML 注释摘要。

If you open your settings (using default designer), you can find in properties window property "Description". Fill it in and it will be used as XML comment summary in autogenerated file.

ペ泪落弦音 2024-09-07 17:10:46

在您的 Settings.settings 文件中(不要使用设计器打开它),添加一个属性,例如“Description”:

<Setting Name="MySetting" Description="This property does blah blah blah" Type="System.Int32" Scope="Application">
  <Value Profile="(Default)">42</Value>
</Setting>

这将生成

/// <summary>
/// This property does blah blah blah
/// </summary>
[global...]
public int MySetting { ...

您还可以构建一个采用 Settings.settings 文件并创建 MAML 主题文件的工具。在项目的构建事件中调用该工具即可。

在我的测试中,如果您将描述作为设置元素的属性,那么如果您在设计器中更改设置,该属性将被保留。但是,如果将其作为设置元素的子元素,它将被删除。

In your Settings.settings file (don't open it with the designer), add an attribute, e.g. "Description":

<Setting Name="MySetting" Description="This property does blah blah blah" Type="System.Int32" Scope="Application">
  <Value Profile="(Default)">42</Value>
</Setting>

This will generate

/// <summary>
/// This property does blah blah blah
/// </summary>
[global...]
public int MySetting { ...

You can also build a tool that takes the Settings.settings file and create an MAML topic file. Call the tool in your project's build event and voilà.

In my tests, if you put the description as an attribute of the Setting element, it will be kept if you change the setting in the designer, the attribute will be kept. However, if you put it as a child of the Setting element, it will be deleted.

野心澎湃 2024-09-07 17:10:46

做到了。
还是不知道有没有更好的办法
但我在我的 Sandcastle HFB 项目中添加了一个 SettingsDoc.xml 。
缺点是它不是由 Visual Studio 编译的,所以我需要自己更新和检查参考资料等。

Did it.
I'm still not sure if there is a better way,
but i added a SettingsDoc.xml to my Sandcastle HFB project.
disadvantage is that it doesnt get compiled by visual studio, so I need to update and check references etc myself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文