@@ -44,6 +44,7 @@ internal GroupAttribute(string publicName)
4444
4545 internal string FileContent { get ; private set ; }
4646 internal string PublicName { get ; private set ; }
47+
4748 internal static Assert . GroupAttribute [ ] Defines => new Assert . GroupAttribute [ ]
4849 {
4950 new Assert . GroupAttribute { FileContent = __FILE__BOOLEAN_CONDITION_CHECKS , PublicName = __NAME__BOOLEAN_CONDITION_CHECKS } ,
@@ -54,23 +55,28 @@ internal GroupAttribute(string publicName)
5455 new Assert . GroupAttribute { FileContent = __FILE__ARITHMETIC_LOGIC_CHECKS , PublicName = __NAME__ARITHMETIC_LOGIC_CHECKS } ,
5556 new Assert . GroupAttribute { FileContent = __FILE__MEMORY_CHECKS , PublicName = __NAME__MEMORY_CHECKS }
5657 } ;
58+ private static string [ ] KnownUsingsWithAssertClasses => new string [ ]
59+ {
60+ "using NUnit.Framework;" ,
61+ "using UnityEngine.Assertions" ,
62+ "using static System.Diagnostics.Debug;"
63+ } ;
5764
58- internal static async Task < Dictionary < Assert . GroupAttribute , ulong > > CountMethodCallsAsync ( string projectPath )
65+ internal static async Task < Dictionary < Assert . GroupAttribute , uint > > CountMethodCallsAsync ( string projectPath )
5966 {
6067 try
6168 {
6269 Dictionary < MethodInfo , Assert . GroupAttribute > methodToGroupMap = GetAssertionsMappedToGroups ( ) ;
63- List < Task < Dictionary < Assert . GroupAttribute , ulong > > > jobs = CreateCountingTasks ( methodToGroupMap , projectPath ) ;
70+ List < Task < Dictionary < Assert . GroupAttribute , uint > > > jobs = CreateCountingTasks ( methodToGroupMap , projectPath ) ;
6471
65- return await CombineResults ( jobs , methodToGroupMap ) ;
72+ return await CombineResults ( jobs ) ;
6673 }
6774 catch ( Exception ex )
6875 {
6976 ex . Log ( ) ;
7077 return null ;
7178 }
7279 }
73-
7480 private static bool ContainsOverload ( Dictionary < MethodInfo , Assert . GroupAttribute > result , MethodInfo method )
7581 {
7682 foreach ( KeyValuePair < MethodInfo , Assert . GroupAttribute > item in result )
@@ -104,9 +110,7 @@ private static string GetMethodPrefixFromUsingStatements(string script)
104110 {
105111 return string . Empty ;
106112 }
107- else if ( script . Contains ( "using DevTools;" ) &&
108- ! script . Contains ( "using NUnit.Framework;" ) &&
109- ! script . Contains ( "using static System.Diagnostics.Debug;" ) )
113+ else if ( script . Contains ( "using DevTools;" ) && KnownUsingsWithAssertClasses . All ( __using => ! script . Contains ( __using ) ) )
110114 {
111115 return "Assert." ;
112116 }
@@ -129,9 +133,9 @@ private static uint CountSubstrings(string instance, string value)
129133
130134 return count ;
131135 }
132- private static List < Task < Dictionary < Assert . GroupAttribute , ulong > > > CreateCountingTasks ( Dictionary < MethodInfo , Assert . GroupAttribute > methodToGroupMap , string path )
136+ private static List < Task < Dictionary < Assert . GroupAttribute , uint > > > CreateCountingTasks ( Dictionary < MethodInfo , Assert . GroupAttribute > methodToGroupMap , string path )
133137 {
134- List < Task < Dictionary < Assert . GroupAttribute , ulong > > > tasks = new List < Task < Dictionary < Assert . GroupAttribute , ulong > > > ( 256 ) ;
138+ List < Task < Dictionary < Assert . GroupAttribute , uint > > > tasks = new List < Task < Dictionary < Assert . GroupAttribute , uint > > > ( 256 ) ;
135139
136140 DirectoryExtensions . ForEachFile ( path ,
137141 ( file ) =>
@@ -141,17 +145,17 @@ private static uint CountSubstrings(string instance, string value)
141145 return ;
142146 }
143147
144- tasks . Add ( Task < Dictionary < Assert . GroupAttribute , ulong > > . Factory . StartNew (
148+ tasks . Add ( Task < Dictionary < Assert . GroupAttribute , uint > > . Factory . StartNew (
145149 ( ) =>
146150 {
147- Dictionary < Assert . GroupAttribute , ulong > callCounts = new Dictionary < Assert . GroupAttribute , ulong > ( ) ;
151+ Dictionary < Assert . GroupAttribute , uint > callCounts = new Dictionary < Assert . GroupAttribute , uint > ( ) ;
148152 string script = File . ReadAllText ( file ) ;
149153 string prefix = GetMethodPrefixFromUsingStatements ( script ) ;
150154
151155 foreach ( KeyValuePair < MethodInfo , Assert . GroupAttribute > methodMapping in methodToGroupMap )
152156 {
153157 Assert . GroupAttribute group = methodMapping . Value ;
154- ulong numCalls = CountSubstrings ( script , prefix + methodMapping . Key . Name ) ;
158+ uint numCalls = CountSubstrings ( script , prefix + methodMapping . Key . Name ) ;
155159
156160 if ( callCounts . ContainsKey ( group ) )
157161 {
@@ -169,13 +173,13 @@ private static uint CountSubstrings(string instance, string value)
169173
170174 return tasks ;
171175 }
172- private static async Task < Dictionary < Assert . GroupAttribute , ulong > > CombineResults ( List < Task < Dictionary < Assert . GroupAttribute , ulong > > > jobs , Dictionary < MethodInfo , Assert . GroupAttribute > methodToGroupMap )
176+ private static async Task < Dictionary < Assert . GroupAttribute , uint > > CombineResults ( List < Task < Dictionary < Assert . GroupAttribute , uint > > > jobs )
173177 {
174- Dictionary < Assert . GroupAttribute , ulong > result = await jobs [ 0 ] ; // at the very least this very script is assigned a job
178+ Dictionary < Assert . GroupAttribute , uint > result = await jobs [ 0 ] ; // at the very least this very script is assigned a job
175179
176180 for ( int i = 1 ; i < jobs . Count ; i ++ )
177181 {
178- foreach ( KeyValuePair < Assert . GroupAttribute , ulong > callCount in await jobs [ i ] )
182+ foreach ( KeyValuePair < Assert . GroupAttribute , uint > callCount in await jobs [ i ] )
179183 {
180184 result [ callCount . Key ] += callCount . Value ;
181185 }
0 commit comments