Beispiel #1
0
        private DynamicFileInfo CreateInfo(Key key, DynamicDocumentContainer document)
        {
            var filename   = key.FilePath + ".g.cs";
            var textLoader = document.GetTextLoader(filename);

            return(new DynamicFileInfo(filename, SourceCodeKind.Regular, textLoader, _factory.Create(document)));
        }
Beispiel #2
0
        // Called by us to update entries
        public override void UpdateFileInfo(string projectFilePath, DynamicDocumentContainer documentContainer)
        {
            if (projectFilePath == null)
            {
                throw new ArgumentNullException(nameof(projectFilePath));
            }

            if (documentContainer == null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            // There's a possible race condition here where we're processing an update
            // and the project is getting unloaded. So if we don't find an entry we can
            // just ignore it.
            var key = new Key(projectFilePath, documentContainer.FilePath);

            if (_entries.TryGetValue(key, out var entry))
            {
                lock (entry.Lock)
                {
                    var textLoader = documentContainer.GetTextLoader(entry.Current.FilePath);
                    entry.Current = entry.Current.WithTextLoader(textLoader);
                }

                Updated?.Invoke(entry.Current);
            }
        }