Skip to content

Commit d9cc23c

Browse files
authored
Add separate DeserializePacket() to INodePacketFactory (#11650)
### Context Minimum change to get shared IPC added in #11546 recompiling again for #11383 (since the original PR was reverted). ### Changes Made - Splits up `DeserializeAndRoutePacket()` in `PacketFactoryRecord` (private class) - Adds `DeserializePacket()` to `INodePacketFactory` and all implementations. Does not remove old method. - Adds ifdef's to shared pipe classes for compilation purposes No behavior changes to MSBuild.
2 parents b878078 + 60e11f7 commit d9cc23c

16 files changed

+156
-15
lines changed

eng/SourceBuildPrebuiltBaseline.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<UsagePattern IdentityGlob="System.Diagnostics.EventLog/*9.0.0*" />
2525
<!-- dependency of System.Resources.Extensions -->
2626
<UsagePattern IdentityGlob="System.Formats.Nrbf/*9.0.0*" />
27+
<!-- dependency of System.System.Threading.Channels -->
28+
<UsagePattern IdentityGlob="Microsoft.Bcl.AsyncInterfaces/*9.0.0*" />
2729
<!-- dependency of System.Security.Cryptography.Pkcs -->
2830
<UsagePattern IdentityGlob="Microsoft.Bcl.Cryptography/*9.0.0*" />
2931
</IgnorePatterns>

src/Build.UnitTests/BackEnd/NodeEndpointInProc_Tests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public void DeserializeAndRoutePacket(int nodeId, NodePacketType packetType, ITr
105105
throw new NotImplementedException();
106106
}
107107

108+
public INodePacket DeserializePacket(NodePacketType packetType, ITranslator translator)
109+
{
110+
throw new NotImplementedException();
111+
}
112+
108113
public void RoutePacket(int nodeId, INodePacket packet)
109114
{
110115
_dataReceivedContext = new DataReceivedContext(Thread.CurrentThread, packet);

src/Build/BackEnd/Client/MSBuildClientPacketPump.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ public void DeserializeAndRoutePacket(int nodeId, NodePacketType packetType, ITr
125125
_packetFactory.DeserializeAndRoutePacket(nodeId, packetType, translator);
126126
}
127127

128+
/// <summary>
129+
/// Deserializes a packet.
130+
/// </summary>
131+
/// <param name="packetType">The packet type.</param>
132+
/// <param name="translator">The translator to use as a source for packet data.</param>
133+
public INodePacket DeserializePacket(NodePacketType packetType, ITranslator translator)
134+
{
135+
return _packetFactory.DeserializePacket(packetType, translator);
136+
}
137+
128138
/// <summary>
129139
/// Routes a packet to the appropriate handler.
130140
/// </summary>

src/Build/BackEnd/Components/Communications/NodeManager.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ public void DeserializeAndRoutePacket(int nodeId, NodePacketType packetType, ITr
255255
_packetFactory.DeserializeAndRoutePacket(nodeId, packetType, translator);
256256
}
257257

258+
/// <summary>
259+
/// Takes a serializer and deserializes the packet.
260+
/// </summary>
261+
/// <param name="packetType">The packet type.</param>
262+
/// <param name="translator">The translator containing the data from which the packet should be reconstructed.</param>
263+
public INodePacket DeserializePacket(NodePacketType packetType, ITranslator translator)
264+
{
265+
return _packetFactory.DeserializePacket(packetType, translator);
266+
}
267+
258268
/// <summary>
259269
/// Routes the specified packet. This is called by the Inproc node directly since it does not have to do any deserialization
260270
/// </summary>

src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,16 @@ public void DeserializeAndRoutePacket(int nodeId, NodePacketType packetType, ITr
292292
ErrorUtilities.ThrowInternalErrorUnreachable();
293293
}
294294

295+
/// <summary>
296+
/// Deserializes and routes a packet. Not used in the in-proc node.
297+
/// </summary>
298+
public INodePacket DeserializePacket(NodePacketType packetType, ITranslator translator)
299+
{
300+
// Not used
301+
ErrorUtilities.ThrowInternalErrorUnreachable();
302+
return null;
303+
}
304+
295305
/// <summary>
296306
/// Routes a packet.
297307
/// </summary>

src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ public void DeserializeAndRoutePacket(int nodeId, NodePacketType packetType, ITr
287287
}
288288
}
289289

290+
/// <summary>
291+
/// Takes a serializer and deserializes the packet.
292+
/// </summary>
293+
/// <param name="packetType">The packet type.</param>
294+
/// <param name="translator">The translator containing the data from which the packet should be reconstructed.</param>
295+
public INodePacket DeserializePacket(NodePacketType packetType, ITranslator translator)
296+
{
297+
return _localPacketFactory.DeserializePacket(packetType, translator);
298+
}
299+
290300
/// <summary>
291301
/// Routes the specified packet
292302
/// </summary>

src/Build/BackEnd/Components/Communications/TaskHostNodeManager.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ public void DeserializeAndRoutePacket(int nodeId, NodePacketType packetType, ITr
149149
throw new NotSupportedException("not used");
150150
}
151151

152+
/// <summary>
153+
/// Takes a serializer, deserializes the packet and routes it to the appropriate handler.
154+
/// </summary>
155+
/// <param name="packetType">The packet type.</param>
156+
/// <param name="translator">The translator containing the data from which the packet should be reconstructed.</param>
157+
public INodePacket DeserializePacket(NodePacketType packetType, ITranslator translator)
158+
{
159+
throw new NotSupportedException("not used");
160+
}
161+
152162
/// <summary>
153163
/// Routes the specified packet. This is called by the Inproc node directly since it does not have to do any deserialization
154164
/// </summary>

src/Build/BackEnd/Node/InProcNode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ public void DeserializeAndRoutePacket(int nodeId, NodePacketType packetType, ITr
222222
ErrorUtilities.ThrowInternalError("Unexpected call to DeserializeAndRoutePacket on the in-proc node.");
223223
}
224224

225+
/// <summary>
226+
/// Not necessary for in-proc node - we don't serialize.
227+
/// </summary>
228+
public INodePacket DeserializePacket(NodePacketType packetType, ITranslator translator)
229+
{
230+
// The in-proc endpoint shouldn't be serializing, just routing.
231+
ErrorUtilities.ThrowInternalError("Unexpected call to DeserializePacket on the in-proc node.");
232+
return null;
233+
}
234+
225235
/// <summary>
226236
/// Routes the packet to the appropriate handler.
227237
/// </summary>

src/Build/BackEnd/Node/OutOfProcNode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,16 @@ void INodePacketFactory.DeserializeAndRoutePacket(int nodeId, NodePacketType pac
343343
_packetFactory.DeserializeAndRoutePacket(nodeId, packetType, translator);
344344
}
345345

346+
/// <summary>
347+
/// Deserializes a packet.
348+
/// </summary>
349+
/// <param name="packetType">The packet type.</param>
350+
/// <param name="translator">The translator to use as a source for packet data.</param>
351+
INodePacket INodePacketFactory.DeserializePacket(NodePacketType packetType, ITranslator translator)
352+
{
353+
return _packetFactory.DeserializePacket(packetType, translator);
354+
}
355+
346356
/// <summary>
347357
/// Routes a packet to the appropriate handler.
348358
/// </summary>

src/Build/BackEnd/Node/OutOfProcServerNode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ void INodePacketFactory.DeserializeAndRoutePacket(int nodeId, NodePacketType pac
210210
_packetFactory.DeserializeAndRoutePacket(nodeId, packetType, translator);
211211
}
212212

213+
/// <summary>
214+
/// Deserializes a packet.
215+
/// </summary>
216+
/// <param name="packetType">The packet type.</param>
217+
/// <param name="translator">The translator to use as a source for packet data.</param>
218+
INodePacket INodePacketFactory.DeserializePacket(NodePacketType packetType, ITranslator translator)
219+
{
220+
return _packetFactory.DeserializePacket(packetType, translator);
221+
}
222+
213223
/// <summary>
214224
/// Routes a packet to the appropriate handler.
215225
/// </summary>

0 commit comments

Comments
 (0)