Skip to content

Commit a767c4b

Browse files
committed
Some code cleanup
1 parent b04b8dd commit a767c4b

27 files changed

+310
-339
lines changed

CodeCoverage/Assets/BigFace.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8821,4 +8821,4 @@
88218821
</Color>
88228822
</Category>
88238823
</Theme>
8824-
</Themes>
8824+
</Themes>

CodeCoverage/CodeCoverage.vbproj

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
<Version>3.7.0</Version>
7575
</PackageReference>
7676
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
77-
<PackageReference Include="Newtonsoft.Json">
78-
<Version>12.0.3</Version>
79-
</PackageReference>
8077
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
8178
</ItemGroup>
8279
<ItemGroup>

CodeCoverage/Coverlet/ColorRTB.vb

+2-10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Imports CodeCoverage.Coverlet.Core
99

1010
Imports Microsoft.CodeAnalysis
1111

12-
Imports VBMsgBox
13-
1412
Public Module ColorRTB
1513

1614
Private Sub BuildLineTables(ConversionBuffer As RichTextBox, ByRef LineStarts() As Integer, ByRef LineEnds() As Integer)
@@ -162,14 +160,8 @@ Public Module ColorRTB
162160
Try ' Prevent crash when exiting
163161
With ConversionBuffer
164162
.Clear()
165-
.Select(.TextLength, 0)
166-
Dim TextToCompile As String = Nothing
167-
Using FileStream As FileStream = File.OpenRead(FileName)
168-
TextToCompile = GetFileTextFromStream(FileStream)
169-
Application.DoEvents()
170-
Colorize(CallingForm, TextToCompile, ConversionBuffer, FileName, ProgressBar)
171-
End Using
172-
163+
Call .Select(.TextLength, 0)
164+
Colorize(CallingForm, File.ReadAllText(FileName), ConversionBuffer, FileName, ProgressBar)
173165
End With
174166
Catch ex As Exception
175167
Stop

CodeCoverage/Coverlet/CoverageColorSelector.vb renamed to CodeCoverage/Coverlet/CoverageColorColors.vb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Imports System.IO
22

3-
Public Module CoverageColorSelector
3+
Public Module CoverageColorColors
44

55
Private ReadOnly FullPath As String = Path.Combine(FileIO.SpecialDirectories.MyDocuments, "CodeCoverageColorDictionary.csv")
66

@@ -59,13 +59,13 @@ Public Module CoverageColorSelector
5959
Friend Function GetColorFromName(Name As String) As (Foreground As Color, Background As Color)
6060
Try
6161
If String.IsNullOrWhiteSpace(Name) Then
62-
Return CodeColorSelector.ColorMappingDictionary("default")
62+
Return SyntaxHighlightingColors.ColorMappingDictionary("default")
6363
End If
64-
Return CodeColorSelector.ColorMappingDictionary(Name)
64+
Return SyntaxHighlightingColors.ColorMappingDictionary(Name)
6565
Catch ex As Exception
6666
Debug.Print($"GetColorFromName missing({Name})")
6767
Stop
68-
Return CodeColorSelector.ColorMappingDictionary("error")
68+
Return SyntaxHighlightingColors.ColorMappingDictionary("error")
6969
End Try
7070
End Function
7171

CodeCoverage/Coverlet/CoverageColors.vb

+1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@
7272
ColorMappingDictionary("Method Missed") = (value, ColorMappingDictionary("Default").Background)
7373
End Set
7474
End Property
75+
7576
End Class

CodeCoverage/Coverlet/CoverageResult.vb

+38-19
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,83 @@
44

55
Namespace Coverlet.Core
66

7+
Public Class BranchesCollection
8+
Inherits List(Of BranchInfo)
9+
10+
Sub New()
11+
12+
End Sub
13+
14+
End Class
15+
716
Public Class BranchInfo
817

18+
Public Property EndOffset As Integer
19+
Public Property Hits As Integer
920
Public Property Line As Integer
1021

1122
Public Property Offset As Integer
23+
Public Property Ordinal As UInteger
24+
Public Property Path As Integer
25+
End Class
1226

13-
Public Property EndOffset As Integer
27+
Public Class ClassesDictionary
28+
Inherits Dictionary(Of String, MethodsDictionary)
1429

15-
Public Property Path As Integer
30+
Sub New()
1631

17-
Public Property Ordinal As UInteger
32+
End Sub
1833

19-
Public Property Hits As Integer
34+
End Class
35+
36+
Public Class DocumentsDictionary
37+
Inherits Dictionary(Of String, ClassesDictionary)
38+
39+
Sub New()
40+
41+
End Sub
2042

2143
End Class
2244

2345
Public Class LinesDictionary
2446
Inherits SortedDictionary(Of Integer, Integer)
25-
End Class
2647

27-
Public Class BranchesCollection
28-
Inherits List(Of BranchInfo)
48+
Sub New()
49+
50+
End Sub
51+
2952
End Class
3053

3154
Public Class Method
3255

33-
Friend Sub New()
56+
Public Sub New()
3457

3558
Lines = New LinesDictionary
3659

3760
Branches = New BranchesCollection()
3861

3962
End Sub
4063

41-
Public ReadOnly Property Lines As LinesDictionary
42-
4364
Public ReadOnly Property Branches As BranchesCollection
44-
65+
Public ReadOnly Property Lines As LinesDictionary
4566
End Class
4667

4768
Public Class MethodsDictionary
4869
Inherits Dictionary(Of String, Method)
4970

50-
End Class
51-
52-
Public Class ClassesDictionary
53-
Inherits Dictionary(Of String, MethodsDictionary)
54-
55-
End Class
71+
Sub New()
5672

57-
Public Class DocumentsDictionary
58-
Inherits Dictionary(Of String, ClassesDictionary)
73+
End Sub
5974

6075
End Class
6176

6277
Public Class ModulesDictionary
6378
Inherits Dictionary(Of String, DocumentsDictionary)
6479

80+
Sub New()
81+
82+
End Sub
83+
6584
End Class
6685

6786
End Namespace

CodeCoverage/Coverlet/CoverletTreeView.vb

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Namespace Coverlet.Core
1515

1616
Friend Sub New(JSONFileWithPath As String, TreeView1 As TreeView, ByRef DocumentList As List(Of DirectoryClass), MethodsList As List(Of MethodClass))
1717
Dim jsonString As String
18-
Using FileStream As FileStream = File.OpenRead(JSONFileWithPath)
19-
jsonString = GetFileTextFromStream(FileStream)
20-
End Using
18+
jsonString = File.ReadAllText(JSONFileWithPath)
2119
DocumentCoverageModifiedDate = File.GetLastWriteTime(JSONFileWithPath)
2220
DocumentCoverageSummary = New CoverageSummary
23-
_CodeCoverageRoot = Newtonsoft.Json.JsonConvert.DeserializeObject(Of ModulesDictionary)(jsonString)
21+
22+
_CodeCoverageRoot = Text.Json.JsonSerializer.Deserialize(Of ModulesDictionary)(jsonString)
23+
2424
Dim FileInfo As FileInfo = New FileInfo(JSONFileWithPath)
2525
Dim parentNode As TreeNode = TreeView1.Nodes.Add($"Code Coverage, file {FileInfo.Directory.Name}{Path.PathSeparator}{FileInfo.Name}, Last Updated {FileInfo.LastWriteTime.Date.ToShortDateString} {FileInfo.LastWriteTime.TimeOfDay.Hours}:{FileInfo.LastWriteTime.ToShortTimeString}")
2626
TreeView1.Nodes(0).Tag = CodeCoverageTag
@@ -197,6 +197,7 @@ Namespace Coverlet.Core
197197
ColorParentNodes(parentNode, BackColor)
198198
Return Hit
199199
End Function
200+
200201
Public Shared Function GetModule(FileNameWithPath As String) As ClassesDictionary
201202
If CodeCoverageRoot IsNot Nothing AndAlso CodeCoverageRoot.Count > 0 Then
202203
For Each ngObject As KeyValuePair(Of String, DocumentsDictionary) In CodeCoverageRoot

CodeCoverage/Coverlet/Extensions/ControlExtensions.vb

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Option Explicit On
22
Option Infer Off
33
Option Strict On
4+
45
Imports System.Runtime.CompilerServices
56

67
Imports CodeCoverage.Microsoft.VisualBasic.CompilerServices.NativeMethods
78

89
Public Module ControlExtensions
10+
911
<Extension()>
1012
Friend Sub Suspend(Crtl As Control)
1113
LockWindowUpdate(Crtl.Handle)

CodeCoverage/DirectoryClass.vb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
' See the LICENSE file in the project root for more information.
44

55
Public Class DirectoryClass
6+
67
Sub New(mShortName As String, mFullname As String, mDirectoryNode As TreeNode)
78
_ShortName = mShortName
89
_FullPath = mFullname

CodeCoverage/Extensions/StringExtensions.vb

+1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ Public Module StringExtensions
1818
Contracts.Contract.Requires(value IsNot Nothing)
1919
Return value.Count(Function(c As Char) c = ch)
2020
End Function
21+
2122
End Module

CodeCoverage/Form1.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Public Class Form1
4949
My.Settings.Save()
5050
End If
5151

52-
CoverageColorSelector.UpdateColorDictionaryFromFile()
53-
CodeColorSelector.UpdateDictionaryFromFile()
52+
CoverageColorColors.UpdateColorDictionaryFromFile()
53+
SyntaxHighlightingColors.UpdateDictionaryFromFile()
5454

5555
Dim ExecutablePath As String = Reflection.Assembly.GetExecutingAssembly().Location
5656
Dim ExecutableDirectory As String = Directory.GetParent(ExecutablePath).FullName

CodeCoverage/GlobalSuppressions.vb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
' This file is used by Code Analysis to maintain SuppressMessage
2+
' attributes that are applied to this project.
3+
' Project-level suppressions either have no target or are given
4+
' a specific target and scoped to a namespace, type, member, etc.
5+
6+
Imports System.Diagnostics.CodeAnalysis
7+
8+
<Assembly: SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification:="<Pending>", Scope:="member", Target:="~P:CodeCoverage.ThemesTheme.Category")>
9+
<Assembly: SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification:="<Pending>", Scope:="member", Target:="~P:CodeCoverage.ThemesThemeCategory.Color")>

CodeCoverage/MethodClass.vb

+1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ Public Class MethodClass
3535
End If
3636
Return MethodNameWithParameters.Substring(0, Math.Min(70, MethodNameWithParameters.Length)) & "..."
3737
End Function
38+
3839
End Class

CodeCoverage/My Project/MySettingsProperty.vb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
Imports CodeCoverage.CodeCoverage.My_Project
1+
Imports CodeCoverage.CodeCoverage.My_Project
32

43
Namespace My
54

CodeCoverage/MyListItem.vb

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Public Class MyListItem
2+
23
Sub New(pText As String, pValue As String)
34
_Text = pText
45
_Value = pValue

0 commit comments

Comments
 (0)