Bug 322511 (MONO79810) - [PATCH] CS1058 only applies to 2.0 profile
Summary: [PATCH] CS1058 only applies to 2.0 profile
Status: RESOLVED FIXED
Alias: MONO79810
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other All
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Gert Driesen
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-02 21:24 UTC by Gert Driesen
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Fix and tests (5.98 KB, patch)
2006-11-02 21:26 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:14:45 UTC


---- Reported by gert.driesen@pandora.be 2006-11-02 14:24:46 MST ----

Currently, mcs reports CS1058 for the following code fragment:

using System:

public class Test
{
  static void Main ()
  {
    try {
    } catch (Exception) {
    } catch {
    }
  }
}

CS1058 should be reported when:
* a catch (Exception) block is followed by a catch {} block
AND
* a RuntimeCompatibilityAttribute with WrapNonExceptionThrows set to true 
is applied to the assembly containing this code

However, in the 1.0 profile a RuntimeCompatibilityAttribute can never 
have been applied to an assembly, as this attribute is not part of the 
1.0 (.NET 1.1) API.

Also, currently we consider WrapNonExceptionThrows to be true by default, 
but this is not correct.

gmcs by default should and does add a RuntimeCompatibilityAttribute with 
WrapNonExceptionThrows set to true, but for assemblies built using 1.0 
profile (mcs), the RuntimeCompatibilityAttribute is not set by default 
and as such CS1058 should be reported.

The attached patch corrects this issue and adds tests for it.

One problem though: I added a test to verify that mcs no longer reports 
CS1058 for the code listed above, but all tests in mcs/tests are compiled 
using both mcs and gmcs, and since gmcs by default adds a 
RuntimeCompatibilityAttribute with WrapNonExceptionThrows set to true, 
that test fails on the 2.0 profile (gmcs reports CS1058, as it should). I 
hoped I could use #if NET_2_0 to add 2.0 specific code that would allow 
me to set WrapNonExceptionThrows to false, but apparently the NET_2_0 
symbol is not passes when compiling the tests using gmcs.

As a workaround, I added that test as a known issue to known_issues_gmcs 
and added a separate test for gmcs.



---- Additional Comments From gert.driesen@pandora.be 2006-11-02 14:26:30 MST ----

Created an attachment (id=170782)
Fix and tests




---- Additional Comments From rharinath@novell.com 2006-11-06 09:30:28 MST ----

The patch and tests look good.  I think you can apply.  And yes, the
known-issues-gmcs approach is the cleanest kludge :-(

Marek, do you have any comments?




---- Additional Comments From marek.safar@seznam.cz 2006-11-06 12:22:35 MST ----

Hello,

I would prefer a change like

+#if GMCS_SOURCE
 			wrap_non_exception_throws = true;
+#endif

Also I agree with known-issues-gmcs approach as temporary solution. 



---- Additional Comments From gert.driesen@pandora.be 2006-11-19 05:47:44 MST ----

Fixed in svn.

Imported an attachment (id=170782)