This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Remove ~20 explicit static cctors across corefx#6016
Merged
stephentoub merged 1 commit intodotnet:masterfrom Feb 11, 2016
Merged
Remove ~20 explicit static cctors across corefx#6016stephentoub merged 1 commit intodotnet:masterfrom
stephentoub merged 1 commit intodotnet:masterfrom
Conversation
Contributor
|
@kkurni Please take a look at the data changes. |
| private static readonly bool s_TraceEnabled = ReadTracingEnabled(); | ||
|
|
||
| static WinHttpTraceHelper() | ||
| private static bool ReadTracingEnabled() |
Contributor
There was a problem hiding this comment.
"ReadTracingEnabled" seems confusing for this method name. Why use the "Read" in the name? Why not somethng like "IsTracingEnabled"?
Member
Author
There was a problem hiding this comment.
Because the next method in this type is named IsTraceEnabled() 😉 I'm happy to rename this to whatever you'd prefer...
Contributor
There was a problem hiding this comment.
How about "TracingEnabledHelper"?
Contributor
|
LGTM for System.Data.* |
Contributor
|
cc: @CIPop Left a comment but otherwise LGTM for networking. |
Member
|
LGTM for serialization. |
Member
|
I have a general pondering of why some of these didn't move to assignment-with-collection-initializers instead of separate methods. But LGTM anyways. |
Member
Author
|
Thanks, all. |
41955b7 to
901825f
Compare
Explicit static cctors cause the C# compiler to not mark types as beforefieldinit, which in turn means that the backend compiler needs to add checks to static methods to ensure that the type has been initialized. We have a bunch of such cctors across corefx that can be easily removed; this commit does so. In a few places, it also presizes some collections to help avoid unnecessary memory pressure.
901825f to
79ae21b
Compare
stephentoub
added a commit
that referenced
this pull request
Feb 11, 2016
Remove ~20 explicit static cctors across corefx
dotnet-maestro-bot
pushed a commit
to dotnet-maestro-bot/corefx
that referenced
this pull request
Jun 26, 2018
Fixes dotnet#6016. Resolves dotnet#6015. Signed-off-by: dotnet-bot <[email protected]>
stephentoub
pushed a commit
that referenced
this pull request
Jun 27, 2018
Fixes #6016. Resolves #6015. Signed-off-by: dotnet-bot <[email protected]>
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
Remove ~20 explicit static cctors across corefx Commit migrated from dotnet/corefx@11efc0d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explicit static cctors cause the C# compiler to not mark types as beforefieldinit, which in turn means that the backend compiler needs to add checks to static methods to ensure that the type has been initialized. We have a bunch of such cctors across corefx that can be easily removed; this commit does so. (See https://msdn.microsoft.com/en-us/library/ms182275.aspx for some background.)
The changes are all minor and basically boil down to converting the static cctor to one or more static methods which are then just called in the field initializer(s).
cc:
@davidsh for networking
@saurabh500 for data
@bartonjs for security
@khdang for serialization/xml
@jkotas