Skip to content

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Nov 1, 2020

@ghost ghost assigned adityapatwardhan Nov 1, 2020
if (times == 0 || array.Length == 0)
{
return new T[0]; // don't use Utils.EmptyArray, always return a new array
return Array.Empty<T>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iSazonov Perhaps we should suppress CA1825 here, if there is still a rationale for always returning a new array instance. Utils.EmptyArray was removed in your PR #9042.

Copy link
Collaborator

@iSazonov iSazonov Nov 2, 2020

Choose a reason for hiding this comment

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

Yes, please revert and suppress. We could update only the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will revert and suppress, but I was wondering what reason we do not to use the static empty array?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't remember. Perhaps it is used in comparisons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PaulHigin Must we always return a new instance, rather then using the static empty array?

public object Data { get; set; }

internal static readonly RuntimeDefinedParameter[] EmptyParameterArray = new RuntimeDefinedParameter[0];
internal static readonly RuntimeDefinedParameter[] EmptyParameterArray = Array.Empty<RuntimeDefinedParameter>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps we can inline EmptyParameterArray ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not in the PR.

@xtqqczze xtqqczze marked this pull request as ready for review November 2, 2020 00:52
@xtqqczze xtqqczze requested a review from anmenaga as a code owner November 2, 2020 00:52
@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Nov 2, 2020
@iSazonov iSazonov requested a review from PaulHigin November 2, 2020 11:58
@iSazonov iSazonov merged commit 1d7a93c into PowerShell:master Nov 4, 2020
@iSazonov iSazonov added this to the 7.2.0-preview.1 milestone Nov 4, 2020
@xtqqczze xtqqczze deleted the CA1825 branch November 5, 2020 16:59
@ghost
Copy link

ghost commented Nov 17, 2020

🎉v7.2.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants