Bug 43471 - pragma warning disable still shows warnings in "Errors" pad
Summary: pragma warning disable still shows warnings in "Errors" pad
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.4.2 (C7SR1)
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2016-08-17 16:13 UTC by alan.spires
Modified: 2016-08-18 21:15 UTC (History)
3 users (show)

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

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 alan.spires 2016-08-17 16:13:59 UTC

#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
	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: (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:

=== 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: (Xamarin Business)
Hash: f37444a
Branch: cycle7-sr1
Build date: 2016-07-28 12:17:02-0400

=== Xamarin.Mac ===

Version: (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.

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