Beispiel #1
0
        public void Execute(RazorCodeDocument codeDocument)
        {
            var writer       = BlazorComponentDocumentWriter.Create(_codegenOptions);
            var documentNode = codeDocument.GetDocumentIntermediateNode();
            var csharpDoc    = writer.WriteDocument(codeDocument, documentNode);

            codeDocument.SetCSharpDocument(csharpDoc);
        }
Beispiel #2
0
        protected override void ExecuteCore(RazorCodeDocument codeDocument)
        {
            var documentNode = codeDocument.GetDocumentIntermediateNode();

            ThrowForMissingDocumentDependency(documentNode);
#pragma warning disable CS0618
            var writer = new DocumentWriterWorkaround().Create(documentNode.Target, documentNode.Options);
#pragma warning restore CS0618
            try
            {
                var cSharpDocument = writer.WriteDocument(codeDocument, documentNode);
                codeDocument.SetCSharpDocument(cSharpDocument);
            }
            catch (RazorCompilerException ex)
            {
                // Currently the Blazor code generation has some 'fatal errors' that can cause code generation
                // to fail completely. This class is here to make that implementation work gracefully.
                var cSharpDocument = RazorCSharpDocument.Create("", documentNode.Options, new[] { ex.Diagnostic });
                codeDocument.SetCSharpDocument(cSharpDocument);
            }
        }
Beispiel #3
0
 public void Execute(RazorCodeDocument codeDocument)
 {
     if (Writer != null)
     {
         var intermediateNode       = codeDocument.GetDocumentIntermediateNode();
         RazorCSharpDocument csharp = Writer.WriteDocument(codeDocument, intermediateNode);
         codeDocument.SetCSharpDocument(csharp);
     }
     else
     {
         _inner.Execute(codeDocument);
     }
 }
        protected override void ExecuteCore(RazorCodeDocument codeDocument)
        {
            var documentNode = codeDocument.GetDocumentIntermediateNode();

            ThrowForMissingDocumentDependency(documentNode);

            var cSharpDocument = RazorCSharpDocument.Create(
                UnsupportedDisclaimer,
                documentNode.Options,
                Enumerable.Empty <RazorDiagnostic>());

            codeDocument.SetCSharpDocument(cSharpDocument);
            codeDocument.SetUnsupported();
        }
    protected override void ExecuteCore(RazorCodeDocument codeDocument)
    {
        var documentNode = codeDocument.GetDocumentIntermediateNode();

        ThrowForMissingDocumentDependency(documentNode);

        var target = documentNode.Target;

        if (target == null)
        {
            var message = Resources.FormatDocumentMissingTarget(
                documentNode.DocumentKind,
                nameof(CodeTarget),
                nameof(DocumentIntermediateNode.Target));
            throw new InvalidOperationException(message);
        }

        var writer         = DocumentWriter.CreateDefault(documentNode.Target, documentNode.Options);
        var cSharpDocument = writer.WriteDocument(codeDocument, documentNode);

        codeDocument.SetCSharpDocument(cSharpDocument);
    }