c# - 在不跳过 PostSharp 的情况下在构建时安静下来 PostSharp 警告

标签 c# .net msbuild postsharp

根据推荐的 PostSharp 最佳实践,我在我的所有项目中都包含了 PostSharp。但是,我在其中一些程序集中没有任何方面或其他转换;他们只是引用了其他确实有使用方面的项目。

在构建时,我收到以下警告:

The module 'xxxxxxx.dll' does not contain any aspect or other transformation. For improved build-time performance, consider disabling PostSharp for this module by setting the compilation symbol (aka constant) 'SkipPostSharp' in your project, or set the MSBuild property 'SkipPostSharp=True'.

感谢 PostSharp 提供的信息!但我“考虑过为这个模块禁用 PostSharp”并决定不这样做。我非常高兴损失一点点构建时性能,作为交换,当我决定在以前没有方面的项目中使用 PostSharp 时不必考虑它。

如何在不启用 SkipPostSharp 的情况下让 PostSharp 停止告诉我这个提示?

最佳答案

在 PostSharp 选项卡下的项目属性中,有一行条目“禁用消息(分号分隔列表)”

在该字段中输入特定消息的代码。我不完全确定它是什么,但试试 PS0121

或者,如果您手动编辑项目文件“*.csproj”,您可以将 PostSharpDisableMessages 元素添加到您的 PropertyGroup 中以进行适用的配置,如下所示。

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
    <PostSharpDisabledMessages>PS0131;PS0121</PostSharpDisabledMessages>
  </PropertyGroup>

关于c# - 在不跳过 PostSharp 的情况下在构建时安静下来 PostSharp 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19017247/

相关文章:

c# - 如何以编程方式检查 SMB 连接是否已加密?

.net - 为什么 Visual Studio 在 Azure DevOps checkin 时排除 BIN 和 OBJ 文件夹

.net - MSBuild 错误 MSB3086,与 TeamCity

c# - 不并行运行的异步方法

c# - 加载程序集和版本控制

.net - 代码分析改进

c# - 创建对特定 RID 的另一个项目的 NET Core 项目引用

c# - Java+Swing 比 C#+WinForms/WPF 有什么优势?

javascript - ASP.NET REST POST - JavaScript (jQuery) 在 POST 中发送正文

c# - 在 C# 中以结构作为返回值调用 C 函数