Block distributed transaction usage on arm64 (#74226)
authorShay Rojansky <roji@roji.org>
Sun, 11 Sep 2022 10:41:25 +0000 (13:41 +0300)
committerGitHub <noreply@github.com>
Sun, 11 Sep 2022 10:41:25 +0000 (12:41 +0200)
And fix GUID interop in distributed transactions

See #74170

19 files changed:
src/libraries/System.Transactions.Local/src/Resources/Strings.resx
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/IPrepareInfo.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/IResourceManagerFactory2.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransaction.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionCloner.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionDispenser.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionEnlistmentAsync.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionExport.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionExportFactory.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionImport.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionOptions.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionOutcomeEvents.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionReceiver.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionReceiverFactory.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionResourceAsync.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionTransmitter.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionTransmitterFactory.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcInterfaces/ITransactionVoterNotifyAsync2.cs
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcProxyShimFactory.cs

index 2acf86b..0548f78 100644 (file)
   <data name="TraceSourceBase" xml:space="preserve">
     <value>[Base]</value>
   </data>
-  <data name="DistributedNotSupportOn32Bits" xml:space="preserve">
+  <data name="DistributedNotSupportedOn32Bits" xml:space="preserve">
     <value>Distributed transactions are currently unsupported in 32-bit processes.</value>
   </data>
-</root>
\ No newline at end of file
+  <data name="DistributedNotSupportedOnArm" xml:space="preserve">
+    <value>Distributed transactions are currently unsupported on ARM.</value>
+  </data>
+</root>
index 0b6c115..576f55f 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index b788a17..dd4777c 100644 (file)
@@ -10,15 +10,15 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
 internal interface IResourceManagerFactory2
 {
     internal void Create(
-        Guid pguidRM,
+        in Guid pguidRM,
         [MarshalAs(UnmanagedType.LPStr)] string pszRMName,
         [MarshalAs(UnmanagedType.Interface)] IResourceManagerSink pIResMgrSink,
         [MarshalAs(UnmanagedType.Interface)] out IResourceManager rm);
 
     internal void CreateEx(
-        Guid pguidRM,
+        in Guid pguidRM,
         [MarshalAs(UnmanagedType.LPStr)] string pszRMName,
         [MarshalAs(UnmanagedType.Interface)] IResourceManagerSink pIResMgrSink,
-        Guid riidRequested,
+        in Guid riidRequested,
         [MarshalAs(UnmanagedType.Interface)] out object rm);
 }
index a06acb7..de54474 100644 (file)
@@ -1,9 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
-using System.Transactions.Oletx;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
 
@@ -12,7 +10,7 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
 internal interface ITransaction
 {
     void Commit(
-        [MarshalAs(UnmanagedType.Bool)] bool fRetainingt,
+        [MarshalAs(UnmanagedType.Bool)] bool fRetaining,
         [MarshalAs(UnmanagedType.U4)] OletxXacttc grfTC,
         uint grfRM);
 
index 731e722..3090333 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index c45ea2c..d5ca436 100644 (file)
@@ -7,7 +7,7 @@ using System.Transactions.Oletx;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
 
-// https://docs.microsoft.com/previous-versions/windows/desktop/ms679525(v=vs.85)
+// https://docs.microsoft.com/previous-versions/windows/desktop/ms687604(v=vs.85)
 [ComImport, Guid(Guids.IID_ITransactionDispenser), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
 internal interface ITransactionDispenser
 {
index da73856..8fb42b4 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index 02f6436..75b6e7e 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index b82c8f5..0369283 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index 310f7d9..a7095a6 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
@@ -13,6 +12,6 @@ internal interface ITransactionImport
     void Import(
         uint cbTransactionCookie,
         [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] byte[] rgbTransactionCookie,
-        Guid piid,
+        in Guid piid,
         [MarshalAs(UnmanagedType.Interface)] out object ppvTransaction);
 }
index 645b4cb..6635861 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index d0cabc4..3627730 100644 (file)
@@ -10,11 +10,21 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
 [ComImport, Guid("3A6AD9E2-23B9-11cf-AD60-00AA00A74CCD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
 internal interface ITransactionOutcomeEvents
 {
-    void Committed([MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW /* always null? */, int hresult);
+    void Committed(
+        [MarshalAs(UnmanagedType.Bool)] bool fRetaining,
+        IntPtr pNewUOW,
+        int hresult);
 
-    void Aborted(IntPtr pboidReason, [MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW, int hresult);
+    void Aborted(
+        IntPtr pboidReason,
+        [MarshalAs(UnmanagedType.Bool)] bool fRetaining,
+        IntPtr pNewUOW,
+        int hresult);
 
-    void HeuristicDecision([MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision, IntPtr pboidReason, int hresult);
+    void HeuristicDecision(
+        [MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision,
+        IntPtr pboidReason,
+        int hresult);
 
     void Indoubt();
 }
index ec66d1c..1b1f388 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index 30f957c..8a29e99 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index fec5d00..79489c6 100644 (file)
@@ -1,9 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
-using System.Transactions.Oletx;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
 
@@ -19,7 +17,10 @@ internal interface ITransactionResourceAsync
 
     void CommitRequest(OletxXactRm grfRM, IntPtr pNewUOW);
 
-    void AbortRequest(IntPtr pboidReason, [MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW);
+    void AbortRequest(
+        IntPtr pboidReason,
+        [MarshalAs(UnmanagedType.Bool)] bool fRetaining,
+        IntPtr pNewUOW);
 
     void TMDown();
 }
index c427b9a..e00cba9 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index 73c7fa7..9179778 100644 (file)
@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System;
 using System.Runtime.InteropServices;
 
 namespace System.Transactions.DtcProxyShim.DtcInterfaces;
index 2eca406..9fb0abb 100644 (file)
@@ -10,11 +10,21 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
 [ComImport, Guid("5433376B-414D-11d3-B206-00C04FC2F3EF"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
 internal interface ITransactionVoterNotifyAsync2
 {
-    void Committed([MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW /* always null? */, uint hresult);
+    void Committed(
+        [MarshalAs(UnmanagedType.Bool)] bool fRetaining,
+        IntPtr pNewUOW,
+        uint hresult);
 
-    void Aborted(IntPtr pboidReason, [MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW, uint hresult);
+    void Aborted(
+        IntPtr pboidReason,
+        [MarshalAs(UnmanagedType.Bool)] bool fRetaining,
+        IntPtr pNewUOW,
+        uint hresult);
 
-    void HeuristicDecision([MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision, IntPtr pboidReason, uint hresult);
+    void HeuristicDecision(
+        [MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision,
+        IntPtr pboidReason,
+        uint hresult);
 
     void Indoubt();
 
index e8fe3c9..b1658bf 100644 (file)
@@ -59,9 +59,14 @@ internal sealed class DtcProxyShimFactory
         out byte[] whereabouts,
         out ResourceManagerShim resourceManagerShim)
     {
-        if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
+        switch (RuntimeInformation.ProcessArchitecture)
         {
-            throw new PlatformNotSupportedException(SR.DistributedNotSupportOn32Bits);
+            case Architecture.X86:
+                throw new PlatformNotSupportedException(SR.DistributedNotSupportedOn32Bits);
+
+            case Architecture.Armv6: // #74170
+            case Architecture.Arm64:
+                throw new PlatformNotSupportedException(SR.DistributedNotSupportedOnArm);
         }
 
         ConnectToProxyCore(nodeName, resourceManagerIdentifier, managedIdentifier, out nodeNameMatches, out whereabouts, out resourceManagerShim);