Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Code cleanup and formatting for System.Memory files. #17451

Merged
merged 9 commits into from
May 22, 2018

Conversation

ahsonkhan
Copy link

@ahsonkhan ahsonkhan commented Apr 6, 2018

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

}

// 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;
Copy link
Member

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)

Copy link
Author

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.

@@ -383,7 +383,7 @@ private void PublicationOnlyViaFactory(LazyHelper initializer)
private void PublicationOnlyWaitForOtherThreadToPublish()
{
var spinWait = new SpinWait();
while (!ReferenceEquals(_state, null))
while (!(_state is null))
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

@@ -383,7 +383,7 @@ private void PublicationOnlyViaFactory(LazyHelper initializer)
private void PublicationOnlyWaitForOtherThreadToPublish()
{
var spinWait = new SpinWait();
while (!ReferenceEquals(_state, null))
while (!(_state is null))
Copy link
Member

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?

Copy link
Author

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 !=

@ahsonkhan
Copy link
Author

@dotnet-bot test Windows_NT x64 Checked corefx_baseline
@dotnet-bot test Ubuntu x64 Checked corefx_baseline

@joshfree
Copy link
Member

joshfree commented Apr 6, 2018

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

@ahsonkhan ahsonkhan added this to the 2.2.0 milestone Apr 6, 2018
@@ -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;
Copy link

@ghost ghost Apr 6, 2018

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.

@ahsonkhan ahsonkhan added the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Apr 11, 2018
@ahsonkhan ahsonkhan removed the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label May 21, 2018
@ahsonkhan ahsonkhan merged commit f31097f into dotnet:master May 22, 2018
@ahsonkhan ahsonkhan deleted the CodeCleanup branch May 22, 2018 01:04
dotnet-bot pushed a commit to dotnet/corert that referenced this pull request May 22, 2018
…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>
dotnet-bot pushed a commit to dotnet/corefx that referenced this pull request May 22, 2018
…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>
jkotas pushed a commit to dotnet/corert that referenced this pull request May 22, 2018
…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>
jkotas pushed a commit to dotnet/corefx that referenced this pull request May 22, 2018
…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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants