private static FileSymbolCache GetDefaultCache() { FileSymbolCache?cache = s_cache; if (cache != null) { return(cache); } // We always expect to be able to create a temporary directory Directory.CreateDirectory(s_defaultCacheLocation); cache = new FileSymbolCache(s_defaultCacheLocation); Interlocked.CompareExchange(ref s_cache, cache, null); return(s_cache !); }
internal SymbolServer(FileSymbolCache cache, string server) { if (cache is null) { throw new ArgumentNullException(nameof(cache)); } _cache = cache; Server = server; if (IsSymweb(server)) { SupportsCompression = false; SupportsRedirection = true; } }
public static IFileLocator CreateFromSymbolPath(string symbolPath) { FileSymbolCache defaultCache = GetDefaultCache(); List <IFileLocator> locators = new List <IFileLocator>(); bool first = false; SymbolServer?single = null; foreach ((string?Cache, string[] Servers) in symbolPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(EnumerateEntries)) { if (Servers.Length == 0) { continue; } FileSymbolCache cache = defaultCache; if (Cache != null && !defaultCache.Location.Equals(Cache, FileSymbolCache.IsCaseInsensitiveFileSystem ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) { Directory.CreateDirectory(Cache); cache = new FileSymbolCache(Cache); // if the cache is not the default, we have to add it to the list of locators so we check there before hitting the symbol server locators.Add(cache); } foreach (string server in Servers) { if (server.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || server.StartsWith("https:", StringComparison.OrdinalIgnoreCase)) { SymbolServer symSvr = new SymbolServer(cache, server); locators.Add(symSvr); if (first) { single = symSvr; first = false; } else { single = null; } } else if (Directory.Exists(server)) { locators.Add(new FileSymbolCache(server)); } else { Trace.WriteLine($"Ignoring symbol part: {server}"); } } } if (single != null) { return(single); } if (locators.Count == 0) { return(new SymbolServer(defaultCache, SymbolServer.Msdl)); } return(new SymbolGroup(locators)); }