【发布时间】:2018-05-29 19:39:46
【问题描述】:
我正在研究一种本地化遗留应用程序的解决方案。我使用 EnvDte 编写了一个 Visual Studio 插件,它可以自动将解决方案中每个表单的“可本地化”标志设置为 true,这是在表单设计器上提取资源的关键步骤。我现在正在尝试处理任何以编程方式设置的文本,即触发Globalization (CA13##) 警告的文本。
designer.Visible = true;
var host = (IDesignerHost)designer.Object;
var provider = TypeDescriptor.GetProvider(host.RootComponent);
var typeDescriptor = provider.GetExtendedTypeDescriptor(host.RootComponent);
if (typeDescriptor == null)
continue;
var propCollection = typeDescriptor.GetProperties();
var propDesc = propCollection["Localizable"];
if (propDesc != null && host.RootComponent != null &&
(bool?)propDesc.GetValue(host.RootComponent) != true)
{
try
{
propDesc.SetValue(host.RootComponent, true);
}
catch (Exception ex)
{
// log the error
}
// save changes
}
我已经能够从菜单中手动运行它,使用:分析 -> 运行代码分析 -> 解决方案 以获取问题列表,但我想自动执行此步骤另一个运行并提取结果的加载项。
是否有任何资源指向访问构建警告或代码分析结果?
有没有使用 EnvDte 或 Roslyn 的解决方案?
【问题讨论】:
标签: visual-studio envdte static-code-analysis roslyn-code-analysis