-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
SystemState.cs
693 lines (606 loc) · 27.7 KB
/
SystemState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using Microsoft.Build.BackEnd;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Microsoft.Build.Tasks.AssemblyDependency;
using Microsoft.Build.Utilities;
#nullable disable
namespace Microsoft.Build.Tasks
{
/// <summary>
/// Class is used to cache system state.
/// </summary>
internal sealed class SystemState : StateFileBase, ITranslatable
{
/// <summary>
/// Cache at the SystemState instance level. Has the same contents as <see cref="instanceLocalFileStateCache"/>.
/// It acts as a flag to enforce that an entry has been checked for staleness only once.
/// </summary>
private Dictionary<string, FileState> upToDateLocalFileStateCache = new Dictionary<string, FileState>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Cache at the SystemState instance level.
/// </summary>
/// <remarks>
/// Before starting execution, RAR attempts to populate this field by deserializing a per-project cache file. During execution,
/// <see cref="FileState"/> objects that get actually used are inserted into <see cref="instanceLocalOutgoingFileStateCache"/>.
/// After execution, <see cref="instanceLocalOutgoingFileStateCache"/> is serialized and written to disk if it's different from
/// what we originally deserialized into this field.
/// </remarks>
internal Dictionary<string, FileState> instanceLocalFileStateCache = new Dictionary<string, FileState>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Cache at the SystemState instance level. It is serialized to disk and reused between instances via <see cref="instanceLocalFileStateCache"/>.
/// </summary>
internal Dictionary<string, FileState> instanceLocalOutgoingFileStateCache = new Dictionary<string, FileState>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// LastModified information is purely instance-local. It doesn't make sense to
/// cache this for long periods of time since there's no way (without actually
/// calling File.GetLastWriteTimeUtc) to tell whether the cache is out-of-date.
/// </summary>
private Dictionary<string, DateTime> instanceLocalLastModifiedCache = new Dictionary<string, DateTime>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// DirectoryExists information is purely instance-local. It doesn't make sense to
/// cache this for long periods of time since there's no way (without actually
/// calling Directory.Exists) to tell whether the cache is out-of-date.
/// </summary>
private Dictionary<string, bool> instanceLocalDirectoryExists = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// GetDirectories information is also purely instance-local. This information
/// is only considered good for the lifetime of the task (or whatever) that owns
/// this instance.
/// </summary>
private Dictionary<string, string[]> instanceLocalDirectories = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Additional level of caching kept at the process level.
/// </summary>
private static ConcurrentDictionary<string, FileState> s_processWideFileStateCache = new ConcurrentDictionary<string, FileState>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// XML tables of installed assemblies.
/// </summary>
private RedistList redistList;
/// <summary>
/// True if the contents have changed.
/// </summary>
private bool isDirty;
/// <summary>
/// Delegate used internally.
/// </summary>
private GetLastWriteTime getLastWriteTime;
/// <summary>
/// Cached delegate.
/// </summary>
private GetAssemblyName getAssemblyName;
/// <summary>
/// Cached delegate.
/// </summary>
private GetAssemblyMetadata getAssemblyMetadata;
/// <summary>
/// Cached delegate.
/// </summary>
private DirectoryExists directoryExists;
/// <summary>
/// Cached delegate.
/// </summary>
private GetDirectories getDirectories;
/// <summary>
/// Cached delegate
/// </summary>
private GetAssemblyRuntimeVersion getAssemblyRuntimeVersion;
/// <summary>
/// Class that holds the current file state.
/// </summary>
internal sealed class FileState : ITranslatable
{
/// <summary>
/// The last modified time for this file.
/// </summary>
private DateTime lastModified;
/// <summary>
/// The fusion name of this file.
/// </summary>
private AssemblyNameExtension assemblyName;
/// <summary>
/// The assemblies that this file depends on.
/// </summary>
internal AssemblyNameExtension[] dependencies;
/// <summary>
/// The scatter files associated with this assembly.
/// </summary>
internal string[] scatterFiles;
/// <summary>
/// FrameworkName the file was built against
/// </summary>
internal FrameworkName frameworkName;
/// <summary>
/// The CLR runtime version for the assembly.
/// </summary>
internal string runtimeVersion;
/// <summary>
/// Default construct.
/// </summary>
internal FileState(DateTime lastModified)
{
this.lastModified = lastModified;
}
/// <summary>
/// Ctor for translator deserialization
/// </summary>
internal FileState(ITranslator translator)
{
Translate(translator);
}
/// <summary>
/// Reads/writes this class
/// </summary>
public void Translate(ITranslator translator)
{
ErrorUtilities.VerifyThrowArgumentNull(translator);
translator.Translate(ref lastModified);
translator.Translate(ref assemblyName,
(ITranslator t) => new AssemblyNameExtension(t));
translator.TranslateArray(ref dependencies,
(ITranslator t) => new AssemblyNameExtension(t));
translator.Translate(ref scatterFiles);
translator.Translate(ref runtimeVersion);
translator.Translate(ref frameworkName);
}
/// <summary>
/// Gets the last modified date.
/// </summary>
/// <value></value>
internal DateTime LastModified
{
get { return lastModified; }
}
/// <summary>
/// Get or set the assemblyName.
/// </summary>
/// <value></value>
internal AssemblyNameExtension Assembly
{
get { return assemblyName; }
set { assemblyName = value; }
}
/// <summary>
/// Get or set the runtimeVersion
/// </summary>
/// <value></value>
internal string RuntimeVersion
{
get { return runtimeVersion; }
set { runtimeVersion = value; }
}
/// <summary>
/// Get or set the framework name the file was built against
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Could be used in other assemblies")]
internal FrameworkName FrameworkNameAttribute
{
get { return frameworkName; }
set { frameworkName = value; }
}
/// <summary>
/// The last-modified value to use for immutable framework files which we don't do I/O on.
/// </summary>
internal static DateTime ImmutableFileLastModifiedMarker => DateTime.MaxValue;
/// <summary>
/// It is wasteful to persist entries for immutable framework files.
/// </summary>
internal bool IsWorthPersisting => lastModified != ImmutableFileLastModifiedMarker;
}
/// <summary>
/// Construct.
/// </summary>
public SystemState()
{
}
public SystemState(ITranslator translator)
{
Translate(translator);
}
/// <summary>
/// Set the target framework paths.
/// This is used to optimize IO in the case of files requested from one
/// of the FX folders.
/// </summary>
/// <param name="installedAssemblyTableInfos">List of Assembly Table Info.</param>
internal void SetInstalledAssemblyInformation(
AssemblyTableInfo[] installedAssemblyTableInfos)
{
redistList = RedistList.GetRedistList(installedAssemblyTableInfos);
}
/// <summary>
/// Reads/writes this class.
/// Used for serialization and deserialization of this class persistent cache.
/// </summary>
public override void Translate(ITranslator translator)
{
if (instanceLocalFileStateCache is null)
{
throw new NullReferenceException(nameof(instanceLocalFileStateCache));
}
translator.TranslateDictionary(
ref (translator.Mode == TranslationDirection.WriteToStream) ? ref instanceLocalOutgoingFileStateCache : ref instanceLocalFileStateCache,
StringComparer.OrdinalIgnoreCase,
(ITranslator t) => new FileState(t));
// IsDirty should be false for either direction. Either this cache was brought
// up-to-date with the on-disk cache or vice versa. Either way, they agree.
IsDirty = false;
}
/// <inheritdoc />
internal override bool HasStateToSave => instanceLocalOutgoingFileStateCache.Count > 0;
/// <summary>
/// Flag that indicates that <see cref="instanceLocalFileStateCache"/> has been modified.
/// </summary>
/// <value></value>
internal bool IsDirty
{
get { return isDirty; }
set { isDirty = value; }
}
/// <summary>
/// Set the GetLastWriteTime delegate.
/// </summary>
/// <param name="getLastWriteTimeValue">Delegate used to get the last write time.</param>
internal void SetGetLastWriteTime(GetLastWriteTime getLastWriteTimeValue)
{
getLastWriteTime = getLastWriteTimeValue;
}
/// <summary>
/// Cache the results of a GetAssemblyName delegate.
/// </summary>
/// <param name="getAssemblyNameValue">The delegate.</param>
/// <returns>Cached version of the delegate.</returns>
internal GetAssemblyName CacheDelegate(GetAssemblyName getAssemblyNameValue)
{
getAssemblyName = getAssemblyNameValue;
return GetAssemblyName;
}
/// <summary>
/// Cache the results of a GetAssemblyMetadata delegate.
/// </summary>
/// <param name="getAssemblyMetadataValue">The delegate.</param>
/// <returns>Cached version of the delegate.</returns>
internal GetAssemblyMetadata CacheDelegate(GetAssemblyMetadata getAssemblyMetadataValue)
{
getAssemblyMetadata = getAssemblyMetadataValue;
return GetAssemblyMetadata;
}
/// <summary>
/// Cache the results of a FileExists delegate.
/// </summary>
/// <returns>Cached version of the delegate.</returns>
internal FileExists CacheDelegate()
{
return FileExists;
}
public DirectoryExists CacheDelegate(DirectoryExists directoryExistsValue)
{
directoryExists = directoryExistsValue;
return DirectoryExists;
}
/// <summary>
/// Cache the results of a GetDirectories delegate.
/// </summary>
/// <param name="getDirectoriesValue">The delegate.</param>
/// <returns>Cached version of the delegate.</returns>
internal GetDirectories CacheDelegate(GetDirectories getDirectoriesValue)
{
getDirectories = getDirectoriesValue;
return GetDirectories;
}
/// <summary>
/// Cache the results of a GetAssemblyRuntimeVersion delegate.
/// </summary>
/// <param name="getAssemblyRuntimeVersion">The delegate.</param>
/// <returns>Cached version of the delegate.</returns>
internal GetAssemblyRuntimeVersion CacheDelegate(GetAssemblyRuntimeVersion getAssemblyRuntimeVersion)
{
this.getAssemblyRuntimeVersion = getAssemblyRuntimeVersion;
return GetRuntimeVersion;
}
internal FileState GetFileState(string path)
{
// Looking up an assembly to get its metadata can be expensive for projects that reference large amounts
// of assemblies. To avoid that expense, we remember and serialize this information betweeen runs in
// <ProjectFileName>.AssemblyReference.cache files in the intermediate directory and also store it in an
// process-wide cache to share between successive builds.
//
// To determine if this information is up-to-date, we use the last modified date of the assembly, however,
// as calls to GetLastWriteTime can add up over hundreds and hundreds of files, we only check for
// invalidation once per assembly per ResolveAssemblyReference session.
upToDateLocalFileStateCache.TryGetValue(path, out FileState state);
if (state == null)
{ // We haven't seen this file this ResolveAssemblyReference session
state = ComputeFileStateFromCachesAndDisk(path);
upToDateLocalFileStateCache[path] = state;
}
return state;
}
private FileState ComputeFileStateFromCachesAndDisk(string path)
{
DateTime lastModified = GetAndCacheLastModified(path);
bool isCachedInInstance = instanceLocalFileStateCache.TryGetValue(path, out FileState cachedInstanceFileState);
bool isCachedInProcess = s_processWideFileStateCache.TryGetValue(path, out FileState cachedProcessFileState);
bool isInstanceFileStateUpToDate = isCachedInInstance && lastModified == cachedInstanceFileState.LastModified;
bool isProcessFileStateUpToDate = isCachedInProcess && lastModified == cachedProcessFileState.LastModified;
// If the process-wide cache contains an up-to-date FileState, always use it.
if (isProcessFileStateUpToDate)
{
// For the next build, we may be using a different process. Update the file cache if the entry is worth persisting.
if (cachedProcessFileState.IsWorthPersisting)
{
if (!isInstanceFileStateUpToDate)
{
instanceLocalFileStateCache[path] = cachedProcessFileState;
isDirty = true;
}
// Remember that this FileState was actually used by adding it to the outgoing dictionary.
instanceLocalOutgoingFileStateCache[path] = cachedProcessFileState;
}
return cachedProcessFileState;
}
if (isInstanceFileStateUpToDate)
{
if (cachedInstanceFileState.IsWorthPersisting)
{
// Remember that this FileState was actually used by adding it to the outgoing dictionary.
instanceLocalOutgoingFileStateCache[path] = cachedInstanceFileState;
}
return s_processWideFileStateCache[path] = cachedInstanceFileState;
}
// If no up-to-date FileState exists at this point, create one and take ownership
return InitializeFileState(path, lastModified);
}
private DateTime GetAndCacheLastModified(string path)
{
if (!instanceLocalLastModifiedCache.TryGetValue(path, out DateTime lastModified))
{
lastModified = getLastWriteTime(path);
instanceLocalLastModifiedCache[path] = lastModified;
}
return lastModified;
}
private FileState InitializeFileState(string path, DateTime lastModified)
{
var fileState = new FileState(lastModified);
// Dirty the instance-local cache only with entries that are worth persisting.
if (fileState.IsWorthPersisting)
{
instanceLocalFileStateCache[path] = fileState;
instanceLocalOutgoingFileStateCache[path] = fileState;
isDirty = true;
}
s_processWideFileStateCache[path] = fileState;
return fileState;
}
/// <summary>
/// Cached implementation of GetAssemblyName.
/// </summary>
/// <param name="path">The path to the file</param>
/// <returns>The assembly name.</returns>
private AssemblyNameExtension GetAssemblyName(string path)
{
// If the assembly is in an FX folder and its a well-known assembly
// then we can short-circuit the File IO involved with GetAssemblyName()
if (redistList != null)
{
string extension = Path.GetExtension(path);
if (string.Equals(extension, ".dll", StringComparison.OrdinalIgnoreCase))
{
IEnumerable<AssemblyEntry> assemblyNames = redistList.FindAssemblyNameFromSimpleName(
Path.GetFileNameWithoutExtension(path));
string filename = Path.GetFileName(path);
foreach (AssemblyEntry a in assemblyNames)
{
string pathFromRedistList = Path.Combine(a.FrameworkDirectory, filename);
if (String.Equals(path, pathFromRedistList, StringComparison.OrdinalIgnoreCase))
{
return new AssemblyNameExtension(a.FullName);
}
}
}
}
// Not a well-known FX assembly so now check the cache.
FileState fileState = GetFileState(path);
if (fileState.Assembly == null)
{
fileState.Assembly = getAssemblyName(path);
// Certain assemblies, like mscorlib may not have metadata.
// Avoid continuously calling getAssemblyName on these files by
// recording these as having an empty name.
if (fileState.Assembly == null)
{
fileState.Assembly = AssemblyNameExtension.UnnamedAssembly;
}
if (fileState.IsWorthPersisting)
{
isDirty = true;
}
}
if (fileState.Assembly.IsUnnamedAssembly)
{
return null;
}
return fileState.Assembly;
}
/// <summary>
/// Cached implementation. Given a path, crack it open and retrieve runtimeversion for the assembly.
/// </summary>
/// <param name="path">Path to the assembly.</param>
private string GetRuntimeVersion(string path)
{
FileState fileState = GetFileState(path);
if (String.IsNullOrEmpty(fileState.RuntimeVersion))
{
fileState.RuntimeVersion = getAssemblyRuntimeVersion(path);
if (fileState.IsWorthPersisting)
{
isDirty = true;
}
}
return fileState.RuntimeVersion;
}
/// <summary>
/// Cached implementation. Given an assembly name, crack it open and retrieve the list of dependent
/// assemblies and the list of scatter files.
/// </summary>
/// <param name="path">Path to the assembly.</param>
/// <param name="assemblyMetadataCache">Cache for pre-extracted assembly metadata.</param>
/// <param name="dependencies">Receives the list of dependencies.</param>
/// <param name="scatterFiles">Receives the list of associated scatter files.</param>
/// <param name="frameworkName"></param>
private void GetAssemblyMetadata(
string path,
ConcurrentDictionary<string, AssemblyMetadata> assemblyMetadataCache,
out AssemblyNameExtension[] dependencies,
out string[] scatterFiles,
out FrameworkName frameworkName)
{
FileState fileState = GetFileState(path);
if (fileState.dependencies == null)
{
getAssemblyMetadata(
path,
assemblyMetadataCache,
out fileState.dependencies,
out fileState.scatterFiles,
out fileState.frameworkName);
if (fileState.IsWorthPersisting)
{
isDirty = true;
}
}
dependencies = fileState.dependencies;
scatterFiles = fileState.scatterFiles;
frameworkName = fileState.frameworkName;
}
/// <summary>
/// Reads in cached data from stateFiles to build an initial cache. Avoids logging warnings or errors.
/// </summary>
/// <param name="stateFiles">List of locations of caches on disk.</param>
/// <param name="log">How to log</param>
/// <param name="fileExists">Whether a file exists</param>
/// <returns>A cache representing key aspects of file states.</returns>
internal static SystemState DeserializePrecomputedCaches(ITaskItem[] stateFiles, TaskLoggingHelper log, FileExists fileExists)
{
SystemState retVal = new SystemState();
retVal.isDirty = stateFiles.Length > 0;
HashSet<string> assembliesFound = new HashSet<string>();
foreach (ITaskItem stateFile in stateFiles)
{
// Verify that it's a real stateFile. Log message but do not error if not.
SystemState sysState = DeserializeCache<SystemState>(stateFile.ToString(), log);
if (sysState == null)
{
continue;
}
foreach (KeyValuePair<string, FileState> kvp in sysState.instanceLocalFileStateCache)
{
string relativePath = kvp.Key;
if (!assembliesFound.Contains(relativePath))
{
FileState fileState = kvp.Value;
string fullPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(stateFile.ToString()), relativePath));
if (fileExists(fullPath))
{
// Correct file path
retVal.instanceLocalFileStateCache[fullPath] = fileState;
assembliesFound.Add(relativePath);
}
}
}
}
return retVal;
}
/// <summary>
/// Modifies this object to be more portable across machines, then writes it to filePath.
/// </summary>
/// <param name="stateFile">Path to which to write the precomputed cache</param>
/// <param name="log">How to log</param>
internal void SerializePrecomputedCache(string stateFile, TaskLoggingHelper log)
{
// Save a copy of instanceLocalOutgoingFileStateCache so we can restore it later. SerializeCacheByTranslator serializes
// instanceLocalOutgoingFileStateCache by default, so change that to the relativized form, then change it back.
Dictionary<string, FileState> oldFileStateCache = instanceLocalOutgoingFileStateCache;
instanceLocalOutgoingFileStateCache = instanceLocalFileStateCache.ToDictionary(kvp => FileUtilities.MakeRelative(Path.GetDirectoryName(stateFile), kvp.Key), kvp => kvp.Value);
try
{
if (FileUtilities.FileExistsNoThrow(stateFile))
{
log.LogWarningWithCodeFromResources("General.StateFileAlreadyPresent", stateFile);
}
SerializeCache(stateFile, log);
}
finally
{
instanceLocalOutgoingFileStateCache = oldFileStateCache;
}
}
/// <summary>
/// Cached implementation of GetDirectories.
/// </summary>
/// <param name="path"></param>
/// <param name="pattern"></param>
/// <returns>The list of directories from the specified path.</returns>
private string[] GetDirectories(string path, string pattern)
{
// Only cache the *. pattern. This is by far the most common pattern
// and generalized caching would require a call to Path.Combine which
// is a string-copy.
if (pattern == "*")
{
instanceLocalDirectories.TryGetValue(path, out string[] cached);
if (cached == null)
{
string[] directories = getDirectories(path, pattern);
instanceLocalDirectories[path] = directories;
return directories;
}
return cached;
}
// This path is currently uncalled. Use assert to tell the dev that adds a new code-path
// that this is an unoptimized path.
Debug.Assert(false, "Using slow-path in SystemState.GetDirectories, was this intentional?");
return getDirectories(path, pattern);
}
/// <summary>
/// Cached implementation of FileExists.
/// </summary>
/// <param name="path">Path to file.</param>
/// <returns>True if the file exists.</returns>
private bool FileExists(string path)
{
DateTime lastModified = GetAndCacheLastModified(path);
return FileTimestampIndicatesFileExists(lastModified);
}
private bool FileTimestampIndicatesFileExists(DateTime lastModified)
{
// TODO: Standardize LastWriteTime value for nonexistent files. See https://github.com/dotnet/msbuild/issues/3699
return lastModified != DateTime.MinValue && lastModified != NativeMethodsShared.MinFileDate;
}
/// <summary>
/// Cached implementation of DirectoryExists.
/// </summary>
/// <param name="path">Path to file.</param>
/// <returns>True if the directory exists.</returns>
private bool DirectoryExists(string path)
{
if (instanceLocalDirectoryExists.TryGetValue(path, out bool flag))
{
return flag;
}
bool exists = directoryExists(path);
instanceLocalDirectoryExists[path] = exists;
return exists;
}
}
}