Skip to content

Commit 9bf0b8c

Browse files
Bump MudBlazor from 9.2.0 to 9.5.0 (#409)
1 parent b8d0c39 commit 9bf0b8c

2 files changed

Lines changed: 64 additions & 1 deletion

File tree

src/MudBlazor.Markdown/MudBlazor.Markdown.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<ItemGroup>
2424
<PackageReference Include="Markdig" Version="1.1.3" />
25-
<PackageReference Include="MudBlazor" Version="9.2.0" />
25+
<PackageReference Include="MudBlazor" Version="9.5.0" />
2626
</ItemGroup>
2727

2828
<ItemGroup>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#if NET10_0_OR_GREATER
2+
using System.Runtime.CompilerServices;
3+
#else
4+
using System.Reflection;
5+
#endif
6+
7+
namespace MudBlazor;
8+
9+
internal static class MudBlazorEx
10+
{
11+
#if NET10_0_OR_GREATER
12+
[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "ToStringFast")]
13+
private static extern string MudToStringFast(
14+
[UnsafeAccessorType("MudBlazor.ColorExtensions, MudBlazor")]
15+
object _,
16+
Color color
17+
);
18+
19+
[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "ToStringFast")]
20+
private static extern string MudToStringFast(
21+
[UnsafeAccessorType("MudBlazor.UnderlineExtensions, MudBlazor")]
22+
object _,
23+
Underline underline
24+
);
25+
26+
[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "ToStringFast")]
27+
private static extern string MudToStringFast(
28+
[UnsafeAccessorType("MudBlazor.TypoExtensions, MudBlazor")]
29+
object _,
30+
Typo typo
31+
);
32+
#else
33+
private static string MudToStringFast(object _, Color color)
34+
{
35+
var extensions = typeof(Color).Assembly.GetType("MudBlazor.ColorExtensions");
36+
var method = extensions?.GetMethod("ToStringFast", types: [typeof(Color)], bindingAttr: BindingFlags.Public | BindingFlags.Static);
37+
return (string?)method?.Invoke(null, [color]) ?? throw new InvalidOperationException("Unable to find Color from MudBlazor");
38+
}
39+
40+
private static string MudToStringFast(object _, Underline underline)
41+
{
42+
var extensions = typeof(Underline).Assembly.GetType("MudBlazor.UnderlineExtensions");
43+
var method = extensions?.GetMethod("ToStringFast", types: [typeof(Underline)], bindingAttr: BindingFlags.Public | BindingFlags.Static);
44+
return (string?)method?.Invoke(null, [underline]) ?? throw new InvalidOperationException("Unable to find Underline from MudBlazor");
45+
}
46+
47+
private static string MudToStringFast(object _, Typo typo)
48+
{
49+
var extensions = typeof(Typo).Assembly.GetType("MudBlazor.TypoExtensions");
50+
var method = extensions?.GetMethod("ToStringFast", types: [typeof(Typo)], bindingAttr: BindingFlags.Public | BindingFlags.Static);
51+
return (string?)method?.Invoke(null, [typo]) ?? throw new InvalidOperationException("Unable to find Typo from MudBlazor");
52+
}
53+
#endif
54+
55+
public static string ToStringFast(this Color color)
56+
=> MudToStringFast(null!, color);
57+
58+
public static string ToStringFast(this Underline underline)
59+
=> MudToStringFast(null!, underline);
60+
61+
public static string ToStringFast(this Typo typo)
62+
=> MudToStringFast(null!, typo);
63+
}

0 commit comments

Comments
 (0)