Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Moved CSharpCodeWriter out of legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaybhargavb committed Jun 21, 2017
1 parent 21e26ad commit 4811807
Show file tree
Hide file tree
Showing 24 changed files with 658 additions and 942 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Microsoft.AspNetCore.Razor.Language.Legacy;

namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{
Expand Down Expand Up @@ -51,7 +51,7 @@ private void GenerateVCTHClass(ClassDeclarationIntermediateNode @class, TagHelpe
.Add(new IntermediateToken()
{
Kind = IntermediateToken.TokenKind.CSharp,
Content = writer.Builder.ToString()
Content = writer.GenerateCode()
});

@class.Children.Add(statement);
Expand Down Expand Up @@ -101,7 +101,7 @@ private void WriteClass(CSharpCodeWriter writer, TagHelperDescriptor descriptor)
var tagHelperTypeName = "Microsoft.AspNetCore.Razor.TagHelpers.TagHelper";
var className = GetVCTHClassName(descriptor);

using (writer.BuildClassDeclaration("public", className, new[] { tagHelperTypeName }))
using (writer.BuildClassDeclaration("public", className, tagHelperTypeName, interfaces: null))
{
// Add view component helper.
writer.WriteVariableDeclaration(
Expand All @@ -122,11 +122,12 @@ private void WriteClass(CSharpCodeWriter writer, TagHelperDescriptor descriptor)

private void BuildConstructorString(CSharpCodeWriter writer, string className)
{
var helperPair = new KeyValuePair<string, string>(
$"global::Microsoft.AspNetCore.Mvc.IViewComponentHelper",
"helper");

using (writer.BuildConstructor("public", className, new[] { helperPair }))
writer.Write("public ")
.Write(className)
.Write("(")
.Write("global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper")
.WriteLine(")");
using (writer.BuildScope())
{
writer.WriteStartAssignment("_helper")
.Write("helper")
Expand Down
Loading

0 comments on commit 4811807

Please sign in to comment.