Bug 3157 - dmcs is not taking into account the System.Diagnostics.CodeAnalysis.SuppressMessage for unused vars
Summary: dmcs is not taking into account the System.Diagnostics.CodeAnalysis.SuppressM...
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2012-01-31 10:27 UTC by David Ferguson
Modified: 2012-01-31 13:51 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Quick test case to reproduce (432 bytes, text/x-csharp)
2012-01-31 10:27 UTC, David Ferguson

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description David Ferguson 2012-01-31 10:27:36 UTC
Created attachment 1293 [details]
Quick test case to reproduce

The following code compiles without a warning in Visual Studio 2010.  The warning is successfully suppressed via the attribute on the method in VS.NET, but not using dmcs.

using System;

namespace MonoTests
        public class HelloWorldSuppressTest
                public static void Main(string[] args)

                [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "myvar", Justification = "I like myvar")]
                private static void SuppressionTest()
                        var myvar = new HelloWorldSuppressTest();

The compiler being used is dmcs:

$ dmcs -warnaserror HelloWorldSuppressTest.cs 
HelloWorldSuppressTest.cs(15,29): error CS0219: Warning as Error: The variable `myvar' is assigned but its value is never used
Compilation failed: 1 error(s), 0 warnings

mono version is (master) as of Tuesday, January 31st:

$ mono --version
Mono JIT compiler version 2.11 (master/be171d2 Tue Jan 31 09:49:31 EST 2012)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            Included Boehm (with typed GC and Parallel Mark)
Comment 1 Marek Safar 2012-01-31 13:51:34 UTC
This is a feature