-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from dotnetcore/testcodecov
Testcodecov
- Loading branch information
Showing
59 changed files
with
1,188 additions
and
400 deletions.
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
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
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
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
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
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
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
19 changes: 19 additions & 0 deletions
19
src/Natasha.CSharp/Extension/Natasha.CSharp.Codecov/Extension/AssemblyExtension.cs
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,19 @@ | ||
using Natasha.CSharp.Codecov.Utils; | ||
using System.Reflection; | ||
|
||
|
||
public static class AssemblyExtension | ||
{ | ||
public static List<(string MethodName, bool[] Usage)>? GetCodecovCollection(this Assembly assembly) | ||
{ | ||
var recorder = CodecovMonitor.GetRecorderFromAssmebly(assembly); | ||
return recorder.ToList(); | ||
} | ||
|
||
public static void ResetCodecov(this Assembly assembly) | ||
{ | ||
var recorder = CodecovMonitor.GetRecorderFromAssmebly(assembly); | ||
recorder.FlushPayload(); | ||
} | ||
} | ||
|
51 changes: 51 additions & 0 deletions
51
...tasha.CSharp/Extension/Natasha.CSharp.Codecov/Extension/AssenblyCSharpBuilderExtension.cs
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,51 @@ | ||
using Microsoft.CodeAnalysis.Emit; | ||
using Natasha.CSharp.Codecov.Utils; | ||
using System.Collections.Immutable; | ||
|
||
public static class AssenblyCSharpBuilder | ||
{ | ||
public static AssemblyCSharpBuilder WithCodecov(this AssemblyCSharpBuilder builder) | ||
{ | ||
builder.ConfigEmitOptions(opt => opt.WithInstrumentationKinds(ImmutableArray.Create(InstrumentationKind.TestCoverage))); | ||
builder.Add(@" | ||
namespace Microsoft.CodeAnalysis.Runtime | ||
{ | ||
public static class Instrumentation | ||
{ | ||
private static Natasha.CSharp.Codecov.Utils.CodecovRecorder _recorder = default!; | ||
public static bool[] CreatePayload(System.Guid mvid, int methodToken, int fileIndex, ref bool[] payload, int payloadLength) | ||
{ | ||
if(_recorder == null) | ||
{ | ||
_recorder = CodecovMonitor.GetRecorderFromType(typeof(Instrumentation)); | ||
} | ||
return _recorder.CreatePayload(mvid, methodToken, fileIndex, ref payload, payloadLength); | ||
} | ||
public static bool[] CreatePayload(System.Guid mvid, int methodToken, int[] fileIndices, ref bool[] payload, int payloadLength) | ||
{ | ||
if(_recorder == null) | ||
{ | ||
_recorder = CodecovMonitor.GetRecorderFromType(typeof(Instrumentation)); | ||
} | ||
return _recorder.CreatePayload(mvid, methodToken, fileIndices, ref payload, payloadLength); | ||
} | ||
public static void FlushPayload() | ||
{ | ||
_recorder.FlushPayload(); | ||
} | ||
} | ||
} | ||
"); | ||
builder.CompileSucceedEvent += Builder_CompileSucceedEvent; | ||
return builder; | ||
} | ||
|
||
private static void Builder_CompileSucceedEvent(Microsoft.CodeAnalysis.CSharp.CSharpCompilation arg1, System.Reflection.Assembly arg2) | ||
{ | ||
CodecovMonitor.AnalaysisAssemblyToCache(arg2); | ||
} | ||
} | ||
|
Oops, something went wrong.