Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Remove usage of LINQ from the metadata writer - #1095

Merged
MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:noLinq
Apr 6, 2016
Merged

MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:noLinq

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

LINQ Select operator uses generic virtual methods, which is both an
overkill, and prevents us from selfhosting the compiler.

Replacing all of LINQ with a lighter weight implementation for good
measure.

@@ -0,0 +1,74 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

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.

Should this live under common like all other LowLevel*.cs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Then I would need to invent a neutrally sounding namespace for it, which I wanted to avoid. If you have suggestions, I'll gladly move it.

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.

There is actually a similar light-weight linq implementation at src\Common\src\System\Linq\LowLevelEnumerable.cs that it would be nice to unify this with. Partial class split into a few .cs files, e.g. AsList method should be separate to avoid introducing bad dependencies.

The naming convention for LowLevel* has been to use the same namespace as the full blown counterpart, but I guess that it does not work well here because of you get a reference to System.Linq.dll via standard library. We would need to find a way to remove the reference to System.Linq.dll to avoid ambiguity - likely go back to explicit list of references.

Or if unique namespace is better - I would call it System.LowLevelLinq to make it follow the naming convention.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

@jkotas I ended up moving it to Internal.LowLevelLinq because it looks better than System.LowLevelLinq - the System prefix really only works for namespaces that have a counterpart in the public surface area.

It's in a separate commit, so I can undo it if needed, but I think it makes more sense.

Keeping it in the System.Linq namespace would always have the danger of picking up the wrong implementation if references change. It's better to be explicit about it.

@jkotas

jkotas commented Apr 6, 2016

Copy link
Copy Markdown
Member

👍

LINQ Select operator uses generic virtual methods, which is both an
overkill, and prevents us from selfhosting the compiler.

Replacing all of LINQ with a lighter weight implementation for good
measure.
@MichalStrehovsky
MichalStrehovsky merged commit 4cbecd2 into dotnet:master Apr 6, 2016
@MichalStrehovsky
MichalStrehovsky deleted the noLinq branch April 6, 2016 19:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants