Пример #1
0
        public SourceGeneratorProjectItem(string basePath, string filePath, string relativePhysicalPath, string fileKind, AdditionalText additionalText, string cssScope)
        {
            BasePath             = basePath;
            FilePath             = filePath;
            RelativePhysicalPath = relativePhysicalPath;
            _fileKind            = fileKind;
            AdditionalText       = additionalText;
            CssScope             = cssScope;
            var text = AdditionalText.GetText();

            RazorSourceDocument = new SourceTextRazorSourceDocument(AdditionalText.Path, relativePhysicalPath, text);
        }
        public SourceGeneratorProjectItem(string basePath, string filePath, string relativePhysicalPath, string fileKind, AdditionalText additionalText, string?cssScope, GeneratorExecutionContext context)
        {
            BasePath             = basePath;
            FilePath             = filePath;
            RelativePhysicalPath = relativePhysicalPath;
            _fileKind            = fileKind;
            AdditionalText       = additionalText;
            CssScope             = cssScope;
            _context             = context;
            var text = AdditionalText.GetText();

            if (text is null)
            {
                _context.ReportDiagnostic(Diagnostic.Create(RazorDiagnostics.SourceTextNotFoundDescriptor, Location.None, filePath));
            }
            else
            {
                RazorSourceDocument = new SourceTextRazorSourceDocument(AdditionalText.Path, relativePhysicalPath, text);
            }
        }