Bug 4471 - Compiler crashes and allows illegal code on enums.
Summary: Compiler crashes and allows illegal code on enums.
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-04-16 17:48 UTC by JohanO
Modified: 2013-12-05 18:35 UTC (History)
3 users (show)

Tags:
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 Developer Community or GitHub 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:
Status:
RESOLVED NORESPONSE

Description JohanO 2012-04-16 17:48:37 UTC
Hi Folks,

I picked up the following error when adding attributes to my enum members without including the namespace where the attribute class is in. The compiler crashes on a method that uses the enum reporting that the method does not have a body which is incorrect.



using System;
//using JustEnough.Core.UI.Attributes; -- I forgot to include the namespace

namespace JustEnough.IPad.ViewControllers.Ordering
{
	public enum DocumentAction
	{
		[Caption("Printing")] -- My custom attribute
		Print,
		[Caption("E-Mail")]
		Email
	}
}

ERROR DETAILS


Unhandled Exception: Mono.CSharp.InternalErrorException: /Users/johanotto/Projects/JustCloud/IPad/Application/ViewControllers/Ordering/SalesOrderViewController.xib.cs(38,30): JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController ---> System.InvalidOperationException: Method 'JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController.GenerateDocument' does not have a method body.
  at System.Reflection.Emit.MethodBuilder.fixup () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.TypeBuilder.CreateType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: /Users/johanotto/Projects/JustCloud/IPad/Application/ViewControllers/Ordering/SalesOrderViewController.xib.cs(38,30): JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController ---> System.InvalidOperationException: Method 'JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController.GenerateDocument' does not have a method body.
  at System.Reflection.Emit.MethodBuilder.fixup () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.TypeBuilder.CreateType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 



Unhandled Exception: Mono.CSharp.InternalErrorException: /Users/johanotto/Projects/JustCloud/IPad/Application/ViewControllers/Ordering/SalesOrderViewController.xib.cs(38,30): JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController ---> System.InvalidOperationException: Method 'JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController.GenerateDocument' does not have a method body.
  at System.Reflection.Emit.MethodBuilder.fixup () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.TypeBuilder.CreateType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: /Users/johanotto/Projects/JustCloud/IPad/Application/ViewControllers/Ordering/SalesOrderViewController.xib.cs(38,30): JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController ---> System.InvalidOperationException: Method 'JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController.GenerateDocument' does not have a method body.
  at System.Reflection.Emit.MethodBuilder.fixup () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.TypeBuilder.CreateType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.CloseType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
Build complete -- 1 error, 0 warnings
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-04-16 18:01:15 UTC
I can't reproduce this, I pasted your code in a new project, and it failed with 4 compiler errors (but not a compiler crash like the one you got).

Maybe you can attach a full project I can use to reproduce it?
Comment 2 JohanO 2012-04-16 23:52:04 UTC
Rolf giving you project is not going to work. You probably need to recreate the caption attribute to replicate. I will see if I can create a project tomorrow but I warn you that I have a busy schedule so I can't spend too much time on this.

Circumstances:

Namespace X
{
CaptionAttribute: Attribute ....
}

The above code, and a class that has a method like this;

private void GenerateDocument(DocumentAction action)
{
  InvokeOnMainThread( () => 
  {
    switch(action) ...
  } );
....

}

As I said I try and recreate it. What was odd is I could replicate it straight away by just commenting out the namespace on the enum file,
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-04-17 06:21:18 UTC
I just tried adding the attribute too, and nothing changed.

Given the method the compiler is complaining about doesn't seem to be related to the enum at atll(JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController.GenerateDocument), it seems likely that the issue is as trivial as it looks at first.
Comment 4 Marek Safar 2012-04-23 07:46:56 UTC
The error is caused by code inside lambda error reporting (or lack of reporting to be correct) inside
JustEnough.IPad.ViewControllers.Ordering.SalesOrderViewController.GenerateDocument method. Could you paste body of the method?
Comment 5 PJ 2013-11-19 17:05:17 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 6 PJ 2013-12-05 18:35:37 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.