Quiet down PostSharp warnings at build without skipping PostSharp
Asked Answered
H

2

15

I have PostSharp included in all of my projects, as per the recommended best practices for PostSharp. However, I don't have any aspects or other transformations in some of these assemblies; they just reference other projects that do have aspects in use.

At build time, I get the following warning:

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'.

Thanks for the info, PostSharp! But I've "considered disabling PostSharp for this module" and decided not to do so. I'm perfectly happy to lose a tiny bit of build-time performance, in exchange for not having to think about it later when I do decide to use PostSharp in a project previously devoid of aspects.

How do I get PostSharp to stop telling me about this hint, and without enabling SkipPostSharp?

Hellespont answered 26/9, 2013 at 0:14 Comment(0)
S
14

In your project properties under the PostSharp tab there is a line entry "Disabled Messages (semi-colon separated list)"

In that field enter the code for the particular message. I am not entirely sure what it is but try PS0121

Alternatively, if you manually edit your project file "*.csproj" you can add the PostSharpDisableMessages element into your PropertyGroup for your applicable configurations as shown below.

  <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>
Sharlenesharline answered 26/9, 2013 at 10:36 Comment(3)
It was PS0131, but THANK YOU!! I didn't know this disabled warnings section existed.Hellespont
I gather you have to install something extra to see a "PostSharp tab"? We use it without installing anything on the client and so I don't see any such tab. I don't suppose there's a way to do it without this?Centner
You need to install PostSharp Tools for Visual Studio to see the PostSharp tab in project properties window. It is available at postsharp.net/download.Wizen
J
5

You can quiet down these warnings from all the projects in your solution by adding a file to the solution folder called PostSharp.Custom.targets with the content:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PostSharpDisabledMessages>LA0156;PS0131</PostSharpDisabledMessages>
  </PropertyGroup>
</Project>

Where LA0156;PS0131 is a semicolon delimited list of the warnings you want to disable.

Specifically PS0131 disables

The project '<assembly name>' does not contain any aspect or other transformation. You can disable PostSharp for this project by editing the project properties in Visual Studio. Remember to enable PostSharp back if you add an aspect to this project.

And LA0156 disables

Missing code saving information on aspect type "<full type name>". Code saving metrics will be inaccurate. Add [LinesOfCodeAvoided] to the aspect class or specify the LinesOfCodeAvoided property of the advice custom attribute or ignore the warning LA0156.

Johnettajohnette answered 11/4, 2016 at 14:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.