private void Render(DeclareTagHelperFields source, CSharpRenderingContext context)
 {
     foreach (var tagHelperTypeName in source.UsedTagHelperTypeNames)
     {
         var tagHelperVariableName = GetTagHelperVariableName(tagHelperTypeName);
         context.Writer
         .Write("private global::")
         .WriteVariableDeclaration(
             tagHelperTypeName,
             tagHelperVariableName,
             value: null);
     }
 }
        private static void Render(DeclareTagHelperFields source, CSharpRenderingContext context)
        {
            var tagHelperCodeLiterals = context.CodeLiterals.GeneratedTagHelperContext;

            context.Writer.WriteLineHiddenDirective();

            // Need to disable the warning "X is assigned to but never used." for the value buffer since
            // whether it's used depends on how a TagHelper is used.
            context.Writer
            .WritePragma("warning disable 0414")
            .Write("private ")
            .WriteVariableDeclaration("string", StringValueBufferVariableName, value: null)
            .WritePragma("warning restore 0414");

            context.Writer
            .Write("private global::")
            .WriteVariableDeclaration(
                tagHelperCodeLiterals.ExecutionContextTypeName,
                ExecutionContextVariableName,
                value: null);

            context.Writer
            .Write("private global::")
            .Write(tagHelperCodeLiterals.RunnerTypeName)
            .Write(" ")
            .Write(RunnerVariableName)
            .Write(" = new global::")
            .Write(tagHelperCodeLiterals.RunnerTypeName)
            .WriteLine("();");

            const string backedScopeManageVariableName = "__backed" + ScopeManagerVariableName;

            context.Writer
            .Write("private global::")
            .WriteVariableDeclaration(
                tagHelperCodeLiterals.ScopeManagerTypeName,
                backedScopeManageVariableName,
                value: null);

            context.Writer
            .Write("private global::")
            .Write(tagHelperCodeLiterals.ScopeManagerTypeName)
            .Write(" ")
            .WriteLine(ScopeManagerVariableName);

            using (context.Writer.BuildScope())
            {
                context.Writer.WriteLine("get");
                using (context.Writer.BuildScope())
                {
                    context.Writer
                    .Write("if (")
                    .Write(backedScopeManageVariableName)
                    .WriteLine(" == null)");

                    using (context.Writer.BuildScope())
                    {
                        context.Writer
                        .WriteStartAssignment(backedScopeManageVariableName)
                        .WriteStartNewObject(tagHelperCodeLiterals.ScopeManagerTypeName)
                        .Write(tagHelperCodeLiterals.StartTagHelperWritingScopeMethodName)
                        .WriteParameterSeparator()
                        .Write(tagHelperCodeLiterals.EndTagHelperWritingScopeMethodName)
                        .WriteEndMethodInvocation();
                    }

                    context.Writer.WriteReturn(backedScopeManageVariableName);
                }
            }

            foreach (var tagHelperTypeName in source.UsedTagHelperTypeNames)
            {
                var tagHelperVariableName = GetTagHelperVariableName(tagHelperTypeName);
                context.Writer
                .Write("private global::")
                .WriteVariableDeclaration(
                    tagHelperTypeName,
                    tagHelperVariableName,
                    value: null);
            }
        }