-
Notifications
You must be signed in to change notification settings - Fork 389
Remove static Coverage object #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
MarcoRossignoli
wants to merge
4
commits into
coverlet-coverage:master
from
MarcoRossignoli:removestatics
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,126 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using System.IO; | ||
using Newtonsoft.Json; | ||
|
||
namespace Coverlet.Core | ||
{ | ||
public class Line | ||
{ | ||
public int Number; | ||
public string Class; | ||
public string Method; | ||
public int Hits; | ||
} | ||
|
||
public class Branch : Line | ||
{ | ||
public int Offset; | ||
public int EndOffset; | ||
public int Path; | ||
public uint Ordinal; | ||
} | ||
|
||
public class BranchKeyConverter : TypeConverter | ||
{ | ||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) | ||
{ | ||
return sourceType == typeof(string); | ||
} | ||
|
||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) | ||
{ | ||
return JsonConvert.DeserializeObject<BranchKey>(value.ToString()); | ||
} | ||
|
||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) | ||
{ | ||
return destinationType == typeof(BranchKey); | ||
} | ||
} | ||
|
||
[TypeConverter(typeof(BranchKeyConverter))] | ||
public class BranchKey : IEquatable<BranchKey> | ||
{ | ||
public BranchKey(int line, int ordinal) => (Line, Ordinal) = (line, ordinal); | ||
|
||
public int Line { get; set; } | ||
public int Ordinal { get; set; } | ||
|
||
public override bool Equals(object obj) => Equals(obj); | ||
|
||
public bool Equals(BranchKey other) => other is BranchKey branchKey && branchKey.Line == this.Line && branchKey.Ordinal == this.Ordinal; | ||
|
||
public override int GetHashCode() | ||
{ | ||
return (this.Line, this.Ordinal).GetHashCode(); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return JsonConvert.SerializeObject(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for simplicity I used Json serializer. |
||
} | ||
} | ||
|
||
public class Document | ||
{ | ||
public Document() | ||
{ | ||
Lines = new Dictionary<int, Line>(); | ||
Branches = new Dictionary<BranchKey, Branch>(); | ||
} | ||
|
||
public string Path; | ||
public int Index; | ||
public Dictionary<int, Line> Lines { get; private set; } | ||
public Dictionary<BranchKey, Branch> Branches { get; private set; } | ||
} | ||
|
||
public class HitCandidate | ||
{ | ||
public HitCandidate(bool isBranch, int docIndex, int start, int end) => (this.IsBranch, this.DocIndex, this.Start, this.End) = (isBranch, docIndex, start, end); | ||
|
||
public bool IsBranch { get; set; } | ||
public int DocIndex { get; set; } | ||
public int Start { get; set; } | ||
public int End { get; set; } | ||
} | ||
|
||
public class InstrumenterResult | ||
{ | ||
public InstrumenterResult() | ||
{ | ||
Documents = new Dictionary<string, Document>(); | ||
HitCandidates = new List<HitCandidate>(); | ||
} | ||
|
||
public string Module; | ||
public string[] AsyncMachineStateMethod; | ||
public string HitsFilePath; | ||
public string ModulePath; | ||
public string SourceLink; | ||
public Dictionary<string, Document> Documents { get; private set; } | ||
public List<HitCandidate> HitCandidates { get; private set; } | ||
} | ||
|
||
public class InstrumenterState | ||
{ | ||
public InstrumenterResult[] InstrumenterResults { get; set; } | ||
public bool UseSourceLink { get; set; } | ||
public string Identifier { get; set; } | ||
public string MergeWith { get; set; } | ||
} | ||
|
||
public interface IInstrumenter | ||
{ | ||
InstrumenterState PrepareModules(); | ||
} | ||
|
||
public interface IInstrumentStateSerializer | ||
{ | ||
Stream Serialize(InstrumenterState instrumentState); | ||
InstrumenterState Deserialize(Stream serializedInstrumentState); | ||
} | ||
} |
This file contains hidden or 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
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need custom converter because Json serializer does not support serialization of complex dictionary key