Skip to content

Conversation

@kacollins
Copy link
Contributor

Fixes #3834.

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Looks great! One nit, and I'm auditing the other uses of Enumerable.Empty<T> in our codebase to see if anything else looks fishy.

_loadedProjects.TryGetValue(fullPath, out List<Project> candidates);

return candidates ?? (IList<Project>)Enumerable.Empty<Project>();
return candidates ?? (IList<Project>)Array.Empty<Project>();
Copy link
Member

Choose a reason for hiding this comment

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

Can you also remove the now-unnecessary cast?

Copy link
Contributor Author

@kacollins kacollins Oct 5, 2018

Choose a reason for hiding this comment

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

No, because candidates is a List<Project>. I get this error: Operator '??' cannot be applied to operands of type 'List<Project>' and 'Project[]'

Copy link
Member

Choose a reason for hiding this comment

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

Ah, makes sense. My toy test project didn't use ??.

@rainersigwald rainersigwald changed the title Change return value for no matching projects from Enumerable to Array. Avoid casting Enumerable.Empty to IList Oct 5, 2018
@rainersigwald
Copy link
Member

The bad assumption (that Enumerable.Empty<T> is an IList<T>) went in with #3819, and was valid until dotnet/corefx#31025 changed the concrete return type.

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@AndyGerlicher AndyGerlicher left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@rainersigwald rainersigwald merged commit 900ef36 into dotnet:vs15.9 Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants