Exemplo n.º 1
0
        public void WriteDocument_Empty_SuppressChecksumTrue_DoesnotWriteChecksum()
        {
            // Arrange
            var document = new DocumentIntermediateNode();

            var codeDocument   = TestRazorCodeDocument.CreateEmpty();
            var optionsBuilder = new DefaultRazorCodeGenerationOptionsBuilder(designTime: false)
            {
                SuppressChecksum = true
            };
            var options = optionsBuilder.Build();

            var target = CodeTarget.CreateDefault(codeDocument, options);
            var writer = new DefaultDocumentWriter(target, options);

            // Act
            var result = writer.WriteDocument(codeDocument, document);

            // Assert
            var csharp = result.GeneratedCode;

            Assert.Equal(
                @"// <auto-generated/>
#pragma warning disable 1591
#pragma warning restore 1591
",
                csharp,
                ignoreLineEndingDifferences: true);
        }
    public static RazorCodeGenerationOptions Create(Action <RazorCodeGenerationOptionsBuilder> configure)
    {
        if (configure == null)
        {
            throw new ArgumentNullException(nameof(configure));
        }

        var builder = new DefaultRazorCodeGenerationOptionsBuilder(designTime: false);

        configure(builder);
        var options = builder.Build();

        return(options);
    }
Exemplo n.º 3
0
    public RazorCodeGenerationOptions Create(string fileKind, Action <RazorCodeGenerationOptionsBuilder> configure)
    {
        var builder = new DefaultRazorCodeGenerationOptionsBuilder(ProjectEngine.Configuration, fileKind);

        configure?.Invoke(builder);

        for (var i = 0; i < _configureOptions.Length; i++)
        {
            _configureOptions[i].Configure(builder);
        }

        var options = builder.Build();

        return(options);
    }
    public static RazorCodeGenerationOptions CreateDesignTime(Action <RazorCodeGenerationOptionsBuilder> configure)
    {
        if (configure == null)
        {
            throw new ArgumentNullException(nameof(configure));
        }

        var builder = new DefaultRazorCodeGenerationOptionsBuilder(designTime: true)
        {
            SuppressMetadataAttributes = true,
        };

        configure(builder);
        var options = builder.Build();

        return(options);
    }