[Mono-bugs] [Bug 73046][Nor] New - mcs/gmcs doesn't support new SecurityAction defined in 2.0

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 25 Feb 2005 18:03:15 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=73046

--- shadow/73046	2005-02-25 18:03:15.000000000 -0500
+++ shadow/73046.tmp.4097	2005-02-25 18:03:15.000000000 -0500
@@ -0,0 +1,95 @@
+Bug#: 73046
+Product: Mono: Compilers
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs/gmcs doesn't support new SecurityAction defined in 2.0
+
+Description of Problem:
+mcs/gmcs don't support new SecurityAction defined in 2.0
+
+Steps to reproduce the problem:
+1. Try compiling this with gmcs
+
+using System;
+using System.Security;
+using System.Security.Permissions;
+ 
+class Program {
+ 
+        [SecurityPermission (SecurityAction.DemandChoice, ControlPrincipal
+= true)]
+        [SecurityPermission (SecurityAction.DemandChoice, ControlThread =
+true)]
+        public int Execute ()
+        {
+                Console.WriteLine ("*0* Success (at least one condition was
+met)");
+                return 0;
+        }
+ 
+        static int Test ()
+        {
+                return new Program ().Execute ();
+        }
+ 
+        static int Main (string[] args)
+        {
+                try {
+                        return Test ();
+                }
+                catch (SecurityException se) {
+                        Console.WriteLine ("*1* Unexpected
+SecurityException\n{0}", se);
+                        return 1;
+                }
+        }
+}
+
+Actual Results:
+Error
+
+Expected Results:
+Success
+
+How often does this happen? 
+Always
+
+Additional Information:
+
+Adding this to gmcs did the trick for me.
+
+I had to use the integer value of the new SecurityAction enum's elements
+otherwise the compilation didn't work (? mcs use 1.0 to compile gmcs ?).
+
+Index: attribute.cs
+===================================================================
+--- attribute.cs        (revision 41194)
++++ attribute.cs        (working copy)
+@@ -760,6 +760,11 @@
+  
+                        if (!for_assembly) {
+                                if (action < SecurityAction.Demand ||
+action > SecurityAction.InheritanceDemand) {
++#if NET_2_0
++                                       // LinkDemandChoice,
+InheritanceDemandChoice and DemandChoice are new (and valid) in 2.0
++                                       if ((int)action >= 16 &&
+(int)action <= 18)
++                                               return true;
++#endif
+                                        Error_AttributeEmitError
+("SecurityAction is out of range");
+                                        return false;
+                                }