@@ -71,6 +71,7 @@ public void Refresh()
7171 if ( regInfoResponse . Equals ( ExcelError . ExcelErrorNA ) )
7272 {
7373 _regInfoNotAvailable = true ;
74+ Logger . Provider . Verbose ( $ "XllRegistrationInfo not available for { _xllPath } ") ;
7475 return ;
7576 }
7677
@@ -101,7 +102,9 @@ public IEnumerable<IntelliSenseFunctionInfo> GetFunctionInfos()
101102 if ( regInfo == null )
102103 yield break ;
103104
104- for ( int i = 0 ; i < regInfo . GetLength ( 0 ) ; i ++ )
105+ int regInfoCount = regInfo . GetLength ( 0 ) ;
106+ Logger . Provider . Verbose ( $ "XllRegistrationInfo for { _xllPath } : { regInfoCount } registrations") ;
107+ for ( int i = 0 ; i < regInfoCount ; i ++ )
105108 {
106109 if ( regInfo [ i , 0 ] is ExcelEmpty )
107110 {
@@ -136,6 +139,7 @@ public IEnumerable<IntelliSenseFunctionInfo> GetFunctionInfos()
136139 ExcelSynchronizationContext _syncContextExcel ;
137140 Dictionary < string , XllRegistrationInfo > _xllRegistrationInfos = new Dictionary < string , XllRegistrationInfo > ( ) ;
138141 LoaderNotification _loaderNotification ;
142+ bool _isDirty ;
139143 public event EventHandler Invalidate ;
140144
141145 public ExcelDnaIntelliSenseProvider ( )
@@ -158,6 +162,7 @@ public void Initialize()
158162 {
159163 if ( ! _xllRegistrationInfos . ContainsKey ( xllPath ) )
160164 {
165+ Logger . Provider . Verbose ( $ "ExcelDnaIntelliSenseProvider.Initialize: Adding XllRegistrationInfo for { xllPath } ") ;
161166 XllRegistrationInfo regInfo = new XllRegistrationInfo ( xllPath ) ;
162167 _xllRegistrationInfos [ xllPath ] = regInfo ;
163168 regInfo . Refresh ( ) ;
@@ -177,16 +182,25 @@ public void Refresh()
177182 {
178183 regInfo . Refresh ( ) ;
179184 }
185+ _isDirty = false ;
180186 }
181187 }
182188
183189 // May be called from any thread
184190 public IList < IntelliSenseFunctionInfo > GetFunctionInfos ( )
185191 {
192+ IList < IntelliSenseFunctionInfo > functionInfos ;
186193 lock ( _xllRegistrationInfos )
187194 {
188- return _xllRegistrationInfos . Values . SelectMany ( ri => ri . GetFunctionInfos ( ) ) . ToList ( ) ;
195+ functionInfos = _xllRegistrationInfos . Values . SelectMany ( ri => ri . GetFunctionInfos ( ) ) . ToList ( ) ;
189196 }
197+ Logger . Provider . Verbose ( "ExcelDnaIntelliSenseProvider.GetFunctionInfos Begin" ) ;
198+ foreach ( var info in functionInfos )
199+ {
200+ Logger . Provider . Verbose ( $ "\t { info . FunctionName } ({ info . ArgumentList . Count } ) - { info . Description } ") ;
201+ }
202+ Logger . Provider . Verbose ( "ExcelDnaIntelliSenseProvider.GetFunctionInfos End" ) ;
203+ return functionInfos ;
190204 }
191205
192206 #endregion
@@ -195,7 +209,7 @@ public IList<IntelliSenseFunctionInfo> GetFunctionInfos()
195209 // TODO: Consider Load/Unload done when AddIns is enumerated...
196210 void loaderNotification_LoadNotification ( object sender , LoaderNotification . NotificationEventArgs e )
197211 {
198- Debug . Print ( $ "@>@>@>@> LoadNotification: { e . Reason } - { e . FullDllName } ") ;
212+ // Debug.Print($"@>@>@>@> LoadNotification: {e.Reason} - {e.FullDllName}");
199213 if ( e . FullDllName . EndsWith ( ".xll" , StringComparison . OrdinalIgnoreCase ) )
200214 _syncContextExcel . Post ( ProcessLoadNotification , e ) ;
201215 }
@@ -207,6 +221,9 @@ void ProcessLoadNotification(object state)
207221 // we might want to introduce a delay here, so that the .xll can complete loading...
208222 var notification = ( LoaderNotification . NotificationEventArgs ) state ; ;
209223 var xllPath = notification . FullDllName ;
224+
225+ Logger . Provider . Verbose ( $ "ExcelDnaIntelliSenseProvider.ProcessLoadNotification { notification } , { xllPath } ") ;
226+
210227 lock ( _xllRegistrationInfos )
211228 {
212229 XllRegistrationInfo regInfo ;
@@ -217,12 +234,18 @@ void ProcessLoadNotification(object state)
217234 regInfo = new XllRegistrationInfo ( xllPath ) ;
218235 _xllRegistrationInfos [ xllPath ] = regInfo ;
219236 //regInfo.Refresh(); // Rather not.... so that we don't even try during the AddIns enumeration... OnInvalidate will lead to Refresh()
220- OnInvalidate ( ) ;
237+
238+ if ( ! _isDirty )
239+ {
240+ _isDirty = true ;
241+ _syncContextExcel . Post ( OnInvalidate , null ) ;
242+ }
221243 }
222244 }
223245 else if ( notification . Reason == LoaderNotification . Reason . Unloaded )
224246 {
225247 _xllRegistrationInfos . Remove ( xllPath ) ;
248+ // Not too worried about cleaning up
226249 // OnInvalidate();
227250 }
228251 }
@@ -247,7 +270,7 @@ IEnumerable<string> GetLoadedXllPaths()
247270 }
248271 }
249272
250- void OnInvalidate ( )
273+ void OnInvalidate ( object _unused_ )
251274 {
252275 Invalidate ? . Invoke ( this , EventArgs . Empty ) ;
253276 }
0 commit comments