Exemple #1
0
            internal Snapshot(
                VisualStudioMetadataReferenceManager provider,
                MetadataReferenceProperties properties,
                string fullPath,
                FileChangeTracker fileChangeTrackerOpt
                ) : base(properties, fullPath)
            {
                Debug.Assert(Properties.Kind == MetadataImageKind.Assembly);
                _provider             = provider;
                _fileChangeTrackerOpt = fileChangeTrackerOpt;

                _timestamp = new Lazy <DateTime>(
                    () =>
                {
                    try
                    {
                        _fileChangeTrackerOpt?.EnsureSubscription();

                        return(FileUtilities.GetFileTimeStamp(this.FilePath));
                    }
                    catch (IOException e)
                    {
                        // Reading timestamp of a file might fail.
                        // Let's remember the failure and report it to the compiler when it asks for metadata.
                        // We could let the Lazy hold onto this (since it knows how to rethrow exceptions), but
                        // our support of GetStorages needs to gracefully handle the case where we have no timestamp.
                        // If Lazy had a "IsValueFaulted" we could be cleaner here.
                        _error = e;
                        return(DateTime.MinValue);
                    }
                },
                    LazyThreadSafetyMode.PublicationOnly
                    );
            }
 public VisualStudioAnalyzer(string fullPath, IVsFileChangeEx fileChangeService, HostDiagnosticUpdateSource hostDiagnosticUpdateSource, ProjectId projectId, Workspace workspace, string language)
 {
     _fullPath = fullPath;
     _tracker = new FileChangeTracker(fileChangeService, fullPath);
     _tracker.UpdatedOnDisk += OnUpdatedOnDisk;
     _tracker.StartFileChangeListeningAsync();
     _tracker.EnsureSubscription();
     _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
     _projectId = projectId;
     _workspace = workspace;
     _language = language;
 }
Exemple #3
0
 public VisualStudioAnalyzer(string fullPath, IVsFileChangeEx fileChangeService, HostDiagnosticUpdateSource hostDiagnosticUpdateSource, ProjectId projectId, Workspace workspace, string language)
 {
     _fullPath = fullPath;
     _tracker  = new FileChangeTracker(fileChangeService, fullPath);
     _tracker.UpdatedOnDisk += OnUpdatedOnDisk;
     _tracker.StartFileChangeListeningAsync();
     _tracker.EnsureSubscription();
     _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
     _projectId = projectId;
     _workspace = workspace;
     _language  = language;
 }
 public override Task <TextAndVersion> LoadTextAndVersionAsync(Workspace workspace, DocumentId documentId, CancellationToken cancellationToken)
 {
     _fileChangeTracker.EnsureSubscription();
     return(_innerTextLoader.LoadTextAndVersionAsync(workspace, documentId, cancellationToken));
 }