Repository: dotnet/aspnetcore
File: src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs (C#)

Code before:
        _resourceCollection ??= GetResourceCollection(_httpContext) ?? base.Assets;

    private static ResourceAssetCollection? GetResourceCollection(HttpContext httpContext) => httpContext.GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();

    protected override void AddPendingTask(ComponentState? componentState, Task task)
    {
        if (_isReExecuted)
        {
            return;
        }

        var streamRendering = componentState is null
            ? false
            : ((EndpointComponentState)componentState).StreamRendering;

        if (!streamRendering)
        {
            _nonStreamingPendingTasks.Add(task);
        }

        // We still need to determine full quiescence, so always let the base renderer track this task too
        base.AddPendingTask(componentState, task);
    }

    internal void SignalRendererToFinishRendering()
    {
        // sets a deferred stop on the renderer, which will have an effect after the current batch is completed
        _rendererIsStopped = true;
    }

    protected override void ProcessPendingRender()
    {
        if (_rendererIsStopped)
        {
            return;
        }
        base.ProcessPendingRender();
    }

    // For tests only
    internal Task? NonStreamingPendingTasksCompletion;

    protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
    {
        UpdateNamedSubmitEvents(in renderBatch);

        if (_streamingUpdatesWriter is { } writer && !_rendererIsStopped)
        {
            // Important: SendBatchAsStreamingUpdate *must* be invoked synchronously
            // before any 'await' in this method. That's enforced by the compiler
            // (the method has an 'in' parameter) but even if it wasn't, it would still

Review comment (suggestion):
```suggestion
    // For testing purposes only
    internal void SignalRendererToFinishRendering()
```


Code after:
        _resourceCollection ??= GetResourceCollection(_httpContext) ?? base.Assets;

    private static ResourceAssetCollection? GetResourceCollection(HttpContext httpContext) => httpContext.GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();

    protected override void AddPendingTask(ComponentState? componentState, Task task)
    {
        if (_isReExecuted)
        {
            return;
        }

        var streamRendering = componentState is null
            ? false
            : ((EndpointComponentState)componentState).StreamRendering;

        if (!streamRendering)
        {
            _nonStreamingPendingTasks.Add(task);
        }

        // We still need to determine full quiescence, so always let the base renderer track this task too
        base.AddPendingTask(componentState, task);
    }

    // For testing purposes only
    internal void SignalRendererToFinishRendering()
    {
        // sets a deferred stop on the renderer, which will have an effect after the current batch is completed
        _rendererIsStopped = true;
    }

    protected override void ProcessPendingRender()
    {
        if (_rendererIsStopped)
        {
            return;
        }
        base.ProcessPendingRender();
    }

    // For tests only
    internal Task? NonStreamingPendingTasksCompletion;

    protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
    {
        UpdateNamedSubmitEvents(in renderBatch);

        if (_streamingUpdatesWriter is { } writer && !_rendererIsStopped)
        {
            // Important: SendBatchAsStreamingUpdate *must* be invoked synchronously
            // before any 'await' in this method. That's enforced by the compiler