Skip to content

Commit c55d76d

Browse files
authored
Port distributed transaction support for Windows (#72051)
Closes #715
1 parent 6a2c63f commit c55d76d

File tree

77 files changed

+10091
-755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+10091
-755
lines changed

src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ internal static partial class Libraries
4646
internal const string MsQuic = "msquic.dll";
4747
internal const string HostPolicy = "hostpolicy.dll";
4848
internal const string Ucrtbase = "ucrtbase.dll";
49+
internal const string Xolehlp = "xolehlp.dll";
4950
}
5051
}

src/libraries/System.Transactions.Local/src/Resources/Strings.resx

Lines changed: 367 additions & 38 deletions
Large diffs are not rendered by default.

src/libraries/System.Transactions.Local/src/System.Transactions.Local.csproj

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
<PropertyGroup>
33
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5-
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
5+
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)</TargetFrameworks>
6+
<NoWarn>CA1805;IDE0059;CS1591</NoWarn>
7+
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
8+
<IsTrimmable>false</IsTrimmable>
69
</PropertyGroup>
710
<ItemGroup>
811
<Compile Include="System\Transactions\CommittableTransaction.cs" />
912
<Compile Include="System\Transactions\DependentTransaction.cs" />
10-
<Compile Include="System\Transactions\DistributedTransaction.cs" />
1113
<Compile Include="System\Transactions\DurableEnlistmentState.cs" />
1214
<Compile Include="System\Transactions\EnterpriseServices.cs" />
1315
<Compile Include="System\Transactions\Enlistment.cs" />
1416
<Compile Include="System\Transactions\EnlistmentState.cs" />
1517
<Compile Include="System\Transactions\EnlistmentTraceIdentifier.cs" />
18+
<Compile Include="System\Transactions\IDtcTransaction.cs" />
1619
<Compile Include="System\Transactions\IEnlistmentNotification.cs" />
1720
<Compile Include="System\Transactions\InternalTransaction.cs" />
1821
<Compile Include="System\Transactions\IPromotableSinglePhaseNotification.cs" />
@@ -25,7 +28,6 @@
2528
<Compile Include="System\Transactions\Transaction.cs" />
2629
<Compile Include="System\Transactions\TransactionException.cs" />
2730
<Compile Include="System\Transactions\TransactionInformation.cs" />
28-
<Compile Include="System\Transactions\TransactionInterop.cs" />
2931
<Compile Include="System\Transactions\TransactionManager.cs" />
3032
<Compile Include="System\Transactions\TransactionOptions.cs" />
3133
<Compile Include="System\Transactions\TransactionScope.cs" />
@@ -40,13 +42,80 @@
4042
<Compile Include="System\Transactions\Configuration\DefaultSettingsSection.cs" />
4143
<Compile Include="System\Transactions\Configuration\MachineSettingsSection.cs" />
4244
</ItemGroup>
45+
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
46+
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs" Link="Common\Interop\Windows\Interop.Libraries.cs" />
47+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IPrepareInfo.cs" />
48+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IResourceManagerFactory2.cs" />
49+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IResourceManager.cs" />
50+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IResourceManagerSink.cs" />
51+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITmNodeName.cs" />
52+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransaction.cs" />
53+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionCloner.cs" />
54+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionExport.cs" />
55+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionExportFactory.cs" />
56+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionOptions.cs" />
57+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionDispenser.cs" />
58+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionEnlistmentAsync.cs" />
59+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionImport.cs" />
60+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionImportWhereabouts.cs" />
61+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionOutcomeEvents.cs" />
62+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionPhase0EnlistmentAsync.cs" />
63+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionPhase0Factory.cs" />
64+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionPhase0NotifyAsync.cs" />
65+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionReceiver.cs" />
66+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionReceiverFactory.cs" />
67+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionResourceAsync.cs" />
68+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionTransmitter.cs" />
69+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionTransmitterFactory.cs" />
70+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionVoterBallotAsync2.cs" />
71+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionVoterFactory2.cs" />
72+
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionVoterNotifyAsync2.cs" />
73+
<Compile Include="System\Transactions\DtcProxyShim\DtcProxyShimFactory.cs" />
74+
<Compile Include="System\Transactions\DtcProxyShim\EnlistmentNotifyShim.cs" />
75+
<Compile Include="System\Transactions\DtcProxyShim\EnlistmentShim.cs" />
76+
<Compile Include="System\Transactions\DtcProxyShim\Guids.cs" />
77+
<Compile Include="System\Transactions\DtcProxyShim\NativeEnums.cs" />
78+
<Compile Include="System\Transactions\DtcProxyShim\NotificationShimBase.cs" />
79+
<Compile Include="System\Transactions\DtcProxyShim\OletxHelper.cs" />
80+
<Compile Include="System\Transactions\DtcProxyShim\OletxXactTransInfo.cs" />
81+
<Compile Include="System\Transactions\DtcProxyShim\Phase0NotifyShim.cs" />
82+
<Compile Include="System\Transactions\DtcProxyShim\Phase0Shim.cs" />
83+
<Compile Include="System\Transactions\DtcProxyShim\ResourceManagerNotifyShim.cs" />
84+
<Compile Include="System\Transactions\DtcProxyShim\ResourceManagerShim.cs" />
85+
<Compile Include="System\Transactions\DtcProxyShim\TransactionNotifyShim.cs" />
86+
<Compile Include="System\Transactions\DtcProxyShim\TransactionOutcome.cs" />
87+
<Compile Include="System\Transactions\DtcProxyShim\TransactionShim.cs" />
88+
<Compile Include="System\Transactions\DtcProxyShim\VoterNotifyShim.cs" />
89+
<Compile Include="System\Transactions\DtcProxyShim\VoterShim.cs" />
90+
<Compile Include="System\Transactions\DtcProxyShim\Xactopt.cs" />
91+
<Compile Include="System\Transactions\Oletx\DtcTransactionManager.cs" />
92+
<Compile Include="System\Transactions\Oletx\OletxCommittableTransaction.cs" />
93+
<Compile Include="System\Transactions\Oletx\OletxDependentTransaction.cs" />
94+
<Compile Include="System\Transactions\Oletx\OletxEnlistment.cs" />
95+
<Compile Include="System\Transactions\Oletx\OletxResourceManager.cs" />
96+
<Compile Include="System\Transactions\Oletx\OletxTransaction.cs" />
97+
<Compile Include="System\Transactions\Oletx\OletxTransactionManager.cs" />
98+
<Compile Include="System\Transactions\Oletx\OletxVolatileEnlistment.cs" />
99+
<Compile Include="System\Transactions\TransactionInterop.cs" />
100+
</ItemGroup>
101+
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows'">
102+
<Compile Include="System\Transactions\TransactionInteropNonWindows.cs" />
103+
<Compile Include="System\Transactions\NonWindowsUnsupported.cs" />
104+
</ItemGroup>
43105
<ItemGroup>
106+
<Reference Include="System.Collections" />
107+
<Reference Include="System.Collections.Concurrent" />
108+
<Reference Include="System.ComponentModel" />
109+
<Reference Include="System.ComponentModel.Primitives" />
110+
<Reference Include="System.Diagnostics.Process" />
111+
<Reference Include="System.Diagnostics.TraceSource" />
44112
<Reference Include="System.Diagnostics.Tracing" />
45113
<Reference Include="System.Memory" />
46114
<Reference Include="System.Runtime" />
47115
<Reference Include="System.Runtime.InteropServices" />
48116
<Reference Include="System.Threading" />
49117
<Reference Include="System.Threading.Thread" />
50118
<Reference Include="System.Threading.ThreadPool" />
119+
<Reference Include="System.Xml.ReaderWriter" />
51120
</ItemGroup>
52121
</Project>

src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Runtime.Versioning;
66
using System.Threading;
77

8+
#pragma warning disable CS1591
9+
810
namespace System.Transactions
911
{
1012
[UnsupportedOSPlatform("browser")]
@@ -37,7 +39,7 @@ internal CommittableTransaction(IsolationLevel isoLevel, TimeSpan timeout) : bas
3739
TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
3840
if (etwLog.IsEnabled())
3941
{
40-
etwLog.TransactionCreated(this, "CommittableTransaction");
42+
etwLog.TransactionCreated(TraceSourceType.TraceSourceLtm, TransactionTraceId, "CommittableTransaction");
4143
}
4244
}
4345

@@ -47,7 +49,7 @@ public IAsyncResult BeginCommit(AsyncCallback? asyncCallback, object? asyncState
4749
if (etwLog.IsEnabled())
4850
{
4951
etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
50-
etwLog.TransactionCommit(this, "CommittableTransaction");
52+
etwLog.TransactionCommit(TraceSourceType.TraceSourceLtm, TransactionTraceId, "CommittableTransaction");
5153
}
5254

5355
ObjectDisposedException.ThrowIf(Disposed, this);
@@ -81,7 +83,7 @@ public void Commit()
8183
if (etwLog.IsEnabled())
8284
{
8385
etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
84-
etwLog.TransactionCommit(this, "CommittableTransaction");
86+
etwLog.TransactionCommit(TraceSourceType.TraceSourceLtm, TransactionTraceId, "CommittableTransaction");
8587
}
8688

8789
ObjectDisposedException.ThrowIf(Disposed, this);
@@ -113,7 +115,6 @@ public void Commit()
113115
{
114116
etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
115117
}
116-
117118
}
118119

119120
internal override void InternalDispose()

src/libraries/System.Transactions.Local/src/System/Transactions/DependentTransaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void Complete()
6161

6262
if (etwLog.IsEnabled())
6363
{
64-
etwLog.TransactionDependentCloneComplete(this, "DependentTransaction");
64+
etwLog.TransactionDependentCloneComplete(TraceSourceType.TraceSourceLtm, TransactionTraceId, "DependentTransaction");
6565
etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
6666
}
6767
}

src/libraries/System.Transactions.Local/src/System/Transactions/DistributedTransaction.cs

Lines changed: 0 additions & 166 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Runtime.InteropServices;
6+
7+
namespace System.Transactions.DtcProxyShim.DtcInterfaces;
8+
9+
// https://docs.microsoft.com/previous-versions/windows/desktop/ms686533(v=vs.85)
10+
[ComImport, Guid("80c7bfd0-87ee-11ce-8081-0080c758527e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
11+
internal interface IPrepareInfo
12+
{
13+
void GetPrepareInfoSize(out uint pcbPrepInfo);
14+
15+
void GetPrepareInfo([MarshalAs(UnmanagedType.LPArray), Out] byte[] pPrepInfo);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Runtime.InteropServices;
5+
6+
namespace System.Transactions.DtcProxyShim.DtcInterfaces;
7+
8+
// https://docs.microsoft.com/previous-versions/windows/desktop/ms681790(v=vs.85)
9+
[ComImport, Guid(Guids.IID_IResourceManager), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
10+
internal interface IResourceManager
11+
{
12+
internal void Enlist(
13+
[MarshalAs(UnmanagedType.Interface)] ITransaction pTransaction,
14+
[MarshalAs(UnmanagedType.Interface)] ITransactionResourceAsync pRes,
15+
out Guid pUOW,
16+
out OletxTransactionIsolationLevel pisoLevel,
17+
[MarshalAs(UnmanagedType.Interface)] out ITransactionEnlistmentAsync ppEnlist);
18+
19+
internal void Reenlist(
20+
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pPrepInfo,
21+
uint cbPrepInfom,
22+
uint lTimeout,
23+
[MarshalAs(UnmanagedType.I4)] out OletxXactStat pXactStat);
24+
25+
void ReenlistmentComplete();
26+
27+
void GetDistributedTransactionManager(
28+
in Guid riid,
29+
[MarshalAs(UnmanagedType.Interface)] out object ppvObject);
30+
}

0 commit comments

Comments
 (0)