Skip to content

Commit c9d4a48

Browse files
authored
Update 6.0.5: Compatibility With MudBlazor 6.1.4 and Replace All AndForget to AndFo… (#78)
* Compatibility With MudBlazor 6.1.4 and Replace All AndForget to AndForgetExt * Some Little Fix
1 parent 02d5a8e commit c9d4a48

File tree

13 files changed

+93
-19
lines changed

13 files changed

+93
-19
lines changed

CodeBeam.MudExtensions/CodeBeam.MudExtensions.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
55
<Nullable>disable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<Version>6.1.4</Version>
7+
<Version>6.1.5</Version>
88
<Title>CodeBeam.MudBlazor.Extensions</Title>
99
<Authors>CodeBeam</Authors>
1010
<Company>CodeBeam</Company>
@@ -21,12 +21,12 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="MudBlazor" Version="6.1.2" />
24+
<PackageReference Include="MudBlazor" Version="6.1.4" />
2525
</ItemGroup>
2626

2727
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
28-
<PackageReference Include="Microsoft.AspNetCore.Components" Version="6.0.10" />
29-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.10" />
28+
<PackageReference Include="Microsoft.AspNetCore.Components" Version="6.0.11" />
29+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.11" />
3030
</ItemGroup>
3131

3232
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">

CodeBeam.MudExtensions/Components/Loading/MudLoading.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using MudBlazor;
66
using MudBlazor.Utilities;
77
using MudExtensions.Enums;
8+
using MudExtensions.Extensions;
89

910
namespace MudExtensions
1011
{
@@ -32,7 +33,7 @@ public bool Loading
3233
return;
3334
}
3435
_loading = value;
35-
LoadingChanged.InvokeAsync(_loading).AndForget();
36+
LoadingChanged.InvokeAsync(_loading).AndForgetExt();
3637
}
3738
}
3839

CodeBeam.MudExtensions/Components/LoadingButton/MudLoadingButton.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using MudBlazor;
66
using MudBlazor.Utilities;
77
using MudExtensions.Enums;
8+
using MudExtensions.Extensions;
89

910
namespace MudExtensions
1011
{
@@ -27,7 +28,7 @@ public bool Loading
2728
return;
2829
}
2930
_loading = value;
30-
LoadingChanged.InvokeAsync(_loading).AndForget();
31+
LoadingChanged.InvokeAsync(_loading).AndForgetExt();
3132
}
3233
}
3334

CodeBeam.MudExtensions/Components/PasswordField/MudPasswordField.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.AspNetCore.Components.Web;
55
using MudBlazor;
66
using MudBlazor.Utilities;
7+
using MudExtensions.Extensions;
78

89
namespace MudExtensions
910
{
@@ -116,7 +117,7 @@ public bool PasswordMode
116117
_passwordIcon = Icons.Filled.Visibility;
117118
}
118119

119-
PasswordModeChanged.InvokeAsync(value).AndForget();
120+
PasswordModeChanged.InvokeAsync(value).AndForgetExt();
120121
}
121122
}
122123

CodeBeam.MudExtensions/Components/Popup/MudPopup.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Text;
99
using System.Threading.Tasks;
1010
using MudExtensions.Enums;
11+
using MudExtensions.Extensions;
1112

1213
namespace MudExtensions
1314
{
@@ -50,7 +51,7 @@ public bool Open
5051
return;
5152
}
5253
_open = value;
53-
OpenChanged.InvokeAsync(_open).AndForget();
54+
OpenChanged.InvokeAsync(_open).AndForgetExt();
5455
}
5556
}
5657

CodeBeam.MudExtensions/Components/Splitter/MudSplitter.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Linq;
1010
using System.Text;
1111
using System.Threading.Tasks;
12+
using MudExtensions.Extensions;
1213
using static MudBlazor.CategoryTypes;
1314

1415
namespace MudExtensions
@@ -54,7 +55,7 @@ public string Height
5455
return;
5556
}
5657
_height = value;
57-
UpdateDimensions().AndForget();
58+
UpdateDimensions().AndForgetExt();
5859
}
5960
}
6061

CodeBeam.MudExtensions/Components/Stepper/MudStep.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using System.Text;
99
using System.Threading.Tasks;
10+
using MudExtensions.Extensions;
1011

1112
namespace MudExtensions
1213
{
@@ -42,7 +43,7 @@ public StepStatus Status
4243
return;
4344
}
4445
_status = value;
45-
StatusChanged.InvokeAsync(_status).AndForget();
46+
StatusChanged.InvokeAsync(_status).AndForgetExt();
4647
}
4748
}
4849

CodeBeam.MudExtensions/Components/Toggle/MudToggle.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Runtime.InteropServices;
99
using System.Text;
1010
using System.Threading.Tasks;
11+
using MudExtensions.Extensions;
1112

1213
namespace MudExtensions
1314
{
@@ -45,7 +46,7 @@ public bool Toggled
4546
return;
4647
}
4748
_toggled = value;
48-
ToggledChanged.InvokeAsync().AndForget();
49+
ToggledChanged.InvokeAsync().AndForgetExt();
4950
}
5051
}
5152

CodeBeam.MudExtensions/Components/Watch/MudWatch.razor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using MudBlazor;
77
using MudBlazor.Utilities;
88
using MudExtensions.Enums;
9+
using MudExtensions.Extensions;
910
using static MudBlazor.CategoryTypes;
1011

1112
namespace MudExtensions
@@ -43,7 +44,7 @@ protected override void OnInitialized()
4344

4445
if (Mode == WatchMode.Watch)
4546
{
46-
SetWatchMode(Mode).AndForget();
47+
SetWatchMode(Mode).AndForgetExt();
4748
Start();
4849
}
4950
}
@@ -94,7 +95,7 @@ public WatchMode Mode
9495
return;
9596
}
9697
_watchMode = value;
97-
SetWatchMode(_watchMode).AndForget();
98+
SetWatchMode(_watchMode).AndForgetExt();
9899
}
99100
}
100101

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using MudBlazor;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace MudExtensions.Extensions
9+
{
10+
public static class TaskExtensions
11+
{
12+
/// <summary>
13+
/// Task will be awaited and exceptions will be logged to console (TaskOption.Safe) or managed by the Blazor framework (TaskOption.None).
14+
/// </summary>
15+
public static async void AndForgetExt(this Task task, TaskOption option = TaskOption.None)
16+
{
17+
try
18+
{
19+
await task;
20+
}
21+
catch (Exception ex)
22+
{
23+
if (option != TaskOption.Safe)
24+
throw;
25+
26+
Console.WriteLine(ex);
27+
}
28+
}
29+
30+
/// <summary>
31+
/// ValueTask will be awaited and exceptions will be logged to console (TaskOption.Safe) or managed by the Blazor framework (TaskOption.None).
32+
/// </summary>
33+
public static async void AndForgetExt(this ValueTask task, TaskOption option = TaskOption.None)
34+
{
35+
try
36+
{
37+
await task;
38+
}
39+
catch (Exception ex)
40+
{
41+
if (option != TaskOption.Safe)
42+
throw;
43+
44+
Console.WriteLine(ex);
45+
}
46+
}
47+
48+
/// <summary>
49+
/// ValueTask(bool) will be awaited and exceptions will be logged to console (TaskOption.Safe) or managed by the Blazor framework (TaskOption.None).
50+
/// </summary>
51+
public static async void AndForgetExt(this ValueTask<bool> task, TaskOption option = TaskOption.None)
52+
{
53+
try
54+
{
55+
await task;
56+
}
57+
catch (Exception ex)
58+
{
59+
if (option != TaskOption.Safe)
60+
throw;
61+
62+
Console.WriteLine(ex);
63+
}
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)