public async Task <DynamicFileInfo?> GetDynamicFileInfoAsync(
            ProjectId projectId,
            string projectFilePath,
            string filePath,
            CancellationToken cancellationToken
            )
        {
            // We lazily attach to the dynamic file info provider in order to ensure that Razor assemblies are not loaded in non-Razor contexts.
            if (!EnsureAttached())
            {
                // Razor workload is not installed. Can't build dynamic file infos for any Razor files.
                return(null);
            }

            var result = await _innerDynamicFileInfoProvider.Value
                         .GetDynamicFileInfoAsync(projectId, projectFilePath, filePath, cancellationToken)
                         .ConfigureAwait(false);

            var serviceProvider = new RazorDocumentServiceProviderWrapper(
                result.DocumentServiceProvider
                );
            var razorDocumentPropertiesService =
                result.DocumentServiceProvider.GetService <IRazorDocumentPropertiesService>();
            var designTimeOnly  = razorDocumentPropertiesService?.DesignTimeOnly ?? false;
            var dynamicFileInfo = new DynamicFileInfo(
                result.FilePath,
                result.SourceCodeKind,
                result.TextLoader,
                designTimeOnly,
                serviceProvider
                );

            return(dynamicFileInfo);
        }
            public Entry(DynamicFileInfo current)
            {
                if (current == null)
                {
                    throw new ArgumentNullException(nameof(current));
                }

                Current = current;
                Lock    = new object();
            }
Ejemplo n.º 3
0
            public Entry(DynamicFileInfo current, bool supportsSuppression)
            {
                if (current == null)
                {
                    throw new ArgumentNullException(nameof(current));
                }

                Current             = current;
                SupportsSuppression = supportsSuppression;
                Lock = new object();
            }