23
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
25
// THE SOFTWARE.
26
+ #nullable enable
26
27
using System ;
27
28
using System . Collections . Generic ;
28
29
using System . IO ;
@@ -63,16 +64,16 @@ public virtual void HandleException (string message, Exception e)
63
64
/// </summary>
64
65
internal class Caching
65
66
{
66
- readonly ICachingFaultInjector cachingFaultInjector ;
67
+ readonly ICachingFaultInjector ? cachingFaultInjector ;
67
68
readonly RuntimeCompositionExceptionHandler exceptionHandler ;
68
69
69
- Task saveTask ;
70
+ Task saveTask = Task . CompletedTask ;
70
71
readonly HashSet < Assembly > loadedAssemblies ;
71
72
public HashSet < Assembly > MefAssemblies { get ; }
72
73
internal string MefCacheFile { get ; }
73
74
internal string MefCacheControlFile { get ; }
74
75
75
- public Caching ( HashSet < Assembly > mefAssemblies , RuntimeCompositionExceptionHandler exceptionHandler , Func < string , string > getCacheFilePath = null , ICachingFaultInjector cachingFaultInjector = null )
76
+ public Caching ( HashSet < Assembly > mefAssemblies , RuntimeCompositionExceptionHandler exceptionHandler , Func < string , string > ? getCacheFilePath = null , ICachingFaultInjector ? cachingFaultInjector = null )
76
77
{
77
78
getCacheFilePath = getCacheFilePath ?? ( file => Path . Combine ( AddinManager . CurrentAddin . PrivateDataPath , file ) ) ;
78
79
@@ -97,7 +98,7 @@ void IdeApp_Exiting (object sender, ExitEventArgs args)
97
98
// As of the time this code was written, serializing the cache takes 200ms.
98
99
// Maybe show a dialog and progress bar here that we're closing after save.
99
100
// We cannot cancel the save, vs-mef doesn't use the cancellation tokens in the API.
100
- saveTask ? . Wait ( ) ;
101
+ saveTask . Wait ( ) ;
101
102
}
102
103
103
104
internal Stream OpenCacheStream ( ) => File . Open ( MefCacheFile , FileMode . Open ) ;
@@ -165,7 +166,7 @@ internal bool CanUse (bool handleExceptions = true)
165
166
return true ;
166
167
}
167
168
168
- static bool ValidateAssemblyCacheListIntegrity ( HashSet < Assembly > assemblies , List < MefControlCacheAssemblyInfo > cachedAssemblyInfos , ICachingFaultInjector cachingFaultInjector )
169
+ static bool ValidateAssemblyCacheListIntegrity ( HashSet < Assembly > assemblies , List < MefControlCacheAssemblyInfo > cachedAssemblyInfos , ICachingFaultInjector ? cachingFaultInjector )
169
170
{
170
171
var currentAssemblies = new Dictionary < string , Guid > ( assemblies . Count ) ;
171
172
foreach ( var asm in assemblies )
@@ -203,7 +204,7 @@ internal Task Write (RuntimeComposition runtimeComposition, ComposableCatalog ca
203
204
await saveTask ;
204
205
205
206
IdeApp . Exiting -= IdeApp_Exiting ;
206
- saveTask = null ;
207
+ saveTask = Task . CompletedTask ;
207
208
} ) ;
208
209
}
209
210
0 commit comments