Skip to content

Commit

Permalink
Use generated generic Linker.DefineFunction() and `Function.FromCal…
Browse files Browse the repository at this point in the history
…lback()` overloads for efficiently invoking callbacks (#163)

* Use a T4 text template to generate overloads of generic Linker.DefineFunction() methods that can efficiently call the specified callback without reflection.

* Simplify.

* Follow-Up: Also implement the generic overload generation for Function.FromCallback().

* Follow-Up: Returning a ValueTuple<> with more than 4 type arguments requires to use the overload taking a Delegate.

* Add more tests.

* Follow-Up: Fall back to using reflection instead of throwing an exception when the parameter/result type combination cannot be represented with the current generic parameters.

* Add more tests including one for a custom callback delegate.

* Directly specify the delegate parameter and return types, so that it's not necessary to use reflection to find the delegate's Invoke() method.

* Update for changes in #172.

* PR feedback: Extract duplicated code into a separate .t4 file that can be included in the .tt files.

* PR feedback: Use a bool value for hasCaller.

* PR feedback: Use a local tool manifest file for the dotnet-t4 tool, and invoke it automatically when building the project.

* Follow-Up: Run "dotnet tool restore" to automatically make the tool available.

* We no longer need to specify the -o flag since mono/t4#142 has been fixed in version 2.3.1.
  • Loading branch information
kpreisser authored Nov 11, 2022
1 parent fe87f2f commit cc1179f
Show file tree
Hide file tree
Showing 13 changed files with 24,350 additions and 960 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-t4": {
"version": "2.3.1",
"commands": [
"t4"
]
}
}
}
Loading

0 comments on commit cc1179f

Please sign in to comment.