-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Refactor System.Net.* AppContextSwitch usage to LocalAppContextSwitches #125385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
81b74f3
3659f44
f4f3dfd
accd589
6ac0495
b88da59
2e01303
74b442c
1cd5696
f9eac54
0ada26e
2b1e9ef
9b8237f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace System | ||
| { | ||
| internal static partial class LocalAppContextSwitches | ||
| { | ||
| private static int s_disableIPv6; | ||
| internal static bool DisableIPv6 | ||
| { | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| get => GetCachedSwitchValue("System.Net.DisableIPv6", "DOTNET_SYSTEM_NET_DISABLEIPV6", ref s_disableIPv6); | ||
| } | ||
|
Comment on lines
+10
to
+15
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we're changing things, can we use a pattern more like this? public static bool DisableIPv6 { get; } = GetSwitchValue("System.Net.DisableIPv6", "DOTNET_SYSTEM_NET_DISABLEIPV6");This way the JIT can see that the value can't change, and completely remove unreachable branches when tiering up.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pattern defeats the purpose of Also, this pattern is not friendly for startup and trimming: It will read all switches eagerly, even if they are not used by the app. This startup performance hit may be acceptable for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't believe we expose a similar option for any existing networking switches currently, was your intention to start doing so now @rzikm? My preference would be to use the same approach as with our HTTP switches here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main intent was to deduplicate all the places across networking where we implemented the AppCtx query + envvar fallback, the LocalAppContextSwitches helper came up in code search and it seemed a good idea to use what the rest of the libraries are using for consistency.
|
||
|
|
||
| private static int s_enableSslKeyLogging; | ||
| internal static bool EnableSslKeyLogging | ||
| { | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| #if DEBUG | ||
| get => GetCachedSwitchValue("System.Net.EnableSslKeyLogging", ref s_enableSslKeyLogging, defaultValue: true); | ||
| #else | ||
| get => GetCachedSwitchValue("System.Net.EnableSslKeyLogging", ref s_enableSslKeyLogging); | ||
| #endif | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace System | ||
| { | ||
| internal static partial class LocalAppContextSwitches | ||
| { | ||
| private static int s_usePortInSpn; | ||
| internal static bool UsePortInSpn | ||
| { | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| get => GetCachedSwitchValue("System.Net.Http.UsePortInSpn", "DOTNET_SYSTEM_NET_HTTP_USEPORTINSPN", ref s_usePortInSpn); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace System | ||
| { | ||
| internal static partial class LocalAppContextSwitches | ||
| { | ||
| private static int s_enableKernelResponseBuffering; | ||
| internal static bool EnableKernelResponseBuffering | ||
| { | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| get => GetCachedSwitchValue("System.Net.HttpListener.EnableKernelResponseBuffering", ref s_enableKernelResponseBuffering); | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.