Ejemplo n.º 1
0
        private static Task <(RazorCodeDocument, VersionStamp, VersionStamp, VersionStamp)> GetOutputAsync(ProjectState project, DocumentState document)
        {
            var projectSnapshot  = new DefaultProjectSnapshot(project);
            var documentSnapshot = new DefaultDocumentSnapshot(projectSnapshot, document);

            return(document.GetGeneratedOutputAndVersionAsync(projectSnapshot, documentSnapshot));
        }
Ejemplo n.º 2
0
        private ProjectState(
            ProjectState older,
            ProjectDifference difference,
            HostProject hostProject,
            ProjectWorkspaceState projectWorkspaceState,
            ImmutableDictionary <string, DocumentState> documents,
            ImmutableDictionary <string, ImmutableArray <string> > importsToRelatedDocuments)
        {
            if (older == null)
            {
                throw new ArgumentNullException(nameof(older));
            }

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

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

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

            Services = older.Services;
            Version  = older.Version.GetNewerVersion();

            HostProject               = hostProject;
            ProjectWorkspaceState     = projectWorkspaceState;
            Documents                 = documents;
            ImportsToRelatedDocuments = importsToRelatedDocuments;

            _lock = new object();

            if ((difference & ClearDocumentCollectionVersionMask) == 0)
            {
                // Document collection hasn't changed
                DocumentCollectionVersion = older.DocumentCollectionVersion;
            }
            else
            {
                DocumentCollectionVersion = Version;
            }

            if ((difference & ClearConfigurationVersionMask) == 0 && older._projectEngine != null)
            {
                // Optimistically cache the RazorProjectEngine.
                _projectEngine       = older.ProjectEngine;
                ConfigurationVersion = older.ConfigurationVersion;
            }
            else
            {
                ConfigurationVersion = Version;
            }

            if ((difference & ClearProjectWorkspaceStateVersionMask) == 0 ||
                ProjectWorkspaceState == older.ProjectWorkspaceState ||
                ProjectWorkspaceState?.Equals(older.ProjectWorkspaceState) == true)
            {
                ProjectWorkspaceStateVersion = older.ProjectWorkspaceStateVersion;
            }
            else
            {
                ProjectWorkspaceStateVersion = Version;
            }

            if ((difference & ClearProjectWorkspaceStateVersionMask) != 0 &&
                CSharpLanguageVersion != older.CSharpLanguageVersion)
            {
                // C# language version changed. This impacts the ProjectEngine, reset it.
                _projectEngine       = null;
                ConfigurationVersion = Version;
            }
        }
Ejemplo n.º 3
0
        private static Task <(RazorCodeDocument, VersionStamp, VersionStamp, VersionStamp)> GetOutputAsync(ProjectState project, HostDocument hostDocument)
        {
            var document = project.Documents[hostDocument.FilePath];

            return(GetOutputAsync(project, document));
        }