@@ -14,80 +14,79 @@ namespace Microsoft.Maui
1414 /// </remarks>
1515 static class RuntimeFeature
1616 {
17+ const string FeatureSwitchPrefix = "Microsoft.Maui.RuntimeFeature." ;
18+
1719 const bool IsIVisualAssemblyScanningEnabledByDefault = false ;
1820 const bool IsShellSearchResultsRendererDisplayMemberNameSupportedByDefault = true ;
1921 const bool IsQueryPropertyAttributeSupportedByDefault = true ;
2022 const bool IsImplicitCastOperatorsUsageViaReflectionSupportedByDefault = true ;
2123 const bool AreBindingInterceptorsSupportedByDefault = true ;
2224 const bool IsXamlCBindingWithSourceCompilationEnabledByDefault = false ;
2325 const bool IsHybridWebViewSupportedByDefault = true ;
24- < << << << HEAD
2526 const bool SupportNamescopesByDefault = true ;
2627 const string FeatureSwitchPrefix = "Microsoft.Maui.RuntimeFeature" ;
27- = == == ==
2828 const bool EnableDiagnosticsByDefault = false ;
29- > >>> >>> b2393753db ( Turn Visual and Binding diags on EnableDiagnostics)
3029
3130#pragma warning disable IL4000 // Return value does not match FeatureGuardAttribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute'.
3231#if NET9_0_OR_GREATER
33- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature. IsIVisualAssemblyScanningEnabled") ]
32+ [ FeatureSwitchDefinition ( $ " { FeatureSwitchPrefix } . { nameof ( IsIVisualAssemblyScanningEnabled ) } ") ]
3433 [ FeatureGuard ( typeof ( RequiresUnreferencedCodeAttribute ) ) ]
3534#endif
3635 public static bool IsIVisualAssemblyScanningEnabled =>
37- AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature. IsIVisualAssemblyScanningEnabled", out bool isEnabled )
36+ AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( IsIVisualAssemblyScanningEnabled ) } ", out bool isEnabled )
3837 ? isEnabled
3938 : IsIVisualAssemblyScanningEnabledByDefault ;
4039
4140#if NET9_0_OR_GREATER
42- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature. IsShellSearchResultsRendererDisplayMemberNameSupported") ]
41+ [ FeatureSwitchDefinition ( $ " { FeatureSwitchPrefix } . { nameof ( IsShellSearchResultsRendererDisplayMemberNameSupported ) } ") ]
4342 [ FeatureGuard ( typeof ( RequiresUnreferencedCodeAttribute ) ) ]
4443#endif
4544 public static bool IsShellSearchResultsRendererDisplayMemberNameSupported
46- => AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature. IsShellSearchResultsRendererDisplayMemberNameSupported", out bool isSupported )
45+ => AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( IsShellSearchResultsRendererDisplayMemberNameSupported ) } ", out bool isSupported )
4746 ? isSupported
4847 : IsShellSearchResultsRendererDisplayMemberNameSupportedByDefault ;
4948
5049#if NET9_0_OR_GREATER
51- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature. IsQueryPropertyAttributeSupported") ]
50+ [ FeatureSwitchDefinition ( $ " { FeatureSwitchPrefix } . { nameof ( IsQueryPropertyAttributeSupported ) } ") ]
5251 [ FeatureGuard ( typeof ( RequiresUnreferencedCodeAttribute ) ) ]
5352#endif
5453 public static bool IsQueryPropertyAttributeSupported =>
55- AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature. IsQueryPropertyAttributeSupported", out bool isSupported )
54+ AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( IsQueryPropertyAttributeSupported ) } ", out bool isSupported )
5655 ? isSupported
5756 : IsQueryPropertyAttributeSupportedByDefault ;
5857
5958#if NET9_0_OR_GREATER
60- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature. IsImplicitCastOperatorsUsageViaReflectionSupported") ]
59+ [ FeatureSwitchDefinition ( $ " { FeatureSwitchPrefix } . { nameof ( IsImplicitCastOperatorsUsageViaReflectionSupported ) } ") ]
6160 [ FeatureGuard ( typeof ( RequiresUnreferencedCodeAttribute ) ) ]
6261#endif
6362 public static bool IsImplicitCastOperatorsUsageViaReflectionSupported =>
64- AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature. IsImplicitCastOperatorsUsageViaReflectionSupported", out bool isSupported )
63+ AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( IsImplicitCastOperatorsUsageViaReflectionSupported ) } ", out bool isSupported )
6564 ? isSupported
6665 : IsImplicitCastOperatorsUsageViaReflectionSupportedByDefault ;
6766
6867#if NET9_0_OR_GREATER
69- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature.Microsoft.Maui.RuntimeFeature. AreBindingInterceptorsSupported") ]
68+ [ FeatureSwitchDefinition ( $ " { FeatureSwitchPrefix } . { nameof ( AreBindingInterceptorsSupported ) } ") ]
7069#endif
7170 public static bool AreBindingInterceptorsSupported =>
72- AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature. AreBindingInterceptorsSupported", out bool areSupported )
71+ AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( AreBindingInterceptorsSupported ) } ", out bool areSupported )
7372 ? areSupported
7473 : AreBindingInterceptorsSupportedByDefault ;
7574
7675#if NET9_0_OR_GREATER
77- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature. IsXamlCBindingWithSourceCompilationEnabled") ]
76+ [ FeatureSwitchDefinition ( $ " { FeatureSwitchPrefix } . { nameof ( IsXamlCBindingWithSourceCompilationEnabled ) } ") ]
7877#endif
7978 public static bool IsXamlCBindingWithSourceCompilationEnabled =>
80- AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature. IsXamlCBindingWithSourceCompilationEnabled", out bool areSupported )
79+ AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( IsXamlCBindingWithSourceCompilationEnabled ) } ", out bool areSupported )
8180 ? areSupported
8281 : IsXamlCBindingWithSourceCompilationEnabledByDefault ;
8382
8483#if NET9_0_OR_GREATER
85- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature. IsHybridWebViewSupported") ]
84+ [ FeatureSwitchDefinition ( $ " { FeatureSwitchPrefix } . { nameof ( IsHybridWebViewSupported ) } ") ]
8685 [ FeatureGuard ( typeof ( RequiresUnreferencedCodeAttribute ) ) ]
8786 [ FeatureGuard ( typeof ( RequiresDynamicCodeAttribute ) ) ]
8887#endif
8988 public static bool IsHybridWebViewSupported =>
90- AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature. IsHybridWebViewSupported", out bool isSupported )
89+ AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( IsHybridWebViewSupported ) } ", out bool isSupported )
9190 ? isSupported
9291 : IsHybridWebViewSupportedByDefault ;
9392
@@ -105,21 +104,29 @@ public static bool AreNamescopesSupported
105104 }
106105
107106#if NET9_0_OR_GREATER
108- [ FeatureSwitchDefinition ( "Microsoft.Maui.RuntimeFeature.EnableDiagnostics" ) ]
107+ [ FeatureSwitchDefinition ( $ "{ FeatureSwitchPrefix } .{ nameof ( EnableDiagnostics ) } ") ]
108+ #endif
109+ public static bool EnableDiagnostics => AppContext . TryGetSwitch ( $ "{ FeatureSwitchPrefix } .{ nameof ( EnableDiagnostics ) } ", out bool isEnabled )
110+ ? isEnabled
111+ : EnableDiagnosticsByDefault ;
112+
113+
114+ #if NET9_0_OR_GREATER
115+ [ FeatureSwitchDefinition ( $ "{ FeatureSwitchPrefix } .{ nameof ( EnableMauiDiagnostics ) } ") ]
109116#endif
110- public static bool EnableDiagnostics
117+ public static bool EnableMauiDiagnostics
111118 {
112119 get
113120 {
114- return AppContext . TryGetSwitch ( "Microsoft.Maui.RuntimeFeature.EnableDiagnostics ", out bool isEnabled )
121+ return AppContext . TryGetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( EnableMauiDiagnostics ) } ", out bool isEnabled )
115122 ? isEnabled
116- : EnableDiagnosticsByDefault ;
123+ : EnableDiagnostics ;
117124 }
118125 internal set
119126 {
120127 // This property is internal settable to allow tests to enable diagnostics.
121128 // It should not be set in production code.
122- AppContext . SetSwitch ( "Microsoft.Maui.RuntimeFeature.EnableDiagnostics ", value ) ;
129+ AppContext . SetSwitch ( $ " { FeatureSwitchPrefix } . { nameof ( EnableMauiDiagnostics ) } ", value ) ;
123130 }
124131 }
125132#pragma warning restore IL4000
0 commit comments