• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marthijn / Sidio.OpenGraph / 17172922377

23 Aug 2025 07:36AM UTC coverage: 93.401% (-0.4%) from 93.814%
17172922377

push

github

marthijn
♻️ Refactor Open Graph functionality with Object Pool integration

29 of 29 branches covered (100.0%)

Branch coverage included in aggregate %.

24 of 25 new or added lines in 4 files covered. (96.0%)

155 of 168 relevant lines covered (92.26%)

60.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/src/Sidio.OpenGraph.AspNetCore/HtmlHelperExtensions.cs
1
using System.Text;
2
using Microsoft.AspNetCore.Html;
3
using Microsoft.AspNetCore.Mvc.Rendering;
4

5
namespace Sidio.OpenGraph.AspNetCore;
6

7
/// <summary>
8
/// The HtmlHelperExtensions class provides extensions.
9
/// </summary>
10
public static class HtmlHelperExtensions
11
{
12
    /// <summary>
13
    /// Renders the Open Graph tags.
14
    /// </summary>
15
    /// <param name="htmlHelper">The HTML helper.</param>
16
    /// <returns>An <see cref="HtmlString"/>.</returns>
17
    public static HtmlString RenderOpenGraphTags(this IHtmlHelper htmlHelper)
18
    {
19
        if (htmlHelper.ViewContext.ViewData[Constants.ViewDataKey] is not OpenGraph openGraph)
2✔
20
        {
21
            return new HtmlString(string.Empty);
×
22
        }
23

24
        var html = openGraph.MetaTagsToHtml();
2✔
25
        return new HtmlString(html);
2✔
26
    }
27

28
    /// <summary>
29
    /// Renders the Open Graph tags.
30
    /// </summary>
31
    /// <param name="htmlHelper">The HTML helper.</param>
32
    /// <param name="pool">The string builder object pool.</param>
33
    /// <returns>An <see cref="HtmlString"/>.</returns>
34
    public static HtmlString RenderOpenGraphTags(this IHtmlHelper htmlHelper, Microsoft.Extensions.ObjectPool.ObjectPool<StringBuilder> pool)
35
    {
36
        if (htmlHelper.ViewContext.ViewData[Constants.ViewDataKey] is not OpenGraph openGraph)
2✔
37
        {
NEW
38
            return new HtmlString(string.Empty);
×
39
        }
40

41
        var html = openGraph.MetaTagsToHtml(pool);
2✔
42
        return new HtmlString(html);
2✔
43
    }
44

45
    /// <summary>
46
    /// Gets the Open Graph prefix attribute value.
47
    /// </summary>
48
    /// <param name="htmlHelper">The HTML helper.</param>
49
    /// <returns>A <see cref="string"/>.</returns>
50
    public static string GetOpenGraphPrefixAttributeValue(this IHtmlHelper htmlHelper)
51
    {
52
        if (htmlHelper.ViewContext.ViewData[Constants.ViewDataKey] is not OpenGraph openGraph)
2✔
53
        {
54
            return string.Empty;
×
55
        }
56

57
        return openGraph.PrefixAttributeValue;
2✔
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc