1+ using System . Diagnostics . CodeAnalysis ;
2+
13namespace DotNext ;
24
35internal static class LibrarySettings
46{
7+ private const string UseNativeAllocationFeature = "DotNext.Buffers.NativeAllocation" ;
8+ private const string UseRandomStringInternalBufferCleanupFeature = "DotNext.Security.RandomStringInternalBufferCleanup" ;
9+
510 internal static int StackallocThreshold
611 {
712 get
@@ -19,32 +24,15 @@ internal static int StackallocThreshold
1924 return result > minimumValue ? result : defaultValue ;
2025 }
2126 }
27+
28+ private static bool IsSupported ( [ ConstantExpected ] string featureName )
29+ => ! AppContext . TryGetSwitch ( featureName , out var result ) || result ;
2230
23- internal static bool DisableRandomStringInternalBufferCleanup
24- {
25- get
26- {
27- const string switchName = "DotNext.Security.DisableRandomStringInternalBufferCleanup" ;
28- const bool defaultValue = false ;
29-
30- if ( ! AppContext . TryGetSwitch ( switchName , out var result ) )
31- result = defaultValue ;
32-
33- return result ;
34- }
35- }
31+ // TODO: [FeatureSwitchDefinition(UseRandomStringInternalBufferCleanupFeature)]
32+ internal static bool UseRandomStringInternalBufferCleanup
33+ => IsSupported ( UseRandomStringInternalBufferCleanupFeature ) ;
3634
37- internal static bool DisableNativeAllocation
38- {
39- get
40- {
41- const string switchName = "DotNext.Buffers.DisableNativeAllocation" ;
42- const bool defaultValue = false ;
43-
44- if ( ! AppContext . TryGetSwitch ( switchName , out var result ) )
45- result = defaultValue ;
46-
47- return result ;
48- }
49- }
35+ // TODO: [FeatureSwitchDefinition(EnableNativeAllocationFeature)]
36+ internal static bool UseNativeAllocation
37+ => IsSupported ( UseNativeAllocationFeature ) ;
5038}
0 commit comments