Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Feature suggestion: replace new List<T>() with Enumerable.Empty<T>() where appropriate #58

Open
udlose opened this issue Oct 25, 2018 · 7 comments

Comments

@udlose
Copy link

udlose commented Oct 25, 2018

There are times I find myself returning an empty List<T> to satisfy the .Net Framework Design Guileine for return values representing a collection of some sort - https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/guidelines-for-collections

Unfortunately, this creates an allocation that must be collected. Using Enumerable.Empty<T>() when only an IEnumerable<T> is required will save an allocation since it is a Singleton and makes no allocation.

It would be helpful to have a warning from this extension as a reminder to use the Enumerable.Empty<T>() Singleton.

mjsabby pushed a commit that referenced this issue Jan 16, 2020
…lection required (#80)

* #58: Add CodeFix replacing empty collections with Enumerable.Empty<T>

* #58: Replace method parameters with Enumerable.Empty

* #58: Replace Enumerable.Empty with Array.Empty to cover more use cases
@udlose
Copy link
Author

udlose commented Jan 24, 2020

@mjsabby - any idea when a new update will be released including this fix from @cezarypiatek ?

@mjsabby
Copy link
Contributor

mjsabby commented Feb 3, 2020

The VS extension has been updated. So has the nuget package. Please open issues if you see a problem. Thanks.

@udlose
Copy link
Author

udlose commented Feb 7, 2020

@mjsabby has the update been published? I see commits as of 5 days ago but the last published Release is on 5/16/19

@udlose
Copy link
Author

udlose commented Feb 10, 2020

@mjsabby - thanks I see the updated Release and the new .vsix is posted there. Just so you know, only the 2.0 version is showing up in the VisualStudio Extension Manager.

@cezarypiatek
Copy link
Contributor

This might be caused by the discrepancy of PackageId between Marketplace and source.extension.vsixmanifest

@udlose
Copy link
Author

udlose commented Feb 10, 2020

The .vsix downloaded from the latest release (3.0) still is listed as 2.0 after I uninstalled the old one and installed the one downloaded from the latest release. Maybe the version wasn't updated in the VS extension?

@mjsabby
Copy link
Contributor

mjsabby commented Mar 3, 2020

@udlose It was. I may have kept it as 2.0 when uploading :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants