File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
2+ using System . Diagnostics . CodeAnalysis ;
23using System . Runtime . CompilerServices ;
34namespace LibDeflate . Imports ;
45
@@ -19,23 +20,29 @@ internal readonly struct libdeflate_options
1920 public libdeflate_options ( malloc_func malloc , free_func free )
2021 {
2122#if NET6_0_OR_GREATER
22- ArgumentNullException . ThrowIfNull ( malloc ) ;
23- ArgumentNullException . ThrowIfNull ( free ) ;
23+ ArgumentNullException . ThrowIfNull ( malloc ) ;
24+ ArgumentNullException . ThrowIfNull ( free ) ;
2425#else
25- //TODO: add throwhelpers
26- if ( malloc is null )
27- {
28- throw new ArgumentNullException ( nameof ( malloc ) ) ;
29- }
30-
31- if ( free is null )
32- {
33- throw new ArgumentNullException ( nameof ( free ) ) ;
34- }
26+ ThrowIfNull ( malloc ) ;
27+ ThrowIfNull ( free ) ;
3528#endif
29+
3630 this . sizeof_options = Size ;
3731 this . malloc = malloc ;
3832 this . free = free ;
33+
34+ #if ! NET6_0_OR_GREATER
35+ static void ThrowIfNull ( [ NotNull ] object ? argument , [ CallerArgumentExpression ( nameof ( argument ) ) ] string ? paramName = null )
36+ {
37+ if ( argument is null )
38+ {
39+ ThrowHelperArgumentNull ( paramName ! ) ;
40+ }
41+
42+ [ DoesNotReturn ]
43+ static void ThrowHelperArgumentNull ( string paramName ) => throw new ArgumentNullException ( paramName ) ;
44+ }
45+ #endif
3946 }
4047
4148 /// <summary>
You can’t perform that action at this time.
0 commit comments