File tree Expand file tree Collapse file tree 13 files changed +93
-19
lines changed Expand file tree Collapse file tree 13 files changed +93
-19
lines changed Original file line number Diff line number Diff line change 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 >
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' " >
Original file line number Diff line number Diff line change 55using MudBlazor ;
66using MudBlazor . Utilities ;
77using MudExtensions . Enums ;
8+ using MudExtensions . Extensions ;
89
910namespace 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
Original file line number Diff line number Diff line change 55using MudBlazor ;
66using MudBlazor . Utilities ;
77using MudExtensions . Enums ;
8+ using MudExtensions . Extensions ;
89
910namespace 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
Original file line number Diff line number Diff line change 44using Microsoft . AspNetCore . Components . Web ;
55using MudBlazor ;
66using MudBlazor . Utilities ;
7+ using MudExtensions . Extensions ;
78
89namespace 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
Original file line number Diff line number Diff line change 88using System . Text ;
99using System . Threading . Tasks ;
1010using MudExtensions . Enums ;
11+ using MudExtensions . Extensions ;
1112
1213namespace 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
Original file line number Diff line number Diff line change 99using System . Linq ;
1010using System . Text ;
1111using System . Threading . Tasks ;
12+ using MudExtensions . Extensions ;
1213using static MudBlazor . CategoryTypes ;
1314
1415namespace MudExtensions
@@ -54,7 +55,7 @@ public string Height
5455 return ;
5556 }
5657 _height = value ;
57- UpdateDimensions ( ) . AndForget ( ) ;
58+ UpdateDimensions ( ) . AndForgetExt ( ) ;
5859 }
5960 }
6061
Original file line number Diff line number Diff line change 77using System . Linq ;
88using System . Text ;
99using System . Threading . Tasks ;
10+ using MudExtensions . Extensions ;
1011
1112namespace 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
Original file line number Diff line number Diff line change 88using System . Runtime . InteropServices ;
99using System . Text ;
1010using System . Threading . Tasks ;
11+ using MudExtensions . Extensions ;
1112
1213namespace 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
Original file line number Diff line number Diff line change 66using MudBlazor ;
77using MudBlazor . Utilities ;
88using MudExtensions . Enums ;
9+ using MudExtensions . Extensions ;
910using static MudBlazor . CategoryTypes ;
1011
1112namespace 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
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments