Add RazorCSharpSourceDocument
Precursor to actual CSharp lowering
This commit is contained in:
parent
9cefcdd450
commit
2190dc2096
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution
|
||||
{
|
||||
public class RazorCSharpDocument
|
||||
{
|
||||
public string GeneratedCode { get; set; }
|
||||
|
||||
internal IReadOnlyList<LineMapping> LineMappings { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -47,5 +47,25 @@ namespace Microsoft.AspNetCore.Razor.Evolution
|
|||
|
||||
document.Items[typeof(DocumentIRNode)] = irDocument;
|
||||
}
|
||||
|
||||
public static RazorCSharpDocument GetCSharpDocument(this RazorCodeDocument document)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(document));
|
||||
}
|
||||
|
||||
return (RazorCSharpDocument)document.Items[typeof(RazorCSharpDocument)];
|
||||
}
|
||||
|
||||
public static void SetCSharpDocument(this RazorCodeDocument document, RazorCSharpDocument csharp)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(document));
|
||||
}
|
||||
|
||||
document.Items[typeof(RazorCSharpDocument)] = csharp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,5 +69,36 @@ namespace Microsoft.AspNetCore.Razor.Evolution
|
|||
// Assert
|
||||
Assert.Same(expected, codeDocument.Items[typeof(DocumentIRNode)]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCSharpDocument_ReturnsCSharpDocument()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
|
||||
var expected = new RazorCSharpDocument();
|
||||
codeDocument.Items[typeof(RazorCSharpDocument)] = expected;
|
||||
|
||||
// Act
|
||||
var actual = codeDocument.GetCSharpDocument();
|
||||
|
||||
// Assert
|
||||
Assert.Same(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetCSharpDocument_SetsCSharpDocument()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
|
||||
var expected = new RazorCSharpDocument();
|
||||
|
||||
// Act
|
||||
codeDocument.SetCSharpDocument(expected);
|
||||
|
||||
// Assert
|
||||
Assert.Same(expected, codeDocument.Items[typeof(RazorCSharpDocument)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue