< Summary

Information
Class: UIBlazor.Components.Chat.MarkdownBlock
Assembly: UIBlazor
File(s): /home/runner/work/InvAit/InvAit/UIBlazor/Components/Chat/MarkdownBlock.razor
Tag: 14_22728831704
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 31
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
BuildRenderTree(...)100%210%
get_Content()100%210%
.ctor()100%210%
ShouldRender()100%210%
OnAfterRenderAsync()0%620%

File(s)

/home/runner/work/InvAit/InvAit/UIBlazor/Components/Chat/MarkdownBlock.razor

#LineLine coverage
 1@inject IJSRuntime Js
 2
 3<div id="@_blockId" class="markdown-content">
 04    @((MarkupString)_processedContent)
 5</div>
 6
 7@code {
 08    [Parameter] public string Content { get; set; } = string.Empty;
 9
 010    private readonly string _blockId = $"md-{Guid.NewGuid()}";
 011    private string _lastRenderedContent = string.Empty;
 012    private string _processedContent = string.Empty;
 13
 014    protected override bool ShouldRender() => Content != _lastRenderedContent;
 15
 16    protected override async Task OnAfterRenderAsync(bool firstRender)
 17    {
 018        if (Content != _lastRenderedContent)
 19        {
 020            _lastRenderedContent = Content;
 21            try
 22            {
 023                await Js.InvokeVoidAsync("renderMarkdownToElement", _blockId, Content);
 024            }
 025            catch (JSException)
 26            {
 27                // Ignore JS errors during rendering if element is disposed
 028            }
 29        }
 030    }
 31}