-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Remove ~20 explicit static cctors across corefx #6016
Conversation
@kkurni Please take a look at the data changes. |
|
||
static WinHttpTraceHelper() | ||
private static bool ReadTracingEnabled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ReadTracingEnabled" seems confusing for this method name. Why use the "Read" in the name? Why not somethng like "IsTracingEnabled"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the next method in this type is named IsTraceEnabled()
😉 I'm happy to rename this to whatever you'd prefer...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "TracingEnabledHelper"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will rename.
LGTM for System.Data.* |
cc: @CIPop Left a comment but otherwise LGTM for networking. |
LGTM for serialization. |
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. |
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
Remove ~20 explicit static cctors across corefx
Fixes dotnet#6016. Resolves dotnet#6015. Signed-off-by: dotnet-bot <[email protected]>
Fixes #6016. Resolves #6015. Signed-off-by: dotnet-bot <[email protected]>
Remove ~20 explicit static cctors across corefx Commit migrated from dotnet/corefx@11efc0d
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