【发布时间】:2021-06-21 12:30:57
【问题描述】:
我有一个 c# 项目从 .NET 框架迁移到 .NET Core(然后是 .NET 5)。
我们已经有几年没有碰过我们的.resx 文件了,但是现在我更新了一个.resx 文件,Resources.Designer.cs 文件重新生成了(很好),删除了所有以前的-包含 Xml Doc(不好,产生很大的差异,也会丢失信息)。
如何指示我的 Resx 构建步骤像过去一样保留/生成 XML Doc?
最初这段代码是在 Windows 上使用 Visual Studio 编写和生成的,现在我们在 Mac 上使用 Rider
编辑:看起来它不是特定于 .NET 5,而是 Windows+VS 与 Mac+Rider 配对,因为我团队中的一个 Windows 开发人员在我的更改之上重新生成了这些 cmets。
如何在没有 Visual Studio 的 Mac/Linux 上获得此功能?
旧文件部分:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
...
/// <summary>
/// Looks up a localized string similar to About.
/// </summary>
public static string About {
get {
return ResourceManager.GetString("About", resourceCulture);
}
}
新文件部分:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Resources {
using System;
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
...
public static string About {
get {
return ResourceManager.GetString("About", resourceCulture);
}
}
有问题的文件从 12k LOC 下降到 8k LOC,这会丢失很多 cmets,并使处理变得更加困难。
【问题讨论】:
-
@HansPassant 我认为OP意味着自动生成的cmets丢失了,而不是它们最初是手动完成的。
-
@HansPassant 我只担心以前自动生成的 cmets,现在它们不是了。我可以在问题中更改什么以使其更明显吗?
标签: c# .net visual-studio resx xml-documentation