This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Emit delegate object array thunks - #2911
Merged
MichalStrehovsky merged 1 commit intoMar 8, 2017
Merged
MichalStrehovsky merged 1 commit into
MichalStrehovsky merged 1 commit into
Conversation
This is a special kind of thunks used to invoke delegates created by the LINQ expression interpreter.
Member
Author
|
Tested with the code below, but I can't check that in because our FX packaging story is still incomplete. (Can't reference System.Linq.Expressions.) using System;
using System.Linq.Expressions;
internal class Program
{
private static void SayHello()
{
Console.WriteLine("Hello");
}
private static void SayHelloName(string name)
{
Console.WriteLine("Hello " + name);
}
private static string GetHello()
{
return "Hello";
}
private static string GetHelloName(string name)
{
return "Hello " + name;
}
private static void Main(string[] args)
{
new Program();
{
Action a = SayHello;
Action b = a.Invoke;
Expression<Action> h = () => SayHello();
h.Compile()();
}
{
Action<string> a = SayHelloName;
Action<string> b = a.Invoke;
Expression<Action<string>> h = (string name) => SayHelloName(name);
h.Compile()("Michal");
}
{
Func<string> a = GetHello;
Func<string> b = a.Invoke;
Expression<Func<string>> h = () => GetHello();
Console.WriteLine(h.Compile()());
}
{
Func<string, string> a = GetHelloName;
Func<string, string> b = a.Invoke;
Expression<Func<string, string>> h = (string name) => GetHelloName(name);
Console.WriteLine(h.Compile()("Michal"));
}
}
} |
Member
Author
|
@davidwrighton PTAL |
davidwrighton
approved these changes
Mar 8, 2017
davidwrighton
left a comment
Member
There was a problem hiding this comment.
Looks good. The empty array optimization should be a nice moderate improvement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a special kind of thunks used to invoke delegates created by the
LINQ expression interpreter.
This is mostly a port from the Project N IL2IL toolchain, but I added the empty
array optimization because it's silly to allocate empty arrays.