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

Code Cleanup#26363

Closed
ghost wants to merge 26 commits into
masterfrom
unknown repository
Closed

Code Cleanup#26363
ghost wants to merge 26 commits into
masterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 25, 2019

All refactorings and code fixes were done by the IDE.

@jkotas jkotas requested a review from stephentoub August 26, 2019 12:22
culture: null);

return result != null ? (int)result : 0;
return (int?) result ?? 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not the same; the latter produces IL that involves nullable. Please revert this and all similar changes.


IEqualityComparer<TKey>? comparer = _comparer;
uint hashCode = (uint)((comparer == null) ? key.GetHashCode() : comparer.GetHashCode(key));
uint hashCode = (uint)(comparer?.GetHashCode(key) ?? key.GetHashCode());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is an improvement. The previous code was easy to understand: if comparer is null, do one thing, otherwise do something else. This takes longer to visually parse and understand. Please revert this.

}
} // class Convert
} // namespace
} // namespace No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this file.

m_creator = creator;
m_uniqueId = uniqueId;
m_level = creator != null ? creator.m_level + 1 : 0;
m_level = creator?.m_level + 1 ?? 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hard to understand. Please revert.

{
ManifestBuilder? manifest = null;
bool bNeedsManifest = source != null ? !source.SelfDescribingEvents : true;
bool bNeedsManifest = !source?.SelfDescribingEvents ?? true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is harder to understand. Please revert.

public void AddBinary(string? value)
{
DataCollector.ThreadInstance.AddBinary(value, value == null ? 0 : value.Length * 2);
DataCollector.ThreadInstance.AddBinary(value, value?.Length * 2 ?? 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is harder to understand. Please revert.

return Compare(string1, offset1, string1 == null ? 0 : string1.Length - offset1,
string2, offset2, string2 == null ? 0 : string2.Length - offset2, options);
return Compare(string1, offset1, string1?.Length - offset1 ?? 0,
string2, offset2, string2?.Length - offset2 ?? 0, options);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are harder to understand. Please revert.

public void Add<T>(T value, IEqualityComparer<T>? comparer)
{
Add(comparer != null ? comparer.GetHashCode(value) : (value?.GetHashCode() ?? 0));
Add(comparer?.GetHashCode(value) ?? (value?.GetHashCode() ?? 0));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is harder to understand. Please revert.

else
{
char ch = builder[builder.Length - 1];
char ch = builder[^1];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all use of ^1 in this file. This file ends up getting compiled into some downlevel assemblies that do not have access to Index.

else
{
if (!PathInternal.IsDirectorySeparator(builder[builder.Length - 1]) && !PathInternal.IsDirectorySeparator(path[0]))
if (!(PathInternal.IsDirectorySeparator(builder[^1]) || PathInternal.IsDirectorySeparator(path[0])))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this.

{
uint result = Interop.Kernel32.GetLongPathNameW(
ref inputBuilder.GetPinnableReference(terminate: true), ref outputBuilder.GetPinnableReference(), (uint)outputBuilder.Capacity);
ref inputBuilder.GetPinnableReference(terminate: true), ref outputBuilder.GetPinnableReference(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this?

return false;

char c = path[path.Length - 1];
char c = path[^1];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this file. Same reason as earlier.

if (!hasValue) return other == null;
if (other == null) return false;
return value.Equals(other);
return !hasValue ? other == null : other != null && value.Equals(other);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is harder to understand. Please revert this.

return source != null ?
source.InternalRegister(callback, state, useSynchronizationContext ? SynchronizationContext.Current : null, useExecutionContext ? ExecutionContext.Capture() : null) :
default; // Nothing to do for tokens than can never reach the canceled state. Give back a dummy registration.
return source?.InternalRegister(callback, state, useSynchronizationContext ? SynchronizationContext.Current : null, useExecutionContext ? ExecutionContext.Capture() : null) ?? default; // Nothing to do for tokens than can never reach the canceled state. Give back a dummy registration.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the default and everything after it back on its own line. This new formatting creates an incredibly long line.

Comment thread src/tools/GCLogParser/parse-hb-log.cs
int len = threadsToPrint.Count;
Console.WriteLine("getting info for {0} threads", len);
for (int i = 0; i < len; i++)
foreach (var t in threadsToPrint)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var => whatever type this actually is

pi1024e added 8 commits August 26, 2019 13:13
@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 26, 2019

I see the issue; I am not using the version of C# this program is meant to be in. I am going to undo my changes and redo them

pi1024e added 2 commits August 26, 2019 13:19
This reverts commit add7e53.
This reverts commit a1f19e5.
@ghost ghost closed this Aug 26, 2019
@ghost ghost reopened this Aug 26, 2019
Anipik and others added 2 commits August 26, 2019 13:27
* adding ci legs to release 3.1 branch

* removing regex and adding branches as regex was not working

Remove unnecessary !s for [DoesNotReturn] (#26350)

Remove unused test file introduced in #25948 (#26349)

Fix BinaryReader.ReadChars for fragmented Streams (#26324)

BinaryReader.ReadChars incorrectly read more than necessary from the underlying Stream when multi-byte characters straddled the read chunks.

Fixes https://github.com/dotnet/corefx/issues/40455

Update ReadOnlyDictionary.cs

Simplify null checks

Update parse-hb-log.cs

Update Nullable.cs

Optimizations

Use Expression

Update

Update PathHelper.Windows.cs

Fix convert

Update Nullable.cs

Update StackFrameHelper.cs

Revert "Merge branch 'null-check' of https://github.com/pi1024e/coreclr into null-check"

This reverts commit 67cef41, reversing
changes made to deda7bb.

Revert "Update PathHelper.Windows.cs"

This reverts commit deda7bb.

Revert "Update"

This reverts commit add7e53.

Revert "Use Expression"

This reverts commit 96d11b4.

Revert "Revert "Use Expression""

This reverts commit e710c78.

Revert "Revert "Revert "Use Expression"""

This reverts commit d12cef3.

Revert "Simplify null checks"

This reverts commit df97df7.

Revert "Update ReadOnlyDictionary.cs"

This reverts commit b09e08e.

Revert "Update"

This reverts commit add7e53.

Revert "Optimizations"

This reverts commit a1f19e5.

Update objectnative.cpp
@ghost ghost closed this Aug 26, 2019
@ghost ghost deleted the null-check branch August 26, 2019 17:31
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants