Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Sep 23, 2024
1 parent 69fedb8 commit f094f28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/Draco.Coverage/CoverageResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace Draco.Coverage;
/// </summary>
public readonly struct CoverageResult(ImmutableArray<int> hits)
{
/// <summary>
/// Creates a new coverage result from the given shared memory.
/// </summary>
/// <param name="hits">The shared memory containing the hit counts.</param>
/// <returns>The coverage result.</returns>
public static CoverageResult FromSharedMemory(SharedMemory<int> hits) => new([.. hits.Span]);

/// <summary>
/// An empty coverage result.
/// </summary>
Expand Down
14 changes: 7 additions & 7 deletions src/Draco.Coverage/InstrumentedAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public static InstrumentedAssembly Create(Stream sourceStream, InstrumentationWe
/// <summary>
/// The sequence points of the weaved assembly.
/// </summary>
public ImmutableArray<SequencePoint> SequencePoints =>
this.sequencePoints ??= (ImmutableArray<SequencePoint>)this.SequencePointsField.GetValue(null)!;
private ImmutableArray<SequencePoint>? sequencePoints;
public SequencePoint[] SequencePoints =>
this.sequencePoints ??= NotNullOrNotWeaved((SequencePoint[]?)this.SequencePointsField.GetValue(null));
private SequencePoint[]? sequencePoints;

/// <summary>
/// Retrieves a copy of the coverage result.
/// </summary>
public CoverageResult CoverageResult => new([.. this.HitsInstance]);
public CoverageResult CoverageResult => CoverageResult.FromSharedMemory(this.HitsInstance);

/// <summary>
/// The coverage collector type weaved into the assembly.
Expand All @@ -102,9 +102,9 @@ public static InstrumentedAssembly Create(Stream sourceStream, InstrumentationWe
/// <summary>
/// The hits instance of the coverage collector.
/// </summary>
internal int[] HitsInstance =>
this.hitsInstance ??= NotNullOrNotWeaved((int[]?)this.HitsField.GetValue(null));
private int[]? hitsInstance;
internal SharedMemory<int> HitsInstance =>
this.hitsInstance ??= NotNullOrNotWeaved((SharedMemory<int>?)this.HitsField.GetValue(null));
private SharedMemory<int>? hitsInstance;

private InstrumentedAssembly(Assembly weavedAssembly)
{
Expand Down

0 comments on commit f094f28

Please sign in to comment.