Merge pull request #3071 from adamburgess/fix-ci-links
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 30 May 2016 10:36:55 +0000 (12:36 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 30 May 2016 10:36:55 +0000 (12:36 +0200)
Update README with new CI builds/badges

mcs/class/System.Transactions/System.Transactions-net_4_x.csproj
mcs/class/System.Transactions/System.Transactions.dll.sources
mcs/class/System.Transactions/System.Transactions/TransactionScope.cs
mcs/class/System.Transactions/System.Transactions/TransactionScopeAsyncFlowOption.cs [new file with mode: 0644]
mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/method-to-ir.c
mono/mini/mini-runtime.c

index b7eec4745fd762c591d986fee673ef8d9d736926..0040fd6840b17b446d8eaca8e51b434d279d5b46 100644 (file)
@@ -84,6 +84,7 @@
     <Compile Include="System.Transactions\TransactionOptions.cs" />\r
     <Compile Include="System.Transactions\TransactionPromotionException.cs" />\r
     <Compile Include="System.Transactions\TransactionScope.cs" />\r
+    <Compile Include="System.Transactions\TransactionScopeAsyncFlowOption.cs" />\r
     <Compile Include="System.Transactions\TransactionScopeOption.cs" />\r
     <Compile Include="System.Transactions\TransactionStatus.cs" />\r  </ItemGroup>\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
index 36d981ebe951bb5e44c41551e5a5fb73cd2aab50..4c5394f957bb36702e1d9ffb67534bdef8449232 100644 (file)
@@ -31,6 +31,7 @@ System.Transactions/TransactionManagerCommunicationException.cs
 System.Transactions/TransactionOptions.cs
 System.Transactions/TransactionPromotionException.cs
 System.Transactions/TransactionScope.cs
+System.Transactions/TransactionScopeAsyncFlowOption.cs
 System.Transactions/TransactionScopeOption.cs
 System.Transactions/TransactionStatus.cs
 System.Transactions/Configuration/DefaultSettingsSection.cs
index 129967d9e27817a140dcc077745d6c5828158e58..167d47e8d3a70e0a84be852e860f0e84c2bd10d0 100644 (file)
@@ -31,12 +31,20 @@ namespace System.Transactions
                bool completed;
                bool isRoot;
 
+               bool asyncFlowEnabled;
+
                public TransactionScope ()
                        : this (TransactionScopeOption.Required,
                                TransactionManager.DefaultTimeout)
                {
                }
 
+               public TransactionScope(TransactionScopeAsyncFlowOption asyncFlow)
+                       : this(TransactionScopeOption.Required,
+                               TransactionManager.DefaultTimeout, asyncFlow)
+               {
+               }
+
                public TransactionScope (Transaction transaction)
                        : this (transaction, TransactionManager.DefaultTimeout)
                {
@@ -53,7 +61,7 @@ namespace System.Transactions
                        TimeSpan timeout, DTCOption opt)
                {
                        Initialize (TransactionScopeOption.Required,
-                               transaction, defaultOptions, opt, timeout);
+                               transaction, defaultOptions, opt, timeout, TransactionScopeAsyncFlowOption.Suppress);
                }
 
                public TransactionScope (TransactionScopeOption option)
@@ -62,10 +70,21 @@ namespace System.Transactions
                }
 
                public TransactionScope (TransactionScopeOption option,
-                       TimeSpan timeout)
+                       TimeSpan timeout)
+                       : this (option, timeout, TransactionScopeAsyncFlowOption.Suppress)
+               {
+               }
+
+               public TransactionScope(TransactionScopeOption option, TransactionScopeAsyncFlowOption asyncFlow)
+                       : this(option, TransactionManager.DefaultTimeout, asyncFlow)
+               {
+               }
+
+       public TransactionScope (TransactionScopeOption option,
+                       TimeSpan timeout, TransactionScopeAsyncFlowOption asyncFlow)
                {
                        Initialize (option, null, defaultOptions,
-                               DTCOption.None, timeout);
+                               DTCOption.None, timeout, asyncFlow);
                }
 
                public TransactionScope (TransactionScopeOption scopeOption,
@@ -80,16 +99,17 @@ namespace System.Transactions
                        DTCOption opt)
                {
                        Initialize (scopeOption, null, options, opt,
-                               TransactionManager.DefaultTimeout);
+                               TransactionManager.DefaultTimeout, TransactionScopeAsyncFlowOption.Suppress);
                }
 
                void Initialize (TransactionScopeOption scopeOption,
                        Transaction tx, TransactionOptions options,
-                       DTCOption interop, TimeSpan timeout)
+                       DTCOption interop, TimeSpan timeout, TransactionScopeAsyncFlowOption asyncFlow)
                {
                        completed = false;
                        isRoot = false;
                        nested = 0;
+                       asyncFlowEnabled = asyncFlow == TransactionScopeAsyncFlowOption.Enabled;
 
                        if (timeout < TimeSpan.Zero)
                                throw new ArgumentOutOfRangeException ("timeout");
@@ -165,36 +185,67 @@ namespace System.Transactions
                                throw new InvalidOperationException ("TransactionScope nested incorrectly");
                        }
 
-                       if (Transaction.CurrentInternal != transaction) {
+                       if (Transaction.CurrentInternal != transaction && !asyncFlowEnabled) {
                                if (transaction != null)
                                        transaction.Rollback ();
                                if (Transaction.CurrentInternal != null)
                                        Transaction.CurrentInternal.Rollback ();
 
                                throw new InvalidOperationException ("Transaction.Current has changed inside of the TransactionScope");
-                       }
+                       } 
 
-                       if (Transaction.CurrentInternal == oldTransaction && oldTransaction != null)
-                               oldTransaction.Scope = parentScope;
+                       if (asyncFlowEnabled) {
+                               if (oldTransaction != null)
+                                       oldTransaction.Scope = parentScope;
 
-                       Transaction.CurrentInternal = oldTransaction;
+                               var variedTransaction = Transaction.CurrentInternal;
 
-                       if (transaction == null)
-                               /* scope was not in a transaction, (Suppress) */
-                               return;
+                               if (transaction == null && variedTransaction == null)
+                                       /* scope was not in a transaction, (Suppress) */
+                                       return;
 
-                       transaction.Scope = null;
+                               variedTransaction.Scope = parentScope;
+                               Transaction.CurrentInternal = oldTransaction;
 
-                       if (!IsComplete) {
-                               transaction.Rollback ();
-                               return;
-                       }
+                               transaction.Scope = null;
 
-                       if (!isRoot)
-                               /* Non-root scope has completed+ended */
-                               return;
+                               if (!IsComplete) {
+                                       transaction.Rollback ();
+                                       variedTransaction.Rollback();
+                                       return;
+                               }
+
+                               if (!isRoot)
+                                       /* Non-root scope has completed+ended */
+                                       return;
+
+                               variedTransaction.CommitInternal();
+                               transaction.CommitInternal();
+                       } else {
+                               if (Transaction.CurrentInternal == oldTransaction && oldTransaction != null)
+                                       oldTransaction.Scope = parentScope;
+
+                               Transaction.CurrentInternal = oldTransaction;
 
-                       transaction.CommitInternal ();
+                               if (transaction == null)
+                                       /* scope was not in a transaction, (Suppress) */
+                                       return;
+
+                               transaction.Scope = null;
+
+                               if (!IsComplete)
+                               {
+                                       transaction.Rollback();
+                                       return;
+                               }
+
+                               if (!isRoot)
+                                       /* Non-root scope has completed+ended */
+                                       return;
+
+                               transaction.CommitInternal();
+
+                       }
                }
 
 
diff --git a/mcs/class/System.Transactions/System.Transactions/TransactionScopeAsyncFlowOption.cs b/mcs/class/System.Transactions/System.Transactions/TransactionScopeAsyncFlowOption.cs
new file mode 100644 (file)
index 0000000..5285fe5
--- /dev/null
@@ -0,0 +1,9 @@
+
+namespace System.Transactions
+{
+       public enum TransactionScopeAsyncFlowOption
+       {
+               Suppress,
+               Enabled
+       }
+}
index eea343db4a75b35238914bf4a406f720891fb38e..39abeb285497461e407cb5f3f1bfb3dd0fa96d7b 100644 (file)
@@ -1869,3 +1869,17 @@ mono_interruption_checkpoint_from_trampoline (void)
        if (ex)
                mono_raise_exception (ex);
 }
+
+void
+mono_throw_method_access (MonoMethod *callee, MonoMethod *caller)
+{
+       char *callee_name = mono_method_full_name (callee, 1);
+       char *caller_name = mono_method_full_name (caller, 1);
+       MonoError error;
+
+       mono_error_init (&error);
+       mono_error_set_generic_error (&error, "System", "MethodAccessException", "Method `%s' is inaccessible from method `%s'\n", callee_name, caller_name);
+       mono_error_set_pending_exception (&error);
+       g_free (callee_name);
+       g_free (caller_name);
+}
index 8e2b37d367628cd1f4e3799960bd2622a77a410b..319ec902a013c47aaac095493c859aee047d2149 100644 (file)
@@ -224,4 +224,6 @@ MonoObject* mono_get_method_object (MonoMethod *method);
 
 double mono_ckfinite (double d);
 
+void mono_throw_method_access (MonoMethod *callee, MonoMethod *caller);
+
 #endif /* __MONO_JIT_ICALLS_H__ */
index 8758d4e89af7ca3e990a8133ec99086ee84b610d..ec4e6f429e462e45bc5388dda0501834aeb51601 100644 (file)
                if (cfg->exception_type != MONO_EXCEPTION_NONE) \
                        goto exception_exit;                                            \
        } while (0)
-#define METHOD_ACCESS_FAILURE(method, cmethod) do {                    \
-               method_access_failure ((cfg), (method), (cmethod));                     \
-               goto exception_exit;                                                                            \
-       } while (0)
 #define FIELD_ACCESS_FAILURE(method, field) do {                                       \
                field_access_failure ((cfg), (method), (field));                        \
                goto exception_exit;    \
@@ -377,17 +373,6 @@ break_on_unverified (void)
                G_BREAKPOINT ();
 }
 
-static MONO_NEVER_INLINE void
-method_access_failure (MonoCompile *cfg, MonoMethod *method, MonoMethod *cil_method)
-{
-       char *method_fname = mono_method_full_name (method, TRUE);
-       char *cil_method_fname = mono_method_full_name (cil_method, TRUE);
-       mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
-       mono_error_set_generic_error (&cfg->error, "System", "MethodAccessException", "Method `%s' is inaccessible from method `%s'\n", cil_method_fname, method_fname);
-       g_free (method_fname);
-       g_free (cil_method_fname);
-}
-
 static MONO_NEVER_INLINE void
 field_access_failure (MonoCompile *cfg, MonoMethod *method, MonoClassField *field)
 {
@@ -3156,6 +3141,18 @@ mono_emit_widen_call_res (MonoCompile *cfg, MonoInst *ins, MonoMethodSignature *
        return ins;
 }
 
+
+static void
+emit_method_access_failure (MonoCompile *cfg, MonoMethod *method, MonoMethod *cil_method)
+{
+       MonoInst *args [16];
+
+       args [0] = emit_get_rgctx_method (cfg, mono_method_check_context_used (method), method, MONO_RGCTX_INFO_METHOD);
+       args [1] = emit_get_rgctx_method (cfg, mono_method_check_context_used (cil_method), cil_method, MONO_RGCTX_INFO_METHOD);
+
+       mono_emit_jit_icall (cfg, mono_throw_method_access, args);
+}
+
 static MonoMethod*
 get_memcpy_method (void)
 {
@@ -9269,7 +9266,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                }
                                if (!mono_method_can_access_method (method_definition, target_method) &&
                                        !mono_method_can_access_method (method, cil_method))
-                                       METHOD_ACCESS_FAILURE (method, cil_method);
+                                       emit_method_access_failure (cfg, method, cil_method);
                        }
 
                        if (mono_security_core_clr_enabled ())
@@ -13080,7 +13077,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                                cil_method = cmethod;
                                if (!dont_verify && !cfg->skip_visibility && !mono_method_can_access_method (method, cmethod))
-                                       METHOD_ACCESS_FAILURE (method, cil_method);
+                                       emit_method_access_failure (cfg, method, cil_method);
 
                                if (mono_security_core_clr_enabled ())
                                        ensure_method_is_allowed_to_call_method (cfg, method, cmethod);
index b1cb79734d5b607f96df20034f6f866da27c07d9..9bb896ee4ee78fee3cf09cbd47c8913aca853c78 100644 (file)
@@ -3951,6 +3951,7 @@ register_icalls (void)
        register_icall (mono_llvmonly_init_delegate_virtual, "mono_llvmonly_init_delegate_virtual", "void object object ptr", TRUE);
        register_icall (mono_get_assembly_object, "mono_get_assembly_object", "object ptr", TRUE);
        register_icall (mono_get_method_object, "mono_get_method_object", "object ptr", TRUE);
+       register_icall (mono_throw_method_access, "mono_throw_method_access", "void ptr ptr", FALSE);
 
        register_icall_with_wrapper (mono_monitor_enter, "mono_monitor_enter", "void obj");
        register_icall_with_wrapper (mono_monitor_enter_v4, "mono_monitor_enter_v4", "void obj ptr");