public static IFileLocator CreateFromSymbolPath()

in src/Microsoft.Diagnostics.Runtime/Implementation/SymbolGroup.cs [90:148]


        public static IFileLocator CreateFromSymbolPath(string symbolPath, bool trace, TokenCredential? credential)
        {
            FileSymbolCache defaultCache = GetDefaultCache();
            List<IFileLocator> locators = new();

            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 (IsUrl(server))
                    {
                        SymbolServer symSvr = new(cache, server, trace, credential);
                        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, trace, null);

            return new SymbolGroup(locators);
        }