@@ -29,14 +29,7 @@ internal class ConsoleWindow : EditorWindow, IHasCustomMenu
2929 private static Font m_MonospaceFont ;
3030 private static int m_DefaultFontSize ;
3131 private static List < MethodInfo > s_MethodsToHideInCallstack = null ;
32- private static Dictionary < HideInCallstackGenericMethodKey , Regex > s_GenericMethodSignatureRegex = null ;
33-
34- internal struct HideInCallstackGenericMethodKey
35- {
36- internal string namespaceName ;
37- internal string className ;
38- internal string methodName ;
39- }
32+ private static Dictionary < MethodInfo , Regex > s_GenericMethodSignatureRegex = null ;
4033
4134 //TODO: move this out of here
4235 internal class Constants
@@ -908,7 +901,7 @@ internal static string StacktraceWithHyperlinks(string stacktraceText, int calls
908901 return textWithHyperlinks . ToString ( ) ;
909902 }
910903
911- internal static string GetCallstackFormattedSignatureFromGenericMethod ( Dictionary < HideInCallstackGenericMethodKey , Regex > methodSignatureRegex , MethodInfo method , string line )
904+ internal static string GetCallstackFormattedSignatureFromGenericMethod ( Dictionary < MethodInfo , Regex > methodSignatureRegex , MethodInfo method , string line )
912905 {
913906 if ( string . IsNullOrEmpty ( line ) || method == null || methodSignatureRegex == null )
914907 return null ;
@@ -917,14 +910,7 @@ internal static string GetCallstackFormattedSignatureFromGenericMethod(Dictionar
917910 if ( classType == null )
918911 return null ;
919912
920- var ns = classType . Namespace ;
921- var key = new HideInCallstackGenericMethodKey ( )
922- {
923- namespaceName = ns ,
924- className = classType . Name ,
925- methodName = method . Name
926- } ;
927- if ( ! methodSignatureRegex . TryGetValue ( key , out Regex regex ) )
913+ if ( ! methodSignatureRegex . TryGetValue ( method , out Regex regex ) )
928914 return null ;
929915
930916 if ( regex == null )
@@ -1004,7 +990,7 @@ internal static string GetCallstackFormattedScriptingExceptionSignature(MethodIn
1004990 return sb . ToString ( ) ;
1005991 }
1006992
1007- internal static string [ ] StripCallstack ( Mode mode , Dictionary < HideInCallstackGenericMethodKey , Regex > methodSignatureRegex , List < MethodInfo > methodsToHideInCallstack , string [ ] lines )
993+ internal static string [ ] StripCallstack ( Mode mode , Dictionary < MethodInfo , Regex > methodSignatureRegex , List < MethodInfo > methodsToHideInCallstack , string [ ] lines )
1008994 {
1009995 if ( methodsToHideInCallstack == null || methodSignatureRegex == null || lines == null )
1010996 return lines ;
@@ -1140,14 +1126,14 @@ private static void OnStripLoggingCallstackButtonValueChange()
11401126 SetFlag ( ConsoleFlags . StripLoggingCallstack , s_StripLoggingCallstack ) ;
11411127 }
11421128
1143- internal static ( List < MethodInfo > , Dictionary < HideInCallstackGenericMethodKey , Regex > ) InitializeHideInCallstackMethodsCache ( )
1129+ internal static ( List < MethodInfo > , Dictionary < MethodInfo , Regex > ) InitializeHideInCallstackMethodsCache ( )
11441130 {
11451131 var methods = TypeCache . GetMethodsWithAttribute < HideInCallstackAttribute > ( ) ;
11461132 if ( methods . Count == 0 )
11471133 return ( null , null ) ;
11481134
11491135 var methodsToHideInCallstack = new List < MethodInfo > ( ) ;
1150- var genericMethodSignatureRegexes = new Dictionary < HideInCallstackGenericMethodKey , Regex > ( ) ;
1136+ var genericMethodSignatureRegexes = new Dictionary < MethodInfo , Regex > ( ) ;
11511137 foreach ( var method in methods )
11521138 {
11531139 methodsToHideInCallstack . Add ( method ) ;
@@ -1161,13 +1147,8 @@ internal static (List<MethodInfo>, Dictionary<HideInCallstackGenericMethodKey, R
11611147 var pattern = $ "{ ( string . IsNullOrEmpty ( ns ) ? "" : $@ "({ ns } )\.") } (" + classType . Name +
11621148 @")\:(" + method . Name + @")([^\(]*)\s*\(([^\)]+)\)" ;
11631149 var regex = new Regex ( pattern , RegexOptions . Compiled ) ;
1164- var key = new HideInCallstackGenericMethodKey ( )
1165- {
1166- namespaceName = ns ,
1167- className = classType . Name ,
1168- methodName = method . Name
1169- } ;
1170- genericMethodSignatureRegexes . Add ( key , regex ) ;
1150+ if ( ! genericMethodSignatureRegexes . TryAdd ( method , regex ) )
1151+ continue ;
11711152 }
11721153 }
11731154
0 commit comments