KEMBAR78
Return `Array.Empty` instead of collection `[]` by ArmaanMcleod · Pull Request #25137 · PowerShell/PowerShell · GitHub
Skip to content

Conversation

@ArmaanMcleod
Copy link
Contributor

@ArmaanMcleod ArmaanMcleod commented Mar 7, 2025

PR Summary

Return Array.Empty instead of collection [].

Missed this in #25126 (comment)

PR Context

PR Checklist

@ArmaanMcleod
Copy link
Contributor Author

@iSazonov do you have issues with VSCode and editorconfig not using rules? I still get recommendation to use [] for this code.

@iSazonov
Copy link
Collaborator

iSazonov commented Mar 7, 2025

@ArmaanMcleod I played with the option, and it works for me in VS Code. Maybe you need restart? Or not
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0301 rule but the
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0300 rule works for you?

Learn about code analysis rule IDE0301: Use collection expression for empty
Learn about code analysis rule IDE0300: Use collection expression

@ArmaanMcleod ArmaanMcleod changed the title Return Enumerable.Empty instead of collection [] Return Array.Empty instead of collection [] Mar 7, 2025
@ArmaanMcleod
Copy link
Contributor Author

ArmaanMcleod commented Mar 7, 2025

@ArmaanMcleod I played with the option, and it works for me in VS Code. Maybe you need restart? Or not https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0301 rule but the https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0300 rule works for you?

**IDE0301: Use collection expression for empty - .NET**Learn about code analysis rule IDE0301: Use collection expression for empty

**IDE0300: Use collection expression for array - .NET**Learn about code analysis rule IDE0300: Use collection expression

Thanks @iSazonov. I will play around with it, maybe need to reinstall extension.

Learn about code analysis rule IDE0301: Use collection expression for empty
Learn about code analysis rule IDE0300: Use collection expression

@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Mar 7, 2025
@iSazonov iSazonov self-assigned this Mar 7, 2025
@iSazonov iSazonov merged commit 210ca83 into PowerShell:master Mar 7, 2025
39 of 41 checks passed
@microsoft-github-policy-service
Copy link
Contributor

microsoft-github-policy-service bot commented Mar 7, 2025

📣 Hey @ArmaanMcleod, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

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.

2 participants