question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LINQ in the compiler

See original GitHub issue

Not really a bug but:

https://github.com/PowerShell/PowerShell/blob/904e5511789f0a8375c23c9a1ee59918be0a82a1/src/System.Management.Automation/engine/parser/Compiler.cs#L952-L955

And the method in the select:

https://github.com/PowerShell/PowerShell/blob/904e5511789f0a8375c23c9a1ee59918be0a82a1/src/System.Management.Automation/engine/parser/Compiler.cs#L941-L950

That method is used to compile method arguments, the result is then enumerated twice (once in the first highlighted line, one is the last):

https://github.com/PowerShell/PowerShell/blob/904e5511789f0a8375c23c9a1ee59918be0a82a1/src/System.Management.Automation/engine/parser/Compiler.cs#L6338-L6344

This causes all method arguments to be compiled twice due to multiple enumeration. I’m not aware of any bugs due to this behavior, but it probably negatively impacts compile time for complicated member invocations. Also the method supplied to Select is not done in such a way that the delegate can be cached per instance by roslyn.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
daxian-dbwcommented, Aug 20, 2020

Thanks @SeeminglyScience! I submitted the PR #13491 to fix this, please take a look if you have time.

0reactions
msftbot[bot]commented, Sep 8, 2020

🎉This issue was addressed in #13491, which has now been successfully released as v7.1.0-preview.7.🎉

Handy links:

Read more comments on GitHub >

github_iconTop Results From Across the Web

LinQ - C# - OneCompiler
Write, Run & Share C# code online using OneCompiler's C# online compiler for free. It's one of the robust, feature-rich online compilers for...
Read more >
Language Integrated Query (LINQ) in C# | Microsoft Learn
Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# ...
Read more >
c# - What is LINQ Actually Compiled To?
For LINQ to Objects, this is compiled into a set of static method calls: var productNames = from p in products where p.Id...
Read more >
How is LINQ compiled?
LINQ itself isn't really compiled directly to IL. LINQ is just a wrapper around some regular .NET code. Anything you can write in...
Read more >
Code Editor
NET sandbox for developers to quickly try out code and share code snippets.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found