-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Code cleanup and formatting for System.Memory files. #17451
Conversation
} | ||
|
||
// After this point, the referenced module is not the same as the referencing | ||
// module. | ||
// | ||
ModuleBuilder refedModuleBuilder = refedModule as ModuleBuilder; | ||
|
||
String strRefedModuleFileName = String.Empty; | ||
String strRefedModuleFileName = string.Empty; |
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.
This file used String
consistently before this change. It is using mix of string
and String
now. It does not look like an improvement.
(multiple places - not commenting on all of them)
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.
It looks like VS didn't catch all instances. Will fix.
src/mscorlib/shared/System/Lazy.cs
Outdated
@@ -383,7 +383,7 @@ private void PublicationOnlyViaFactory(LazyHelper initializer) | |||
private void PublicationOnlyWaitForOtherThreadToPublish() | |||
{ | |||
var spinWait = new SpinWait(); | |||
while (!ReferenceEquals(_state, null)) | |||
while (!(_state is null)) |
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.
The other places that check _state
are still using ReferenceEquals. Using is
here while keeping the rest on the ReferenceEquals plan does not look like an improvement.
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.
For comparing an object to a non-null object, is there any benefit of using ReferenceEquals over ==
? If not, I can change the other calls as well.
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.
==
may use overriden operator Equals if there is one.
ReferenceEquals
is explicit about your intent: that you want to compare references, and not use any overridden operators.
src/mscorlib/shared/System/Lazy.cs
Outdated
@@ -383,7 +383,7 @@ private void PublicationOnlyViaFactory(LazyHelper initializer) | |||
private void PublicationOnlyWaitForOtherThreadToPublish() | |||
{ | |||
var spinWait = new SpinWait(); | |||
while (!ReferenceEquals(_state, null)) | |||
while (!(_state is null)) |
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.
Why is this not != null
like the other place?
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.
VS defaulted to this as part of the "Null check can be simplified" fix. I will update to use !=
@dotnet-bot test Windows_NT x64 Checked corefx_baseline |
As this change isn't required to ship 2.1 RC, please hold off on merging this until the master branch opens for 2.2 PRs later this month |
src/mscorlib/shared/System/Memory.cs
Outdated
@@ -6,8 +6,7 @@ | |||
using System.Diagnostics; | |||
using System.Runtime.CompilerServices; | |||
using System.Runtime.InteropServices; | |||
using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; | |||
using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; | |||
using System.ComponentModel; |
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.
I preferred it the original way. System.ComponentModel
is not an obvious namespace to import into a file like Memory.cs
- spelling out the types makes it clear why we're importing it.
…17451) * Fix IDE0034 C# expression can be simplified (use of default) * Remove unnecessary using statements * IDE0012 C# Name can be simplified. String -> string * IDE0041 C# Null check can be simplified * Fix code formatting (limited to Span/System.Memory files). * Address PR feedback - IDE0012 Name can be simplified (String -> string) * Add back the necessary using statements and fix typo * Fix comment typo and add necessary using statements Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
…17451) * Fix IDE0034 C# expression can be simplified (use of default) * Remove unnecessary using statements * IDE0012 C# Name can be simplified. String -> string * IDE0041 C# Null check can be simplified * Fix code formatting (limited to Span/System.Memory files). * Address PR feedback - IDE0012 Name can be simplified (String -> string) * Add back the necessary using statements and fix typo * Fix comment typo and add necessary using statements Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
…17451) * Fix IDE0034 C# expression can be simplified (use of default) * Remove unnecessary using statements * IDE0012 C# Name can be simplified. String -> string * IDE0041 C# Null check can be simplified * Fix code formatting (limited to Span/System.Memory files). * Address PR feedback - IDE0012 Name can be simplified (String -> string) * Add back the necessary using statements and fix typo * Fix comment typo and add necessary using statements Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
…17451) * Fix IDE0034 C# expression can be simplified (use of default) * Remove unnecessary using statements * IDE0012 C# Name can be simplified. String -> string * IDE0041 C# Null check can be simplified * Fix code formatting (limited to Span/System.Memory files). * Address PR feedback - IDE0012 Name can be simplified (String -> string) * Add back the necessary using statements and fix typo * Fix comment typo and add necessary using statements Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
I tried to limit the changes mainly to files shared between coreclr/corefx relevant to System.Memory.
Each set of changes is a separate commit.
The IDE00XX errors were fixed by VS, so all instances of the errors within the solution got fixed.
Related PR on the corefx side: dotnet/corefx#28875
cc @dotnet/corefxlab-contrib, @stephentoub, @jkotas
This should get mirrored - cc @Anipik, @safern