Example #1
0
 internal async Task DownloadFiles(bool symbolsOnly, bool forceWindowsPdbs)
 {
     using (SymbolStore symbolStore = BuildSymbolStore())
     {
         KeyTypeFlags flags;
         if (symbolsOnly)
         {
             flags = KeyTypeFlags.SymbolKey;
         }
         else
         {
             flags = KeyTypeFlags.IdentityKey | KeyTypeFlags.SymbolKey | KeyTypeFlags.ClrKeys;
         }
         if (forceWindowsPdbs)
         {
             flags |= KeyTypeFlags.ForceWindowsPdbs;
         }
         foreach (SymbolStoreKeyWrapper wrapper in GetKeys(flags).Distinct())
         {
             SymbolStoreKey key = wrapper.Key;
             if (symbolStore != null)
             {
                 using (SymbolStoreFile symbolFile = await symbolStore.GetFile(key, CancellationToken.None))
                 {
                     if (symbolFile != null)
                     {
                         await WriteFile(symbolFile, wrapper);
                     }
                 }
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Initializes symbol loading. Adds the symbol server and/or the cache path (if not null) to the list of
        /// symbol servers. This API can be called more than once to add more servers to search.
        /// </summary>
        /// <param name="logging">if true, logging diagnostics to console</param>
        /// <param name="msdl">if true, use the public microsoft server</param>
        /// <param name="symweb">if true, use symweb internal server and protocol (file.ptr)</param>
        /// <param name="symbolServerPath">symbol server url (optional)</param>
        /// <param name="symbolCachePath">symbol cache directory path (optional)</param>
        /// <param name="windowsSymbolPath">windows symbol path (optional)</param>
        /// <returns></returns>
        internal static bool InitializeSymbolStore(bool logging, bool msdl, bool symweb, string symbolServerPath, string symbolCachePath, string windowsSymbolPath)
        {
            if (s_tracer == null)
            {
                s_tracer = new Tracer(enabled: logging, enabledVerbose: logging, Console.WriteLine);
            }
            SymbolStore store = s_symbolStore;

            // Build the symbol stores
            if (windowsSymbolPath != null)
            {
                // Parse the Windows symbol path syntax (srv*, cache*, etc)
                if (!ParseSymbolPath(ref store, windowsSymbolPath))
                {
                    return(false);
                }
            }
            else
            {
                // Build the symbol stores using the other parameters
                if (!GetServerSymbolStore(ref store, msdl, symweb, symbolServerPath, symbolCachePath))
                {
                    return(false);
                }
            }

            s_symbolStore = store;
            return(true);
        }
Example #3
0
        private SymbolStore BuildSymbolStore()
        {
            SymbolStore store = null;

            foreach (ServerInfo server in ((IEnumerable <ServerInfo>)SymbolServers).Reverse())
            {
                if (server.InternalSymwebServer)
                {
                    store = new SymwebHttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
                else
                {
                    store = new HttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
            }

            // Add default symbol cache if one wasn't set by the command line
            if (CacheDirectories.Count == 0)
            {
                CacheDirectories.Add(GetDefaultSymbolCache());
            }

            foreach (string cache in ((IEnumerable <string>)CacheDirectories).Reverse())
            {
                store = new CacheSymbolStore(Tracer, store, cache);
            }

            return(store);
        }
Example #4
0
        public DefaultBuildEnvironment(IPlan plan, ITargetDescription description, TaskMap<ModuleName, ITarget> taskMap, CancellationToken token)
        {
            if (taskMap == null)
                throw new System.ArgumentNullException("taskMap");
            if (description == null)
                throw new System.ArgumentNullException("description");
            if ((object) plan == null)
                throw new System.ArgumentNullException("plan");

            _token = token;
            _plan = plan;
            _taskMap = taskMap;
            _description = description;
            var externals = new List<SymbolInfo>();
            foreach (var name in description.Dependencies)
            {
                var d = taskMap[name].Value.Result;
                if (d.Symbols == null) continue;
                var origin = new SymbolOrigin.ModuleTopLevel(name, NoSourcePosition.Instance);
                externals.AddRange(from decl in d.Symbols
                                   select new SymbolInfo(decl.Value, origin, decl.Key));
            }
            _externalSymbols = SymbolStore.Create(conflictUnionSource: externals);
            _compilationEngine = new Engine();
            _module = Module.Create(description.Name);
        }
Example #5
0
        internal async Task DownloadFiles()
        {
            using (SymbolStore symbolStore = BuildSymbolStore())
            {
                bool verifyPackages = Packages && OutputDirectory == null;

                KeyTypeFlags flags = KeyTypeFlags.None;
                if (Symbols)
                {
                    flags |= KeyTypeFlags.SymbolKey;
                }
                if (Modules)
                {
                    flags |= KeyTypeFlags.IdentityKey;
                }
                if (Debugging)
                {
                    flags |= KeyTypeFlags.ClrKeys;
                }
                if (flags == KeyTypeFlags.None)
                {
                    if (verifyPackages)
                    {
                        // If we are verifing symbol packages then only check the identity and clr keys.
                        flags = KeyTypeFlags.IdentityKey | KeyTypeFlags.ClrKeys;
                    }
                    else
                    {
                        // The default is to download everything
                        flags = KeyTypeFlags.IdentityKey | KeyTypeFlags.SymbolKey | KeyTypeFlags.ClrKeys;
                    }
                }
                if (ForceWindowsPdbs)
                {
                    flags |= KeyTypeFlags.ForceWindowsPdbs;
                }

                foreach (SymbolStoreKeyWrapper wrapper in GetKeys(flags).Distinct())
                {
                    SymbolStoreKey key = wrapper.Key;
                    Tracer.Information("Key: {0} - {1}{2}", key.Index, key.FullPathName, key.IsClrSpecialFile ? "*" : "");

                    if (symbolStore != null)
                    {
                        using (SymbolStoreFile symbolFile = await symbolStore.GetFile(key, CancellationToken.None))
                        {
                            if (symbolFile != null)
                            {
                                await WriteFile(symbolFile, wrapper);
                            }
                            // If there is no output directory verify the file exists in the symbol store
                            if (OutputDirectory == null)
                            {
                                Tracer.WriteLine("Key {0}found {1} - {2}", symbolFile != null ? "" : "NOT ", key.Index, key.FullPathName);
                            }
                        }
                    }
                }
            }
        }
Example #6
0
 protected SymbolEntry LookupSymbolEntry(SymbolStore store, string symbolicId)
 {
     Symbol symbol;
     Assert.IsTrue(store.TryGet(symbolicId, out symbol),
                   string.Format("Expected to find symbol {0} but there is no such entry.", symbolicId));
     return symbol.ToSymbolEntry();
 }
Example #7
0
 internal MergedNamespace([NotNull] SymbolStore scope)
 {
     if (scope == null)
         throw new ArgumentNullException("scope");
     
     _exportScope = scope;
 }
Example #8
0
 public void SetUp()
 {
     _position = new SourcePosition("MExprTests.cs",20,62);
     _symbols = SymbolStore.Create();
     _existing = new Dictionary<Symbol, QualifiedId>();
     _otherPosition = new SourcePosition("PrexoniteTests.csproj",33,77);
     _symbolParser = new SymbolMExprParser(_symbols, ConsoleSink.Instance);
 }
Example #9
0
 /// <summary>
 /// Attempts to download/retrieve from cache the key.
 /// </summary>
 /// <param name="key">index of the file to retrieve</param>
 /// <returns>stream or null</returns>
 private static SymbolStoreFile GetSymbolStoreFile(SymbolStoreKey key)
 {
     // Add the default symbol cache if it hasn't already been added
     if (!s_symbolCacheAdded)
     {
         s_symbolStore      = new CacheSymbolStore(s_tracer, s_symbolStore, GetDefaultSymbolCache());
         s_symbolCacheAdded = true;
     }
     return(s_symbolStore.GetFile(key, CancellationToken.None).GetAwaiter().GetResult());
 }
Example #10
0
 internal DeclarationScope([NotNull] LocalNamespace ns, QualifiedId pathPrefix, [NotNull] SymbolStore store)
 {
     if (ns == null) throw new ArgumentNullException("ns");
     if (store == null)
         throw new ArgumentNullException("store");
         
     _namespace = ns;
     _pathPrefix = pathPrefix;
     _store = store;
 }
Example #11
0
        private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool symweb, string symbolServerPath, string symbolCachePath)
        {
            bool internalServer = false;

            // Add symbol server URL if exists
            if (symbolServerPath == null)
            {
                if (msdl)
                {
                    symbolServerPath = MsdlsymbolServer;
                }
                else if (symweb)
                {
                    symbolServerPath = SymwebSymbolService;
                    internalServer   = true;
                }
            }
            else
            {
                // Use the internal symbol store for symweb
                internalServer = symbolServerPath.Contains("symweb");

                // Make sure the server Uri ends with "/"
                symbolServerPath = symbolServerPath.TrimEnd('/') + '/';
            }

            if (symbolServerPath != null)
            {
                if (!Uri.TryCreate(symbolServerPath, UriKind.Absolute, out Uri uri) || uri.IsFile)
                {
                    return(false);
                }

                // Create symbol server store
                if (internalServer)
                {
                    store = new SymwebHttpSymbolStore(s_tracer, store, uri);
                }
                else
                {
                    store = new HttpSymbolStore(s_tracer, store, uri);
                }
            }

            if (symbolCachePath != null)
            {
                store = new CacheSymbolStore(s_tracer, store, symbolCachePath);

                // Don't add the default cache later
                s_symbolCacheAdded = true;
            }

            return(true);
        }
Example #12
0
        /// <summary>
        ///     Creates a new macro expansion session for the specified compiler target.
        /// </summary>
        /// <param name = "target">The target to expand macros in.</param>
        public MacroSession([NotNull] CompilerTarget target)
        {
            if(target == null)
                throw new ArgumentNullException("target");

            _target = target;
            _astFactory = _target.Factory;
            
            _globalSymbols = SymbolStore.Create(_target.Loader.TopLevelSymbols);
            _outerVariables = new ReadOnlyCollectionView<string>(_target.OuterVariables);

            _buildCommandToken = target.Loader.RequestBuildCommands();
        }
Example #13
0
 public DefaultModuleTarget(Module module, SymbolStore symbols, IEnumerable<Message> messages = null, Exception exception = null)
 {
     if (module == null)
         throw new ArgumentNullException("module");
     if (symbols == null)
         throw new ArgumentNullException("symbols");
     _module = module;
     _symbols = symbols;
     _exception = exception;
     if(messages != null)
         _messages = new List<Message>(messages);
     _isSuccessful = exception == null && (_messages == null || _messages.All(m => m.Severity != MessageSeverity.Error));
 }
Example #14
0
 /// <summary>
 /// Attempts to download/retrieve from cache the key.
 /// </summary>
 /// <param name="key">index of the file to retrieve</param>
 /// <returns>stream or null</returns>
 internal static SymbolStoreFile GetSymbolStoreFile(SymbolStoreKey key)
 {
     try
     {
         // Add the default symbol cache if it hasn't already been added
         if (!s_symbolCacheAdded)
         {
             s_symbolStore      = new CacheSymbolStore(s_tracer, s_symbolStore, GetDefaultSymbolCache());
             s_symbolCacheAdded = true;
         }
         return(s_symbolStore.GetFile(key, CancellationToken.None).GetAwaiter().GetResult());
     }
     catch (Exception ex) when(ex is UnauthorizedAccessException || ex is BadImageFormatException || ex is IOException)
     {
         s_tracer.Error("Exception: {0}", ex.ToString());
         return(null);
     }
 }
Example #15
0
 internal async Task DownloadFiles()
 {
     using (SymbolStore symbolStore = BuildSymbolStore())
     {
         foreach (SymbolStoreKeyWrapper wrapper in GetKeys().Distinct())
         {
             SymbolStoreKey key = wrapper.Key;
             if (symbolStore != null)
             {
                 using (SymbolStoreFile symbolFile = await symbolStore.GetFile(key, CancellationToken.None))
                 {
                     if (symbolFile != null)
                     {
                         await WriteFile(symbolFile, wrapper);
                     }
                 }
             }
         }
     }
 }
Example #16
0
        public ProvidedTarget(Module module,
            IEnumerable<ModuleName> dependencies = null,
            IEnumerable<KeyValuePair<string, Symbol>> symbols = null,
            IEnumerable<IResourceDescriptor> resources = null,
            IEnumerable<Message> messages = null,
            IEnumerable<Message> buildMessages = null,
            Exception exception = null)
        {
            _module = module;
            _dependencies = new DependencySet(module.Name);
            if (dependencies != null)
                _dependencies.AddRange(dependencies);
            _symbols = SymbolStore.Create();
            if (symbols != null)
                foreach (var entry in symbols)
                    _symbols.Declare(entry.Key, entry.Value);
            _resources = new List<IResourceDescriptor>();
            if (resources != null)
                _resources.AddRange(resources);

            _exception = exception;

            if (messages != null)
                _messages = new List<Message>(messages);

            if (buildMessages != null)
            {
                _buildMessages = new List<Message>(buildMessages);

                if (_messages == null)
                    _messages = new List<Message>(_buildMessages);
                else
                    _messages.AddRange(_buildMessages);
                
            }

            _isSuccessful = exception == null &&
                            (_messages == null || _messages.All(m => m.Severity != MessageSeverity.Error));
        }
Example #17
0
        private SymbolStore BuildSymbolStore()
        {
            SymbolStore store = null;

            foreach (ServerInfo server in ((IEnumerable <ServerInfo>)SymbolServers).Reverse())
            {
                if (server.InternalSymwebServer)
                {
                    store = new SymwebHttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
                else
                {
                    store = new HttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
                }
            }

            foreach (string cache in ((IEnumerable <string>)CacheDirectories).Reverse())
            {
                store = new CacheSymbolStore(Tracer, store, cache);
            }

            return(store);
        }
Example #18
0
 /// <summary>
 /// Displays the symbol server and cache configuration
 /// </summary>
 internal static void DisplaySymbolStore()
 {
     if (s_tracer != null)
     {
         SymbolStore symbolStore = s_symbolStore;
         while (symbolStore != null)
         {
             if (symbolStore is CacheSymbolStore cache)
             {
                 s_tracer.WriteLine("Cache: {0}", cache.CacheDirectory);
             }
             else if (symbolStore is HttpSymbolStore http)
             {
                 s_tracer.WriteLine("Server: {0}", http.Uri);
             }
             else
             {
                 s_tracer.WriteLine("Unknown symbol store");
             }
             symbolStore = symbolStore.BackingStore;
         }
     }
 }
 /// <summary>
 /// Create an instance of a directory symbol store
 /// </summary>
 /// <param name="backingStore">next symbol store or null</param>
 /// <param name="directory">symbol search path</param>
 public DirectorySymbolStore(ITracer tracer, SymbolStore backingStore, string directory)
     : base(tracer, backingStore)
 {
     Directory = directory ?? throw new ArgumentNullException(nameof(directory));
 }
Example #20
0
        public async Task <bool> Login(string userId, SecureString password, bool isDemo)
        {
            _userId   = userId;
            _password = password;
            _isDemo   = isDemo;

            var loginResponse = await ConnectToServer();

            ThrowIfNotSuccessful(loginResponse);

            if (_symbolDb.Symbols.Count > 0)
            {
                SymbolRecords = _symbolDb
                                .Symbols
                                .Select(x => x.Symbol)
                                .ToList();

                return(true);
            }

            var allSymbolsResponse = await _connector.GetAllSymbols();

            ThrowIfNotSuccessful(allSymbolsResponse);

            SymbolRecords = allSymbolsResponse.SymbolRecords.Select(x => new Symbol
            {
                Name         = x.Symbol,
                CategoryName = x.CategoryName,
                Description  = x.Description,
                Ask          = x.Ask,
                Bid          = x.Bid
            }).ToList();

            foreach (var s in SymbolRecords)
            {
                try
                {
                    var daily = await LoadData(s.Name, DurationEnum.Year10);

                    var intraday = await LoadData(s.Name, DurationEnum.Day1);

                    var ss = new SymbolStore
                    {
                        Symbol           = s,
                        DailyTickData    = daily,
                        IntradayTickData = intraday
                    };

                    _symbolDb.Symbols.Add(ss);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error while loading " + s.Name);
                }
            }

            return(true);

            //var symbolResponse = APICommandFactory.ExecuteSymbolCommand(_connector, "EURUSD", true);
            //ThrowIfNotSuccessful(symbolResponse);
        }
Example #21
0
        public CompilerTarget(Loader loader, PFunction function, CompilerTarget parentTarget = null, ISourcePosition position = null)
        {
            if (loader == null)
                throw new ArgumentNullException("loader");
            if (function == null)
                function = loader.ParentApplication.CreateFunction();
            if (!ReferenceEquals(function.ParentApplication, loader.ParentApplication))
                throw new ArgumentException(
                    Resources.CompilerTarget_Cannot_create_for_foreign_function,
                    "function");

            _loader = loader;
            _function = function;
            _parentTarget = parentTarget;
            _importScope = SymbolStore.Create(parentTarget == null ? loader.Symbols : parentTarget.Symbols);
            _ast = AstBlock.CreateRootBlock(position ?? new SourcePosition("",-1,-1),  
                SymbolStore.Create(ImportScope),
                                            AstBlock.RootBlockName, Guid.NewGuid().ToString("N"));
        }
Example #22
0
 /// <summary>
 /// This function disables any symbol downloading support.
 /// </summary>
 internal static void DisableSymbolStore()
 {
     s_tracer           = null;
     s_symbolStore      = null;
     s_symbolCacheAdded = false;
 }
Example #23
0
        /// <summary>
        /// Parses the Windows debugger symbol path (srv*, cache*, etc.).
        /// </summary>
        /// <param name="store">symbol store to chain</param>
        /// <param name="symbolPath">Windows symbol path</param>
        /// <returns>if false, error parsing symbol path</returns>
        private static bool ParseSymbolPath(ref SymbolStore store, string symbolPath)
        {
            string[] paths = symbolPath.Split(";", StringSplitOptions.RemoveEmptyEntries);

            foreach (string path in paths.Reverse())
            {
                string[] parts = path.Split("*", StringSplitOptions.RemoveEmptyEntries);

                // UNC or directory paths are ignored (paths not prefixed with srv* or cache*).
                if (parts.Length > 0)
                {
                    string symbolServerPath = null;
                    string symbolCachePath  = null;
                    bool   msdl             = false;

                    switch (parts[0].ToLowerInvariant())
                    {
                    case "srv":
                        switch (parts.Length)
                        {
                        case 1:
                            msdl = true;
                            break;

                        case 2:
                            symbolServerPath = parts[1];
                            break;

                        case 3:
                            symbolCachePath  = parts[1];
                            symbolServerPath = parts[2];
                            break;

                        default:
                            return(false);
                        }
                        break;

                    case "cache":
                        switch (parts.Length)
                        {
                        case 1:
                            symbolCachePath = GetDefaultSymbolCache();
                            break;

                        case 2:
                            symbolCachePath = parts[1];
                            break;

                        default:
                            return(false);
                        }
                        break;

                    default:
                        // Directory path search (currently ignored)
                        break;
                    }

                    // Add the symbol stores to the chain
                    if (!GetServerSymbolStore(ref store, msdl, false, symbolServerPath, symbolCachePath))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }