public void WriteRazorSourceChecksumAttribute_RendersCorrectly()
    {
        // Arrange
        var extension = new MetadataAttributeTargetExtension()
        {
            SourceChecksumAttributeName = "global::TestChecksum",
        };
        var context = TestCodeRenderingContext.CreateRuntime();

        var node = new RazorSourceChecksumAttributeIntermediateNode()
        {
            ChecksumAlgorithm = "SHA1",
            Checksum          = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', },
            Identifier        = "Foo/Bar",
        };

        // Act
        extension.WriteRazorSourceChecksumAttribute(context, node);

        // Assert
        var csharp = context.CodeWriter.GenerateCode();

        Assert.Equal(
            @"[global::TestChecksum(@""SHA1"", @""74657374"", @""Foo/Bar"")]
",
            csharp,
            ignoreLineEndingDifferences: true);
    }
    public void WriteRazorSourceChecksumAttribute(CodeRenderingContext context, RazorSourceChecksumAttributeIntermediateNode node)
    {
        if (context == null)
        {
            throw new ArgumentNullException(nameof(context));
        }

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

        // [global::...RazorSourceChecksum(@"{node.ChecksumAlgorithm}", @"{node.Checksum}", @"{node.Identifier}")]
        context.CodeWriter.Write("[");
        context.CodeWriter.Write(SourceChecksumAttributeName);
        context.CodeWriter.Write("(@\"");
        context.CodeWriter.Write(node.ChecksumAlgorithm);
        context.CodeWriter.Write("\", @\"");
        context.CodeWriter.Write(Checksum.BytesToString(node.Checksum));
        context.CodeWriter.Write("\", @\"");
        context.CodeWriter.Write(node.Identifier);
        context.CodeWriter.WriteLine("\")]");
    }