-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,84 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<ServerHandleValue /> | ||
<ClientHandleValue /> | ||
</PropertyGroup> | ||
|
||
<Target Name="BeforeCollectCodeCoverage" BeforeTargets="RunTests"> | ||
<BeforeCollectCodeCoverageTask TestAssembly="%(TestToRun.Identity)"> | ||
<Output TaskParameter="ServerHandleValue" PropertyName="ServerHandleValue" /> | ||
<Output TaskParameter="ClientHandleValue" PropertyName="ClientHandleValue" /> | ||
</BeforeCollectCodeCoverageTask> | ||
</Target> | ||
|
||
<Target Name="AfterCollectCodeCoverage" AfterTargets="RunTests"> | ||
<AfterCollectCodeCoverageTask ServerHandleValue="$(ServerHandleValue)" ClientHandleValue="$(ClientHandleValue)" /> | ||
</Target> | ||
|
||
<UsingTask | ||
TaskName="BeforeCollectCodeCoverageTask" | ||
TaskFactory="RoslynCodeTaskFactory" | ||
AssemblyName="Microsoft.Build.Tasks.Core"> | ||
|
||
<ParameterGroup> | ||
<TestAssembly ParameterType="System.String" Required="true" /> | ||
<ServerHandleValue ParameterType="System.Int64" Output="true" /> | ||
<ClientHandleValue ParameterType="System.Int64" Output="true" /> | ||
</ParameterGroup> | ||
|
||
<Task> | ||
<Using Namespace="System.Diagnostics" /> | ||
<Using Namespace="System.IO" /> | ||
<Using Namespace="System.IO.Pipes" /> | ||
<Using Namespace="Microsoft.Win32.SafeHandles" /> | ||
<Code> | ||
using var server = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable); | ||
|
||
ServerHandleValue = server.SafePipeHandle.DangerousGetHandle().ToInt64(); | ||
ClientHandleValue = server.ClientSafePipeHandle.DangerousGetHandle().ToInt64(); | ||
|
||
using var coverlet = Process.Start(@"$(DotNetTool)", $"tool run coverlet {TestAssembly} --target pwsh --targetargs \"-NoExit -Command [System.IO.Pipes.AnonymousPipeClientStream]::new([System.IO.Pipes.PipeDirection]::In, [Microsoft.Win32.SafeHandles.SafePipeHandle]::new({ClientHandleValue}, $true)).ReadByte()\""); | ||
|
||
var success = false; | ||
server.SafePipeHandle.DangerousAddRef(ref success); | ||
|
||
// TODO | ||
System.Threading.Thread.Sleep(10000); | ||
</Code> | ||
</Task> | ||
|
||
</UsingTask> | ||
|
||
<UsingTask | ||
TaskName="AfterCollectCodeCoverageTask" | ||
TaskFactory="RoslynCodeTaskFactory" | ||
AssemblyName="Microsoft.Build.Tasks.Core"> | ||
|
||
<ParameterGroup> | ||
<ServerHandleValue ParameterType="System.Int64" Required="true" /> | ||
<ClientHandleValue ParameterType="System.Int64" Required="true" /> | ||
</ParameterGroup> | ||
|
||
<Task> | ||
<Using Namespace="System.IO.Pipes" /> | ||
<Using Namespace="Microsoft.Win32.SafeHandles" /> | ||
<Code> | ||
using var server = new AnonymousPipeServerStream( | ||
PipeDirection.Out, | ||
new SafePipeHandle(new IntPtr(ServerHandleValue), true), | ||
new SafePipeHandle(new IntPtr(ClientHandleValue), true)); | ||
|
||
server.WriteByte(1); | ||
server.DisposeLocalCopyOfClientHandle(); | ||
|
||
// TODO | ||
System.Threading.Thread.Sleep(10000); | ||
</Code> | ||
</Task> | ||
|
||
</UsingTask> | ||
|
||
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" /> | ||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"coverlet.console": { | ||
"version": "1.6.0", | ||
"commands": [ | ||
"coverlet" | ||
] | ||
} | ||
} | ||
} |