Bug 43471

Summary: pragma warning disable still shows warnings in "Errors" pad
Product: [Mono] Compilers Reporter: alan.spires
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: matt.ward, mono-bugs+monodevelop, mono-bugs+mono
Priority: ---    
Version: 4.4.2 (C7SR1)   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description alan.spires 2016-08-17 16:13:59 UTC
Example.

#pragma warning disable CS0162 // Unreachable code detected
   Some Code
#pragma warning restore CS0162 // Unreachable code detected


In Errors Pad:
Api.cs(21,21): Warning CS0162: Unreachable code detected (CS0162) (APP)





=== Xamarin Studio Business ===

Version 6.0.2 (build 73)
Installation UUID: 6af89f91-ac7c-424b-9d39-3b89f09f1ada
Runtime:
	Mono 4.4.2 (mono-4.4.0-branch-c7sr1/f72fe45) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404020011

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.1.2.21 (Xamarin Business)
Android SDK: /Users/alan/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3  (API level 15)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 25.1.7
SDK Platform Tools Version: 24
SDK Build Tools Version: 23.0.3

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 7.3 (10183.3)
Build 7D175

=== Xamarin.iOS ===

Version: 9.8.2.22 (Xamarin Business)
Hash: f37444a
Branch: cycle7-sr1
Build date: 2016-07-28 12:17:02-0400

=== Xamarin.Mac ===

Version: 2.8.2.22 (Xamarin Business)

=== Build Information ===

Release ID: 600020073
Git revision: a6f7a24a9723a2d4f5d33c176615b0d44703ab5b
Build date: 2016-07-26 13:36:15-04
Xamarin addins: f5acb37866a0141bc5ddbe95118f18dae4014568
Build lane: monodevelop-lion-cycle7-sr1

=== Operating System ===

Mac OS X 10.11.6
Darwin Alans-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:25:34 PDT 2016
    root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
Comment 1 Matt Ward 2016-08-17 17:46:19 UTC
I suspect this is a compiler/xbuild difference compared with MSBuild on Windows. On the Mac you can remove the CS part of the warning code to fix the build warning:

#pragma warning disable 0162
   Some Code
#pragma warning restore 0162

Windows supports using CS0162 in the pragma this does not seem to work on the Mac.
Comment 2 Matt Ward 2016-08-17 17:56:42 UTC
MSBuild on Windows supports both formats for the code in the #pragma where as XBuild and MSBuild in Mono 4.4.2 does not.

Looking at the spec the CS part is optional.

https://msdn.microsoft.com/en-us/library/441722ys.aspx
Comment 3 alan.spires 2016-08-17 22:45:51 UTC
Ok but just to note. I was using the built in refactoring of Xam Studio to create those pragmas.
Comment 4 Matt Ward 2016-08-18 08:15:00 UTC
@Alan - Thanks. I have opened a separate bug #43501 for the code fix not generating a #pragma that works with Mono. This code fix may be coming from Roslyn so not sure if it is that easy to be fixed, but there is a separate bug report now logged against Xamarin Studio.
Comment 5 Marek Safar 2016-08-18 21:15:58 UTC
Fixed in master and Mono 4.6