Commit 3ec6d01
.Net: Expose underlying method from kernel function (#11378)
### Motivation, Context and Description
Currently, there is no way to access the underlying method that an
instance of `KernelFunctionFromMethod` was created from or wraps. Being
able to access this underlying method is useful when additional metadata
is needed. For example, if the method has a custom attribute, you may
need to retrieve that attribute to determine the execution path.
This PR adopts the same approach as M.E.AI by exposing the native method
through the `public MethodInfo? UnderlyingMethod {...}` property. This
property is null by default and is only initialized for native functions
represented by the `KernelFunctionFromMethod` class.
Closes: #11182
---------
Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>1 parent 61c3fdc commit 3ec6d01
File tree
4 files changed
+99
-15
lines changed- dotnet
- samples/Concepts/Functions
- src
- SemanticKernel.Abstractions/Functions
- SemanticKernel.Core/Functions
- SemanticKernel.UnitTests/Functions
4 files changed
+99
-15
lines changedLines changed: 47 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | | - | |
14 | | - | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
37 | 55 | | |
38 | | - | |
| 56 | + | |
39 | 57 | | |
40 | 58 | | |
41 | 59 | | |
| |||
59 | 77 | | |
60 | 78 | | |
61 | 79 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 80 | | |
66 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
67 | 86 | | |
68 | 87 | | |
69 | 88 | | |
| |||
110 | 129 | | |
111 | 130 | | |
112 | 131 | | |
113 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
114 | 148 | | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
101 | 111 | | |
102 | 112 | | |
103 | 113 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| 185 | + | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
| |||
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
| 280 | + | |
278 | 281 | | |
279 | 282 | | |
280 | 283 | | |
| |||
307 | 310 | | |
308 | 311 | | |
309 | 312 | | |
| 313 | + | |
310 | 314 | | |
311 | 315 | | |
312 | 316 | | |
| |||
382 | 386 | | |
383 | 387 | | |
384 | 388 | | |
| 389 | + | |
385 | 390 | | |
386 | 391 | | |
387 | 392 | | |
| |||
397 | 402 | | |
398 | 403 | | |
399 | 404 | | |
| 405 | + | |
400 | 406 | | |
401 | 407 | | |
402 | 408 | | |
| |||
424 | 430 | | |
425 | 431 | | |
426 | 432 | | |
| 433 | + | |
427 | 434 | | |
428 | 435 | | |
429 | 436 | | |
430 | 437 | | |
431 | 438 | | |
432 | 439 | | |
433 | | - | |
| 440 | + | |
434 | 441 | | |
435 | 442 | | |
436 | 443 | | |
437 | 444 | | |
| 445 | + | |
438 | 446 | | |
439 | 447 | | |
440 | 448 | | |
441 | 449 | | |
442 | 450 | | |
443 | 451 | | |
444 | 452 | | |
445 | | - | |
| 453 | + | |
446 | 454 | | |
447 | 455 | | |
448 | 456 | | |
449 | 457 | | |
450 | 458 | | |
451 | 459 | | |
| 460 | + | |
452 | 461 | | |
453 | 462 | | |
454 | 463 | | |
| |||
461 | 470 | | |
462 | 471 | | |
463 | 472 | | |
| 473 | + | |
464 | 474 | | |
465 | 475 | | |
466 | 476 | | |
| 477 | + | |
467 | 478 | | |
468 | 479 | | |
469 | 480 | | |
| |||
477 | 488 | | |
478 | 489 | | |
479 | 490 | | |
| 491 | + | |
480 | 492 | | |
481 | 493 | | |
482 | 494 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
291 | 309 | | |
292 | 310 | | |
293 | 311 | | |
| |||
466 | 484 | | |
467 | 485 | | |
468 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
469 | 492 | | |
470 | 493 | | |
471 | 494 | | |
| |||
479 | 502 | | |
480 | 503 | | |
481 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
482 | 510 | | |
0 commit comments