├── .gitignore
├── LICENSE
├── README.md
├── distrib
├── Application Files
│ ├── CallSharp_0_1_0_3
│ │ ├── CallSharp.application
│ │ ├── CallSharp.exe.config.deploy
│ │ ├── CallSharp.exe.deploy
│ │ ├── CallSharp.exe.manifest
│ │ └── JetBrains.Annotations.dll.deploy
│ ├── CallSharp_0_1_1_4
│ │ ├── CallSharp.application
│ │ ├── CallSharp.exe.config.deploy
│ │ ├── CallSharp.exe.deploy
│ │ ├── CallSharp.exe.manifest
│ │ └── JetBrains.Annotations.dll.deploy
│ ├── CallSharp_0_1_1_5
│ │ ├── CallSharp.application
│ │ ├── CallSharp.exe.config.deploy
│ │ ├── CallSharp.exe.deploy
│ │ ├── CallSharp.exe.manifest
│ │ └── JetBrains.Annotations.dll.deploy
│ ├── CallSharp_0_1_1_6
│ │ ├── CallSharp.application
│ │ ├── CallSharp.exe.config.deploy
│ │ ├── CallSharp.exe.deploy
│ │ ├── CallSharp.exe.manifest
│ │ └── JetBrains.Annotations.dll.deploy
│ ├── CallSharp_0_1_1_7
│ │ ├── CallSharp.application
│ │ ├── CallSharp.exe.config.deploy
│ │ ├── CallSharp.exe.deploy
│ │ ├── CallSharp.exe.manifest
│ │ └── JetBrains.Annotations.dll.deploy
│ ├── CallSharp_0_1_1_8
│ │ ├── CallSharp.application
│ │ ├── CallSharp.exe.config.deploy
│ │ ├── CallSharp.exe.deploy
│ │ ├── CallSharp.exe.manifest
│ │ ├── Db
│ │ │ └── StaticMemberDatabase.tt.deploy
│ │ └── JetBrains.Annotations.dll.deploy
│ └── CallSharp_0_2_0_0
│ │ ├── CallSharp.application
│ │ ├── CallSharp.exe.config.deploy
│ │ ├── CallSharp.exe.deploy
│ │ ├── CallSharp.exe.manifest
│ │ ├── Db
│ │ └── StaticMemberDatabase.tt.deploy
│ │ └── JetBrains.Annotations.dll.deploy
├── CallSharp.application
└── setup.exe
├── site
└── screenshot.png
└── src
├── CallSharp.sln
├── CallSharp
├── App.config
├── App.xaml
├── App.xaml.cs
├── CallSharp.csproj
├── CallSharp.csproj.DotSettings
├── Class1.cs
├── Cuda.cs
├── Db
│ ├── DynamicMemberDatabase.cs
│ ├── IMemberDatabase.cs
│ ├── StaticMemberDatabase.cs
│ └── StaticMemberDatabase.tt
├── Empty.cs
├── EnumerableExtensions.cs
├── ExtensionMethods.cs
├── Fragmentation
│ ├── FragmentationEngine.cs
│ ├── IFragmentationEngine.cs
│ └── NullFragmentationEngine.cs
├── MagicTextBox.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MethodCallCookie.cs
├── ObservableHashSet.cs
├── PermuteUtils.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── ScaleToWindowSizeBehavior.cs
├── TypeDatabase.cs
├── TypeToStringConverter.cs
└── packages.config
└── Tests
├── BasicMatchTests.cs
├── Categories.cs
├── FragTests.cs
├── OtherTests.cs
├── Properties
└── AssemblyInfo.cs
├── Tests.csproj
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/csharp,visualstudio
3 |
4 | ### Csharp ###
5 | ## Ignore Visual Studio temporary files, build results, and
6 | ## files generated by popular Visual Studio add-ons.
7 |
8 | # User-specific files
9 | *.suo
10 | *.user
11 | *.userosscache
12 | *.sln.docstates
13 |
14 | # User-specific files (MonoDevelop/Xamarin Studio)
15 | *.userprefs
16 |
17 | # Build results
18 | [Dd]ebug/
19 | [Dd]ebugPublic/
20 | [Rr]elease/
21 | [Rr]eleases/
22 | x64/
23 | x86/
24 | bld/
25 | [Bb]in/
26 | [Oo]bj/
27 | [Ll]og/
28 |
29 | # Visual Studio 2015 cache/options directory
30 | .vs/
31 | # Uncomment if you have tasks that create the project's static files in wwwroot
32 | #wwwroot/
33 |
34 | # MSTest test Results
35 | [Tt]est[Rr]esult*/
36 | [Bb]uild[Ll]og.*
37 |
38 | # NUNIT
39 | *.VisualState.xml
40 | TestResult.xml
41 |
42 | # Build Results of an ATL Project
43 | [Dd]ebugPS/
44 | [Rr]eleasePS/
45 | dlldata.c
46 |
47 | # DNX
48 | project.lock.json
49 | project.fragment.lock.json
50 | artifacts/
51 |
52 | *_i.c
53 | *_p.c
54 | *_i.h
55 | *.ilk
56 | *.meta
57 | *.obj
58 | *.pch
59 | *.pdb
60 | *.pgc
61 | *.pgd
62 | *.rsp
63 | *.sbr
64 | *.tlb
65 | *.tli
66 | *.tlh
67 | *.tmp
68 | *.tmp_proj
69 | *.log
70 | *.vspscc
71 | *.vssscc
72 | .builds
73 | *.pidb
74 | *.svclog
75 | *.scc
76 |
77 | # Chutzpah Test files
78 | _Chutzpah*
79 |
80 | # Visual C++ cache files
81 | ipch/
82 | *.aps
83 | *.ncb
84 | *.opendb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 | *.VC.db
89 | *.VC.VC.opendb
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 | *.sap
96 |
97 | # TFS 2012 Local Workspace
98 | $tf/
99 |
100 | # Guidance Automation Toolkit
101 | *.gpState
102 |
103 | # ReSharper is a .NET coding add-in
104 | _ReSharper*/
105 | *.[Rr]e[Ss]harper
106 | *.DotSettings.user
107 |
108 | # JustCode is a .NET coding add-in
109 | .JustCode
110 |
111 | # TeamCity is a build add-in
112 | _TeamCity*
113 |
114 | # DotCover is a Code Coverage Tool
115 | *.dotCover
116 |
117 | # Visual Studio code coverage results
118 | *.coverage
119 | *.coveragexml
120 |
121 | # NCrunch
122 | _NCrunch_*
123 | .*crunch*.local.xml
124 | nCrunchTemp_*
125 |
126 | # MightyMoose
127 | *.mm.*
128 | AutoTest.Net/
129 |
130 | # Web workbench (sass)
131 | .sass-cache/
132 |
133 | # Installshield output folder
134 | [Ee]xpress/
135 |
136 | # DocProject is a documentation generator add-in
137 | DocProject/buildhelp/
138 | DocProject/Help/*.HxT
139 | DocProject/Help/*.HxC
140 | DocProject/Help/*.hhc
141 | DocProject/Help/*.hhk
142 | DocProject/Help/*.hhp
143 | DocProject/Help/Html2
144 | DocProject/Help/html
145 |
146 | # Click-Once directory
147 | publish/
148 |
149 | # Publish Web Output
150 | *.[Pp]ublish.xml
151 | *.azurePubxml
152 | # TODO: Comment the next line if you want to checkin your web deploy settings
153 | # but database connection strings (with potential passwords) will be unencrypted
154 | *.pubxml
155 | *.publishproj
156 |
157 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
158 | # checkin your Azure Web App publish settings, but sensitive information contained
159 | # in these scripts will be unencrypted
160 | PublishScripts/
161 |
162 | # NuGet Packages
163 | *.nupkg
164 | # The packages folder can be ignored because of Package Restore
165 | **/packages/*
166 | # except build/, which is used as an MSBuild target.
167 | !**/packages/build/
168 | # Uncomment if necessary however generally it will be regenerated when needed
169 | #!**/packages/repositories.config
170 | # NuGet v3's project.json files produces more ignoreable files
171 | *.nuget.props
172 | *.nuget.targets
173 |
174 | # Microsoft Azure Build Output
175 | csx/
176 | *.build.csdef
177 |
178 | # Microsoft Azure Emulator
179 | ecf/
180 | rcf/
181 |
182 | # Windows Store app package directories and files
183 | AppPackages/
184 | BundleArtifacts/
185 | Package.StoreAssociation.xml
186 | _pkginfo.txt
187 |
188 | # Visual Studio cache files
189 | # files ending in .cache can be ignored
190 | *.[Cc]ache
191 | # but keep track of directories ending in .cache
192 | !*.[Cc]ache/
193 |
194 | # Others
195 | ClientBin/
196 | ~$*
197 | *~
198 | *.dbmdl
199 | *.dbproj.schemaview
200 | *.jfm
201 | *.pfx
202 | *.publishsettings
203 | node_modules/
204 | orleans.codegen.cs
205 |
206 | # Since there are multiple workflows, uncomment next line to ignore bower_components
207 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
208 | #bower_components/
209 |
210 | # RIA/Silverlight projects
211 | Generated_Code/
212 |
213 | # Backup & report files from converting an old project file
214 | # to a newer Visual Studio version. Backup files are not needed,
215 | # because we have git ;-)
216 | _UpgradeReport_Files/
217 | Backup*/
218 | UpgradeLog*.XML
219 | UpgradeLog*.htm
220 |
221 | # SQL Server files
222 | *.mdf
223 | *.ldf
224 |
225 | # Business Intelligence projects
226 | *.rdl.data
227 | *.bim.layout
228 | *.bim_*.settings
229 |
230 | # Microsoft Fakes
231 | FakesAssemblies/
232 |
233 | # GhostDoc plugin setting file
234 | *.GhostDoc.xml
235 |
236 | # Node.js Tools for Visual Studio
237 | .ntvs_analysis.dat
238 |
239 | # Visual Studio 6 build log
240 | *.plg
241 |
242 | # Visual Studio 6 workspace options file
243 | *.opt
244 |
245 | # Visual Studio LightSwitch build output
246 | **/*.HTMLClient/GeneratedArtifacts
247 | **/*.DesktopClient/GeneratedArtifacts
248 | **/*.DesktopClient/ModelManifest.xml
249 | **/*.Server/GeneratedArtifacts
250 | **/*.Server/ModelManifest.xml
251 | _Pvt_Extensions
252 |
253 | # Paket dependency manager
254 | .paket/paket.exe
255 | paket-files/
256 |
257 | # FAKE - F# Make
258 | .fake/
259 |
260 | # JetBrains Rider
261 | .idea/
262 | *.sln.iml
263 |
264 | # CodeRush
265 | .cr/
266 |
267 | # Python Tools for Visual Studio (PTVS)
268 | __pycache__/
269 | *.pyc
270 |
271 | # Cake - Uncomment if you are using it
272 | # tools/
273 |
274 |
275 | ### VisualStudio ###
276 | ## Ignore Visual Studio temporary files, build results, and
277 | ## files generated by popular Visual Studio add-ons.
278 |
279 | # User-specific files
280 | *.suo
281 | *.user
282 | *.userosscache
283 | *.sln.docstates
284 |
285 | # User-specific files (MonoDevelop/Xamarin Studio)
286 | *.userprefs
287 |
288 | # Build results
289 | [Dd]ebug/
290 | [Dd]ebugPublic/
291 | [Rr]elease/
292 | [Rr]eleases/
293 | x64/
294 | x86/
295 | bld/
296 | [Bb]in/
297 | [Oo]bj/
298 | [Ll]og/
299 |
300 | # Visual Studio 2015 cache/options directory
301 | .vs/
302 | # Uncomment if you have tasks that create the project's static files in wwwroot
303 | #wwwroot/
304 |
305 | # MSTest test Results
306 | [Tt]est[Rr]esult*/
307 | [Bb]uild[Ll]og.*
308 |
309 | # NUNIT
310 | *.VisualState.xml
311 | TestResult.xml
312 |
313 | # Build Results of an ATL Project
314 | [Dd]ebugPS/
315 | [Rr]eleasePS/
316 | dlldata.c
317 |
318 | # DNX
319 | project.lock.json
320 | project.fragment.lock.json
321 | artifacts/
322 |
323 | *_i.c
324 | *_p.c
325 | *_i.h
326 | *.ilk
327 | *.meta
328 | *.obj
329 | *.pch
330 | *.pdb
331 | *.pgc
332 | *.pgd
333 | *.rsp
334 | *.sbr
335 | *.tlb
336 | *.tli
337 | *.tlh
338 | *.tmp
339 | *.tmp_proj
340 | *.log
341 | *.vspscc
342 | *.vssscc
343 | .builds
344 | *.pidb
345 | *.svclog
346 | *.scc
347 |
348 | # Chutzpah Test files
349 | _Chutzpah*
350 |
351 | # Visual C++ cache files
352 | ipch/
353 | *.aps
354 | *.ncb
355 | *.opendb
356 | *.opensdf
357 | *.sdf
358 | *.cachefile
359 | *.VC.db
360 | *.VC.VC.opendb
361 |
362 | # Visual Studio profiler
363 | *.psess
364 | *.vsp
365 | *.vspx
366 | *.sap
367 |
368 | # TFS 2012 Local Workspace
369 | $tf/
370 |
371 | # Guidance Automation Toolkit
372 | *.gpState
373 |
374 | # ReSharper is a .NET coding add-in
375 | _ReSharper*/
376 | *.[Rr]e[Ss]harper
377 | *.DotSettings.user
378 |
379 | # JustCode is a .NET coding add-in
380 | .JustCode
381 |
382 | # TeamCity is a build add-in
383 | _TeamCity*
384 |
385 | # DotCover is a Code Coverage Tool
386 | *.dotCover
387 |
388 | # Visual Studio code coverage results
389 | *.coverage
390 | *.coveragexml
391 |
392 | # NCrunch
393 | _NCrunch_*
394 | .*crunch*.local.xml
395 | nCrunchTemp_*
396 |
397 | # MightyMoose
398 | *.mm.*
399 | AutoTest.Net/
400 |
401 | # Web workbench (sass)
402 | .sass-cache/
403 |
404 | # Installshield output folder
405 | [Ee]xpress/
406 |
407 | # DocProject is a documentation generator add-in
408 | DocProject/buildhelp/
409 | DocProject/Help/*.HxT
410 | DocProject/Help/*.HxC
411 | DocProject/Help/*.hhc
412 | DocProject/Help/*.hhk
413 | DocProject/Help/*.hhp
414 | DocProject/Help/Html2
415 | DocProject/Help/html
416 |
417 | # Click-Once directory
418 | publish/
419 |
420 | # Publish Web Output
421 | *.[Pp]ublish.xml
422 | *.azurePubxml
423 | # TODO: Comment the next line if you want to checkin your web deploy settings
424 | # but database connection strings (with potential passwords) will be unencrypted
425 | *.pubxml
426 | *.publishproj
427 |
428 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
429 | # checkin your Azure Web App publish settings, but sensitive information contained
430 | # in these scripts will be unencrypted
431 | PublishScripts/
432 |
433 | # NuGet Packages
434 | *.nupkg
435 | # The packages folder can be ignored because of Package Restore
436 | **/packages/*
437 | # except build/, which is used as an MSBuild target.
438 | !**/packages/build/
439 | # Uncomment if necessary however generally it will be regenerated when needed
440 | #!**/packages/repositories.config
441 | # NuGet v3's project.json files produces more ignoreable files
442 | *.nuget.props
443 | *.nuget.targets
444 |
445 | # Microsoft Azure Build Output
446 | csx/
447 | *.build.csdef
448 |
449 | # Microsoft Azure Emulator
450 | ecf/
451 | rcf/
452 |
453 | # Windows Store app package directories and files
454 | AppPackages/
455 | BundleArtifacts/
456 | Package.StoreAssociation.xml
457 | _pkginfo.txt
458 |
459 | # Visual Studio cache files
460 | # files ending in .cache can be ignored
461 | *.[Cc]ache
462 | # but keep track of directories ending in .cache
463 | !*.[Cc]ache/
464 |
465 | # Others
466 | ClientBin/
467 | ~$*
468 | *~
469 | *.dbmdl
470 | *.dbproj.schemaview
471 | *.jfm
472 | *.pfx
473 | *.publishsettings
474 | node_modules/
475 | orleans.codegen.cs
476 |
477 | # Since there are multiple workflows, uncomment next line to ignore bower_components
478 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
479 | #bower_components/
480 |
481 | # RIA/Silverlight projects
482 | Generated_Code/
483 |
484 | # Backup & report files from converting an old project file
485 | # to a newer Visual Studio version. Backup files are not needed,
486 | # because we have git ;-)
487 | _UpgradeReport_Files/
488 | Backup*/
489 | UpgradeLog*.XML
490 | UpgradeLog*.htm
491 |
492 | # SQL Server files
493 | *.mdf
494 | *.ldf
495 |
496 | # Business Intelligence projects
497 | *.rdl.data
498 | *.bim.layout
499 | *.bim_*.settings
500 |
501 | # Microsoft Fakes
502 | FakesAssemblies/
503 |
504 | # GhostDoc plugin setting file
505 | *.GhostDoc.xml
506 |
507 | # Node.js Tools for Visual Studio
508 | .ntvs_analysis.dat
509 |
510 | # Visual Studio 6 build log
511 | *.plg
512 |
513 | # Visual Studio 6 workspace options file
514 | *.opt
515 |
516 | # Visual Studio LightSwitch build output
517 | **/*.HTMLClient/GeneratedArtifacts
518 | **/*.DesktopClient/GeneratedArtifacts
519 | **/*.DesktopClient/ModelManifest.xml
520 | **/*.Server/GeneratedArtifacts
521 | **/*.Server/ModelManifest.xml
522 | _Pvt_Extensions
523 |
524 | # Paket dependency manager
525 | .paket/paket.exe
526 | paket-files/
527 |
528 | # FAKE - F# Make
529 | .fake/
530 |
531 | # JetBrains Rider
532 | .idea/
533 | *.sln.iml
534 |
535 | # CodeRush
536 | .cr/
537 |
538 | # Python Tools for Visual Studio (PTVS)
539 | __pycache__/
540 | *.pyc
541 |
542 | # Cake - Uncomment if you are using it
543 | # tools/
544 |
545 | ### VisualStudio Patch ###
546 | build/
547 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Dmitri Nesteruk
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CallSharp
2 | Helper tool for inferring function call chains dependent on input and expected output.
3 |
4 | This is a self-updating app; to install it, click here.
5 |
6 |
7 |
8 | ## Very tentative roadmap
9 |
10 | **0.1** Initial release; search works but takes an atrocious amount of time.
11 |
12 | **0.2** Search speed improvements (static API search).
13 |
14 | ** WE ARE HERE **
15 |
16 | **0.3** Omission fixes: operators, properties, indexers, verification of constructor calls, support for generics.
17 |
18 | tbc.
19 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_0_3/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | CiVIOUmEL7OJqib8B6WQJ/J3zKfd32aZP+63RqmLqeU=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_0_3/CallSharp.exe.config.deploy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_0_3/CallSharp.exe.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_0_3/CallSharp.exe.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_0_3/CallSharp.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | B/rf2DkXctTqUbAgKt7DnAwh4frgHxssA+lXkBX0Q0c=
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | hMyfsqhG/5mgv9CScV0dLn7fKWMQ66404QBg2MF6cnA=
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | xm4bo26HQ0LNVwz1vdPYtzhkpMnp2AI5i+f0b+OahTI=
75 |
76 |
77 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_0_3/JetBrains.Annotations.dll.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_0_3/JetBrains.Annotations.dll.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_4/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | u2AI3Y+Rh8ewSWHTU9ieJgSj5cx9SElobTyXAFmfKpU=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_4/CallSharp.exe.config.deploy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_4/CallSharp.exe.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_4/CallSharp.exe.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_4/CallSharp.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | FTjeFMEmAN0+tqc552JOycklt8EeVQvuLYFqnRkrIYM=
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | hMyfsqhG/5mgv9CScV0dLn7fKWMQ66404QBg2MF6cnA=
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | xm4bo26HQ0LNVwz1vdPYtzhkpMnp2AI5i+f0b+OahTI=
75 |
76 |
77 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_4/JetBrains.Annotations.dll.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_4/JetBrains.Annotations.dll.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_5/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | b6YAOBxDg2/akiyYlSJgllRWWEv9KWaMbpCAJZS/dr4=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_5/CallSharp.exe.config.deploy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_5/CallSharp.exe.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_5/CallSharp.exe.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_5/CallSharp.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | jez0CSgvV2Hyf+K0ec+8U2WiIGdw2hCQMIHKsPdwzAs=
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | hMyfsqhG/5mgv9CScV0dLn7fKWMQ66404QBg2MF6cnA=
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | xm4bo26HQ0LNVwz1vdPYtzhkpMnp2AI5i+f0b+OahTI=
75 |
76 |
77 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_5/JetBrains.Annotations.dll.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_5/JetBrains.Annotations.dll.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_6/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | 9MySKrbJjsCXXJdA5LHVOZ4kXg+g1ZtoQKAnJ38oqQk=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_6/CallSharp.exe.config.deploy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_6/CallSharp.exe.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_6/CallSharp.exe.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_6/CallSharp.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | W6RB31eMDLkOokOyJmzfZOqx6ZYcCy5S3wgsIULmwUI=
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | hMyfsqhG/5mgv9CScV0dLn7fKWMQ66404QBg2MF6cnA=
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | xm4bo26HQ0LNVwz1vdPYtzhkpMnp2AI5i+f0b+OahTI=
75 |
76 |
77 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_6/JetBrains.Annotations.dll.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_6/JetBrains.Annotations.dll.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_7/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | t/xx/k4YKeSwSlpUDga3yCAmu8c+GNn3jx8JjLqeQdQ=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_7/CallSharp.exe.config.deploy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_7/CallSharp.exe.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_7/CallSharp.exe.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_7/CallSharp.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | hvF3tHVnYlmjYHsHK//LyKucAsWhOLgSkZoBwjburjA=
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | hMyfsqhG/5mgv9CScV0dLn7fKWMQ66404QBg2MF6cnA=
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | xm4bo26HQ0LNVwz1vdPYtzhkpMnp2AI5i+f0b+OahTI=
75 |
76 |
77 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_7/JetBrains.Annotations.dll.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_7/JetBrains.Annotations.dll.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_8/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | M5SHz/d9TmAwwO63yM0/aHflw7kGaU40BJQmzY7HMkU=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_8/CallSharp.exe.config.deploy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_8/CallSharp.exe.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_8/CallSharp.exe.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_8/CallSharp.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | JeqtW/29Tz6y38HcftZi1TBQgsBzpxtLi2rUOFgvt9U=
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | hMyfsqhG/5mgv9CScV0dLn7fKWMQ66404QBg2MF6cnA=
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | xm4bo26HQ0LNVwz1vdPYtzhkpMnp2AI5i+f0b+OahTI=
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | z8B1Yi7ZLQei69WU+FjuNXVIuA1c3qYamZ3EDXWExnE=
84 |
85 |
86 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_8/Db/StaticMemberDatabase.tt.deploy:
--------------------------------------------------------------------------------
1 | <#@ template debug="false" hostspecific="false" language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ import namespace="System.Reflection" #>
4 | <#@ import namespace="System.Linq" #>
5 | <#@ import namespace="System.IO" #>
6 | <#@ import namespace="System.Text" #>
7 | <#@ import namespace="System.CodeDom" #>
8 | <#@ import namespace="System.CodeDom.Compiler" #>
9 | <#@ import namespace="System.Collections.Generic" #>
10 |
11 | <#@ output extension=".cs" #>
12 |
13 | <#
14 |
15 | var allowedTypes = new HashSet
16 | {
17 | typeof(int),
18 | typeof(long),
19 | typeof(short),
20 | typeof(sbyte),
21 | typeof(uint),
22 | typeof(ulong),
23 | typeof(ushort),
24 | typeof(byte),
25 | typeof(bool),
26 | typeof(float),
27 | typeof(double),
28 | typeof(decimal),
29 | typeof(DateTime),
30 | typeof(TimeSpan),
31 | typeof(char),
32 | typeof(string),
33 | typeof(Enumerable),
34 | typeof(Math)
35 | };
36 |
37 | Func getFriendlyName = (Type type) =>
38 | {
39 | var codeDomProvider = CodeDomProvider.CreateProvider("C#");
40 | var typeReferenceExpression =
41 | new CodeTypeReferenceExpression(new CodeTypeReference(
42 | type.Name.Contains("RuntimeType") ? type.UnderlyingSystemType : type
43 | ));
44 | using (var writer = new StringWriter())
45 | {
46 | codeDomProvider.GenerateCodeFromExpression(typeReferenceExpression, writer,
47 | new CodeGeneratorOptions());
48 | return writer.GetStringBuilder().Replace("System.", string.Empty).ToString();
49 | }
50 | };
51 |
52 | Func isParams = pi => pi.GetCustomAttribute() != null;
53 |
54 | Func isSingleParamsArgument = ps => ps.Length == 1 && isParams(ps[0]);
55 |
56 | Dictionary> conversionMap = new Dictionary
57 | >
58 | {
59 | {
60 | typeof(decimal), new HashSet
61 | {
62 | typeof(sbyte),
63 | typeof(byte),
64 | typeof(short),
65 | typeof(ushort),
66 | typeof(int),
67 | typeof(uint),
68 | typeof(long),
69 | typeof(ulong),
70 | typeof(char)
71 | }
72 | },
73 | {
74 | typeof(double), new HashSet
75 | {
76 | typeof(sbyte),
77 | typeof(byte),
78 | typeof(short),
79 | typeof(ushort),
80 | typeof(int),
81 | typeof(uint),
82 | typeof(long),
83 | typeof(ulong),
84 | typeof(char),
85 | typeof(float)
86 | }
87 | },
88 | {
89 | typeof(float), new HashSet
90 | {
91 | typeof(sbyte),
92 | typeof(byte),
93 | typeof(short),
94 | typeof(ushort),
95 | typeof(int),
96 | typeof(uint),
97 | typeof(long),
98 | typeof(ulong),
99 | typeof(char),
100 | typeof(float)
101 | }
102 | },
103 | {
104 | typeof(ulong),
105 | new HashSet {typeof(byte), typeof(ushort), typeof(uint), typeof(char)}
106 | },
107 | {
108 | typeof(long), new HashSet
109 | {
110 | typeof(sbyte),
111 | typeof(byte),
112 | typeof(short),
113 | typeof(ushort),
114 | typeof(int),
115 | typeof(uint),
116 | typeof(char)
117 | }
118 | },
119 | {typeof(uint), new HashSet {typeof(byte), typeof(ushort), typeof(char)}},
120 | {
121 | typeof(int),
122 | new HashSet
123 | {
124 | typeof(sbyte),
125 | typeof(byte),
126 | typeof(short),
127 | typeof(ushort),
128 | typeof(char)
129 | }
130 | },
131 | {typeof(ushort), new HashSet {typeof(byte), typeof(char)}},
132 | {typeof(short), new HashSet {typeof(byte)}}
133 | };
134 |
135 |
136 | var provisionOfThisArgumentIsOptional = new Func((ParameterInfo pi) => isParams(pi) || pi.HasDefaultValue);
137 |
138 | var isConvertibleTo = new Func((Type from, Type to) =>
139 | {
140 | if (from == to || to.IsAssignableFrom(from))
141 | {
142 | return true;
143 | }
144 | if (conversionMap.ContainsKey(to) && conversionMap[to].Contains(from))
145 | {
146 | return true;
147 | }
148 | bool castable = from.GetMethods(BindingFlags.Public | BindingFlags.Static)
149 | .Any(
150 | m => m.ReturnType == to &&
151 | (m.Name == "op_Implicit" || m.Name == "op_Explicit")
152 | );
153 | return castable;
154 | });
155 |
156 | var allMethods = new List();
157 | var allConstructors = new List();
158 |
159 | foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
160 | {
161 | try
162 | {
163 | foreach (var type in ass.ExportedTypes.Where(t => allowedTypes.Contains(t)))
164 | {
165 | var name = ass.GetName().Name;
166 | if (name.Contains("VisualStudio") || name.Contains("Temporary")) continue;
167 |
168 | var methods = type.GetMethods();
169 |
170 | allMethods.AddRange(methods);
171 |
172 | foreach (
173 | var ctor in type.GetConstructors().Where(c => !c.ContainsGenericParameters &&
174 | c.GetParameters().Length == 1 &&
175 | !c.GetParameters()[0].ParameterType.IsPointer))
176 | {
177 | allConstructors.Add(ctor);
178 | }
179 | }
180 | }
181 | catch (Exception)
182 | {
183 | #> // cannot get exported types of <#= ass.GetName().Name
184 | #> <#
185 | }
186 |
187 | }
188 | #>
189 |
190 | namespace CallSharp
191 | {
192 | using System;
193 | using System.Diagnostics;
194 | using System.Collections.Generic;
195 |
196 | class StaticMemberDatabase : IMemberDatabase
197 | {
198 | private readonly IFragmentationEngine fragEngine = new FragmentationEngine();
199 |
200 | public IEnumerable FindCandidates(object input, object output, int depth,
201 | string callChain = "input")
202 | {
203 | Trace.WriteLine(callChain);
204 |
205 | var inputType = input.GetType();
206 | var outputType = output.GetType();
207 |
208 | if (input.Equals(output))
209 | {
210 | yield return callChain;
211 | yield break;
212 | }
213 |
214 | // here we try to brute-force conversion of input to output
215 | // if it succeeds, we break as before
216 | object newValue = null;
217 | try
218 | {
219 | newValue = Convert.ChangeType(output, inputType);
220 | } catch (Exception) { }
221 | if (input.Equals(newValue))
222 | {
223 | yield return callChain;
224 | yield break;
225 | }
226 |
227 | bool foundSomething = false;
228 |
229 | // contains all calls that didn't yield the right result
230 | var failCookies = new List();
231 |
232 | // note: technically, we collect fail cookies. or used to.
233 |
234 | // 1) Look for all matching constructors.
235 | <#
236 | foreach (var ctor in allConstructors)
237 | {
238 | #>if (output is <#= ctor.DeclaringType.FullName #> && input is <#= ctor.GetParameters()[0].ParameterType.FullName #>)
239 | {
240 | var instance = new <#= ctor.DeclaringType.FullName #>((<#= ctor.GetParameters()[0].ParameterType.FullName #>)input);
241 | if (instance == (<#= ctor.DeclaringType.FullName #>)output)
242 | {
243 | yield return $"new <#=getFriendlyName(ctor.DeclaringType)#>({callChain})";
244 | foundSomething = true;
245 | }
246 | }
247 | <#
248 | }
249 | #>
250 | // 2) 1-to-1 instance functions.
251 | <#
252 | foreach (var method in allMethods.Where(m => !m.IsStatic &&
253 | (
254 | m.GetParameters().Length == 0
255 | ||
256 | m.GetParameters().All(p => p.IsOptional)
257 | ||
258 | isSingleParamsArgument(m.GetParameters())
259 | )))
260 | { // TODO: group by in/out pairs
261 | #>
262 | if (input is <#= method.DeclaringType.Name #> && typeof(<#= method.ReturnType.FullName #>).IsConvertibleTo(outputType))
263 | {
264 | // invoke!
265 | <# if (method.Name.StartsWith("get_"))
266 | { #>
267 | var result = ((<#= method.DeclaringType.FullName #>)input).<#= method.Name.Substring(4) #>;
268 | <# }
269 | else
270 | { #>
271 | var result = ((<#= method.DeclaringType.FullName #>)input).<#= method.Name #>();
272 | <# } #>
273 | if (Equals(result, output))
274 | {
275 | <#
276 | var cookie = new MethodCallCookie(
277 | method,
278 | new object[]{}
279 | );
280 | #>
281 | foundSomething = true;
282 | yield return string.Format("<#= cookie.ToString() #>", callChain);
283 | }
284 | }
285 | <#
286 | }
287 | #>
288 | // 3. Search static members
289 | <#
290 | foreach (var method in allMethods.Where(m => m.IsStatic && (
291 | !m.Name.Equals("Parse") // throws
292 | &&
293 | !m.Name.Equals("Delete") // just in case
294 | &&
295 | m.GetParameters().Length == 1
296 | &&
297 | !m.GetParameters()[0].ParameterType.IsGenericType
298 | &&
299 | !m.ReturnType.IsGenericType
300 | &&
301 | !m.Name.StartsWith("op_")
302 | )))
303 | {
304 | var parameters = method.GetParameters();
305 | // ensure input type is convertible to first parameter
306 | // todo: ensure we are avoiding ref/out
307 | #>
308 | if (inputType.IsConvertibleTo(typeof(<#= parameters[0].ParameterType.FullName #>)) &&
309 | typeof(<#= method.ReturnType.FullName #>).IsConvertibleTo(outputType))
310 | {
311 | string retVal = null;
312 | try
313 | {
314 | var result = <#= method.DeclaringType.FullName #>.<#= method.Name #>((<#= parameters[0].ParameterType.FullName #>)input);
315 | if (result == (<#= method.ReturnType.FullName #>)output)
316 | <#
317 | var cookie = new MethodCallCookie(method, new []{ "{0}" });
318 | #>
319 | retVal = string.Format("<#= cookie.ToString() #>", callChain);
320 | }
321 | catch {}
322 | if (retVal != null) yield return retVal;
323 | }
324 | <#
325 | }
326 | #>
327 | // 4. Single-argument fragmentation (1-to-2 instance)
328 | if (true || !foundSomething)
329 | {
330 | <#
331 | int numberOfNonOptionalArguments = 1;
332 | foreach (var method in allMethods.Where(m =>
333 | !m.IsStatic
334 | &&
335 | m.GetParameters().Count(p => !provisionOfThisArgumentIsOptional(p)) ==
336 | numberOfNonOptionalArguments
337 | &&
338 | !m.Name.StartsWith("get_") // can actually be an indexer, cannot handle those
339 | ))
340 | {
341 | // check in-out
342 | // todo: get fragmentations first for each type
343 | #>foreach (var arg in fragEngine.Frag(input, typeof(<#= method.GetParameters()[0].ParameterType.FullName #>)))
344 | {
345 | if (input is <#= method.DeclaringType.Name #>
346 | && typeof(<#= method.ReturnType.FullName #>).IsConvertibleTo(outputType))
347 | {
348 | <#= resultDeclaration(method.ReturnType) #>
349 | try {
350 | result = ((<#= method.DeclaringType.FullName #>)input).<#= method.Name #>((<#= method.GetParameters()[0].ParameterType.FullName #>)arg);
351 | } catch {}
352 | if (<#= resultAvailableCheck(method.ReturnType) #> && <#= resultMatchesOutput(method.ReturnType) #>)
353 | {
354 | <#
355 | var cookie = new MethodCallCookie(method, new object []{"{1}"});
356 | #>foundSomething = true;
357 | yield return string.Format("<#= cookie.ToString() #>", callChain,
358 | arg.ToLiteral());
359 | }
360 | }
361 | }
362 | <#
363 | }
364 | #>
365 |
366 | // 5. Two-argument fragmentation; like the above but with quad the complexity.
367 | if (true || !foundSomething)
368 | {
369 |
370 | <#
371 | numberOfNonOptionalArguments = 2;
372 | foreach (var method in allMethods.Where(m =>
373 | !m.IsStatic
374 | &&
375 | m.GetParameters().Count(p => !provisionOfThisArgumentIsOptional(p)) ==
376 | numberOfNonOptionalArguments
377 | &&
378 | !m.Name.StartsWith("get_") // can actually be an indexer, cannot handle those
379 | ))
380 | {
381 | // check in-out
382 | // todo: get fragmentations first for each type
383 | #>foreach (var arg1 in fragEngine.Frag(input, typeof(<#= method.GetParameters()[0].ParameterType.FullName #>)))
384 | foreach (var arg2 in fragEngine.Frag(input, typeof(<#= method.GetParameters()[1].ParameterType.FullName #>)))
385 | {
386 | if (input is <#= method.DeclaringType.Name #>
387 | && typeof(<#= method.ReturnType.FullName #>).IsConvertibleTo(outputType))
388 | {
389 | <#= resultDeclaration(method.ReturnType) #>
390 | try {
391 | result = ((<#= method.DeclaringType.FullName #>)input).<#= method.Name #>(
392 | (<#= method.GetParameters()[0].ParameterType.FullName #>)arg1,
393 | (<#= method.GetParameters()[1].ParameterType.FullName #>)arg2
394 | );
395 | } catch {}
396 | if (<#= resultCheck(method.ReturnType) #>)
397 | {
398 | <#
399 | var cookie = new MethodCallCookie(method, new object []{"{1}", "{2}"});
400 | #>foundSomething = true;
401 | yield return string.Format("<#= cookie.ToString() #>", callChain,
402 | arg1.ToLiteral(), arg2.ToLiteral());
403 | }
404 | }
405 | }
406 | <#
407 | }
408 | #>
409 |
410 | // 5. Assuming we found nothing and aren't in too deep (any-to-1), look for
411 | // methods which do NOT yield outputType
412 | if (/* !foundSomething && */ depth < 2)
413 | {
414 | <#
415 | foreach (var method in allMethods.Where(m =>
416 | !m.IsStatic
417 | &&
418 | (
419 | m.GetParameters().Length == 0
420 | ||
421 | m.GetParameters().All(p => p.IsOptional)
422 | ||
423 | isSingleParamsArgument(m.GetParameters())
424 | )
425 | ))
426 | {
427 | #>if (input is <#= method.DeclaringType.Name #> && typeof(<#= method.ReturnType.FullName #>) == outputType)
428 | {
429 | <#= resultDeclaration(method.ReturnType) #>
430 | try {
431 | // invoke in the hope it yields something useful down the line
432 | <# if (method.Name.StartsWith("get_"))
433 | { #>
434 | result = ((<#= method.DeclaringType.FullName #>)input).<#= method.Name.Substring(4) #>;
435 | <# }
436 | else
437 | { #>
438 | result = ((<#= method.DeclaringType.FullName #>)input).<#= method.Name #>();
439 | <# } #>
440 | <#
441 | var cookie = new MethodCallCookie(
442 | method,
443 | new object[]{}
444 | );
445 | #>
446 | } catch { /* cannot reasonably handle this */}
447 |
448 | <# if (method.ReturnType.IsValueType) { #>
449 | if (result.HasValue && !Equals(result.Value, input))
450 | {
451 | foreach (var c in FindCandidates(result.Value, output, depth+1,
452 | string.Format("<#= cookie.ToString() #>", callChain)))
453 | {
454 | yield return c;
455 | }
456 | }
457 | <# } else { #>
458 | if (result != null && !Equals(result, input))
459 | {
460 | foreach (var c in FindCandidates(result, output, depth+1,
461 | string.Format("<#= cookie.ToString() #>", callChain)))
462 | {
463 | foundSomething = true;
464 | yield return c;
465 | }
466 | }
467 | <# } #>
468 |
469 | }
470 | <#
471 | }
472 | #>
473 |
474 | // 6. Look for similar, but static calls. Here we go again.
475 | <#
476 | foreach (var method in allMethods.Where(m =>
477 | m.IsStatic
478 | &&
479 | m.GetParameters().Length == 1
480 | &&
481 | !m.GetParameters()[0].ParameterType.IsGenericType
482 | &&
483 | !m.ReturnType.IsGenericType
484 | &&
485 | !m.Name.StartsWith("op_")
486 | ))
487 | {
488 | var paramTypeName = method.GetParameters()[0].ParameterType.FullName;
489 | #>
490 |
491 | if (inputType == typeof(<#= paramTypeName #>))
492 | {
493 | <#= resultDeclaration(method.ReturnType) #>
494 | try
495 | {
496 | result = <#= method.DeclaringType.FullName #>.<#= method.Name #>((<#= paramTypeName #>)input);
497 | } catch {}
498 | if (<#= resultCheck(method.ReturnType) #>)
499 | {
500 | <# MethodCallCookie cookie = new MethodCallCookie(method, new object[]{});
501 | #>foreach (var c in FindCandidates(result<#= valueIfNeeded(method.ReturnType) #>, output, depth+1,
502 | string.Format("<#= cookie.ToString() #>", callChain)))
503 | {
504 | foundSomething = true;
505 | yield return c;
506 | }
507 | }
508 | }
509 |
510 | <#
511 | } // foreach method
512 | #>
513 | }
514 | }
515 | }
516 | }
517 | }
518 | }
519 |
520 | <#+
521 |
522 | string valueIfNeeded(Type type)
523 | {
524 | if (type.IsValueType) return ".Value";
525 | return String.Empty;
526 | }
527 |
528 | string resultDeclaration(Type type)
529 | {
530 | return type.IsValueType ?
531 | string.Format("{0}? result = new {0}?();", type.FullName) :
532 | $"{type.FullName} result = null;";
533 | }
534 |
535 | string resultAvailableCheck(Type type)
536 | {
537 | if (type.IsValueType) return "result.HasValue";
538 | else return "result != null";
539 | }
540 |
541 | string resultMatchesOutput(Type type)
542 | {
543 | if (type.IsValueType) return $"result.Value == (({type.FullName})output)";
544 | else return $"result == ({type.FullName})output";
545 | }
546 |
547 | string resultCheck(Type type)
548 | {
549 | return $"{resultAvailableCheck(type)} && {resultMatchesOutput(type)}";
550 | }
551 |
552 | #>
553 |
554 | <#+
555 |
556 | ///
557 | /// This class contains all the information about an attempt to call
558 | /// a particular function on an input object. It contains information
559 | /// about the function called, the arguments that were applied and
560 | /// the resulting return value.
561 | ///
562 | public class MethodCallCookie
563 | {
564 | public MethodInfo MethodCalled;
565 | public object[] Arguments;
566 | public object ReturnValue;
567 |
568 | public MethodCallCookie(MethodInfo methodCalled, object[] arguments)
569 | {
570 | MethodCalled = methodCalled;
571 | Arguments = arguments;
572 | }
573 |
574 | ///
575 | /// The type of the return value.
576 | ///
577 | //public Type ReturnType => ReturnValue.GetType();
578 |
579 | Func getFriendlyName = (Type type) =>
580 | {
581 | var codeDomProvider = CodeDomProvider.CreateProvider("C#");
582 | var typeReferenceExpression =
583 | new CodeTypeReferenceExpression(new CodeTypeReference(
584 | type.Name.Contains("RuntimeType") ? type.UnderlyingSystemType : type
585 | ));
586 | using (var writer = new StringWriter())
587 | {
588 | codeDomProvider.GenerateCodeFromExpression(typeReferenceExpression, writer,
589 | new CodeGeneratorOptions());
590 | return writer.GetStringBuilder().Replace("System.", string.Empty).ToString();
591 | }
592 | };
593 |
594 | static Func isParams = pi => pi.GetCustomAttribute() != null;
595 |
596 | static Func isSingleParamsArgument = ps => ps.Length == 1 && isParams(ps[0]);
597 |
598 | public string ToString(string subject = "{0}")
599 | {
600 | var sb = new StringBuilder();
601 | var methodParams = MethodCalled.GetParameters();
602 |
603 | // we either called it on a member . or on static X.
604 | if (MethodCalled.IsStatic)
605 | sb.Append(getFriendlyName(MethodCalled.DeclaringType));
606 | else
607 | sb.Append(subject);
608 | sb.Append(".");
609 |
610 | if (MethodCalled.Name.StartsWith("get_"))
611 | {
612 | // just a property
613 | sb.Append(MethodCalled.Name.Substring(4));
614 | }
615 | else
616 | {
617 | sb.Append(MethodCalled.Name).Append("(");
618 |
619 | int start = MethodCalled.IsStatic ? 1 : 0;
620 | for (int i = start; i < Arguments.Length; i++)
621 | {
622 | var arg = Arguments[i];
623 | bool ip = isParams(methodParams[i]);
624 |
625 | // caveat: calling a params[] really passes in a single
626 | // 0-sized array :( need special handling
627 | var arr = arg as Array;
628 | if (arr != null && arr.Length == 0)
629 | break;
630 |
631 | // todo: literalize argument into code
632 | if (arg is string)
633 | {
634 | string s = (string) arg;
635 | if (s.Length == 0)
636 | sb.Append("string.Empty");
637 | else if (s.StartsWith("{") && s.EndsWith("}"))
638 | sb.Append(arg);
639 | else
640 | sb.AppendFormat("\"{0}\"", arg);
641 | }
642 | else if (arg is char)
643 | {
644 | sb.AppendFormat("\'{0}'", arg);
645 | }
646 | else if (arg is char[])
647 | {
648 | if (!ip) sb.Append("new char[]{");
649 | sb.Append(string.Join(",", ((char[]) arg).Select(c => "'" + c + "'")));
650 | if (!ip) sb.Append("}");
651 | }
652 | else
653 | {
654 | sb.Append(arg);
655 | }
656 |
657 | if (i+1 != Arguments.Length)
658 | sb.Append(", ");
659 | }
660 |
661 | // on the other hand, a static call has NO arguments, so...
662 | if (MethodCalled.IsStatic)
663 | sb.Append(subject);
664 |
665 | sb.Append(")");
666 | }
667 | return sb.ToString();
668 | }
669 | }
670 |
671 | #>
672 |
673 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_1_1_8/JetBrains.Annotations.dll.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_1_1_8/JetBrains.Annotations.dll.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_2_0_0/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | kNzZyAezxFRFDBcb88NSo7X9BopefUopgyHeWVZTttU=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_2_0_0/CallSharp.exe.config.deploy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_2_0_0/CallSharp.exe.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_2_0_0/CallSharp.exe.deploy
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_2_0_0/CallSharp.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | qwrJ8Tyirm3OWHwWJ5M5ZSFWYlFa9OYskCk3Xie6FBw=
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | hMyfsqhG/5mgv9CScV0dLn7fKWMQ66404QBg2MF6cnA=
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | xm4bo26HQ0LNVwz1vdPYtzhkpMnp2AI5i+f0b+OahTI=
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | z8B1Yi7ZLQei69WU+FjuNXVIuA1c3qYamZ3EDXWExnE=
84 |
85 |
86 |
--------------------------------------------------------------------------------
/distrib/Application Files/CallSharp_0_2_0_0/JetBrains.Annotations.dll.deploy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/Application Files/CallSharp_0_2_0_0/JetBrains.Annotations.dll.deploy
--------------------------------------------------------------------------------
/distrib/CallSharp.application:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | kNzZyAezxFRFDBcb88NSo7X9BopefUopgyHeWVZTttU=
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/distrib/setup.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/distrib/setup.exe
--------------------------------------------------------------------------------
/site/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nesteruk/CallSharp/accdfd681dd2c91127863bf9b6f688d669b6a842/site/screenshot.png
--------------------------------------------------------------------------------
/src/CallSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CallSharp", "CallSharp\CallSharp.csproj", "{CC273AEA-10C3-4AA6-A8BF-A2437D6AB716}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{C12A3423-CFB5-4540-95C8-E5833A911C98}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {CC273AEA-10C3-4AA6-A8BF-A2437D6AB716}.Debug|x64.ActiveCfg = Debug|x64
17 | {CC273AEA-10C3-4AA6-A8BF-A2437D6AB716}.Debug|x64.Build.0 = Debug|x64
18 | {CC273AEA-10C3-4AA6-A8BF-A2437D6AB716}.Release|x64.ActiveCfg = Release|x64
19 | {CC273AEA-10C3-4AA6-A8BF-A2437D6AB716}.Release|x64.Build.0 = Release|x64
20 | {C12A3423-CFB5-4540-95C8-E5833A911C98}.Debug|x64.ActiveCfg = Debug|x64
21 | {C12A3423-CFB5-4540-95C8-E5833A911C98}.Debug|x64.Build.0 = Debug|x64
22 | {C12A3423-CFB5-4540-95C8-E5833A911C98}.Release|x64.ActiveCfg = Release|x64
23 | {C12A3423-CFB5-4540-95C8-E5833A911C98}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/src/CallSharp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/CallSharp/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/CallSharp/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace CallSharp
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/CallSharp/CallSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CC273AEA-10C3-4AA6-A8BF-A2437D6AB716}
8 | WinExe
9 | Properties
10 | CallSharp
11 | CallSharp
12 | v4.5
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | true
17 | ..\..\distrib\
18 | true
19 | Web
20 | true
21 | Foreground
22 | 7
23 | Days
24 | false
25 | false
26 | true
27 | https://raw.githubusercontent.com/nesteruk/CallSharp/master/distrib/
28 | https://raw.githubusercontent.com/nesteruk/CallSharp/master/distrib/
29 | https://github.com/nesteruk/CallSharp
30 | CallSharp
31 | ActiveMesa
32 | false
33 | 1
34 | 0.2.0.%2a
35 | false
36 | true
37 | true
38 |
39 |
40 | 268759745171C45051A7D18A70BB4A794A003153
41 |
42 |
43 | CallSharp_TemporaryKey.pfx
44 |
45 |
46 | true
47 |
48 |
49 | false
50 |
51 |
52 | true
53 | ..\..\bin\
54 | DEBUG;TRACE
55 | full
56 | x64
57 | prompt
58 | MinimumRecommendedRules.ruleset
59 | true
60 | latest
61 |
62 |
63 | ..\bin\
64 | TRACE
65 | true
66 | pdbonly
67 | x64
68 | prompt
69 | MinimumRecommendedRules.ruleset
70 | true
71 |
72 |
73 |
74 | ..\packages\JetBrains.Annotations.10.1.5\lib\net\JetBrains.Annotations.dll
75 | True
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | 4.0
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | MSBuild:Compile
95 | Designer
96 |
97 |
98 |
99 |
100 | True
101 | True
102 | StaticMemberDatabase.tt
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | MSBuild:Compile
117 | Designer
118 |
119 |
120 | App.xaml
121 | Code
122 |
123 |
124 |
125 |
126 | MainWindow.xaml
127 | Code
128 |
129 |
130 |
131 |
132 |
133 |
134 | Code
135 |
136 |
137 | True
138 | True
139 | Resources.resx
140 |
141 |
142 | True
143 | Settings.settings
144 | True
145 |
146 |
147 | ResXFileCodeGenerator
148 | Resources.Designer.cs
149 |
150 |
151 |
152 | SettingsSingleFileGenerator
153 | Settings.Designer.cs
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 | False
163 | Microsoft .NET Framework 4.5 %28x86 and x64%29
164 | true
165 |
166 |
167 | False
168 | .NET Framework 3.5 SP1
169 | false
170 |
171 |
172 |
173 |
174 | TextTemplatingFileGenerator
175 | StaticMemberDatabase.cs
176 |
177 |
178 |
179 |
180 |
181 |
182 |
189 |
--------------------------------------------------------------------------------
/src/CallSharp/CallSharp.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | True
--------------------------------------------------------------------------------
/src/CallSharp/Class1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Collections.Specialized;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Threading;
9 |
10 | namespace CallSharp
11 | {
12 | public class MyObservableCollection : ObservableCollection
13 | {
14 | public override event NotifyCollectionChangedEventHandler CollectionChanged;
15 | protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
16 | {
17 | NotifyCollectionChangedEventHandler CollectionChanged = this.CollectionChanged;
18 | if (CollectionChanged != null)
19 | foreach (NotifyCollectionChangedEventHandler nh in CollectionChanged.GetInvocationList())
20 | {
21 | DispatcherObject dispObj = nh.Target as DispatcherObject;
22 | if (dispObj != null)
23 | {
24 | Dispatcher dispatcher = dispObj.Dispatcher;
25 | if (dispatcher != null && !dispatcher.CheckAccess())
26 | {
27 | dispatcher.BeginInvoke(
28 | (Action)(() => nh.Invoke(this,
29 | new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset))),
30 | DispatcherPriority.DataBind);
31 | continue;
32 | }
33 | }
34 | nh.Invoke(this, e);
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/CallSharp/Cuda.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace CallSharp
4 | {
5 | ///
6 | /// This file is used to proxy certain calls into CUDA kernels that speed up certain calculations.
7 | ///
8 | public abstract class Cuda
9 | {
10 | [DllImport("CallSharp.Cuda.dll")]
11 | public static extern void foo();
12 | }
13 | }
--------------------------------------------------------------------------------
/src/CallSharp/Db/DynamicMemberDatabase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Threading;
8 | using JetBrains.Annotations;
9 |
10 | namespace CallSharp
11 | {
12 | [Obsolete("This is far too slow, use StaticMemberDatabase", true)]
13 | public class DynamicMemberDatabase : IMemberDatabase
14 | {
15 | private readonly HashSet staticMethods = new HashSet();
16 | private readonly HashSet instanceMethods = new HashSet();
17 | private readonly HashSet constructors = new HashSet();
18 | private readonly IFragmentationEngine fragEngine = new FragmentationEngine();
19 |
20 | public DynamicMemberDatabase()
21 | {
22 | // get each loaded assembly
23 | foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
24 | {
25 | // we only care about publicly visible types, right?
26 | foreach (var type in ass.ExportedTypes)
27 | {
28 | Trace.WriteLine(type.FullName + " from " + ass.FullName);
29 | var methods = type.GetMethods();
30 | foreach (var m in methods)
31 | m.AddTo(m.IsStatic ? staticMethods : instanceMethods);
32 |
33 | // we index single-argument constructors only
34 | type.GetConstructors().Where(c =>
35 | !c.ContainsGenericParameters // nor this
36 | && c.GetParameters().Length == 1 // the argument type is unconstrained
37 | ).AddTo(constructors);
38 | }
39 | }
40 | }
41 |
42 |
43 |
44 | ///
45 | /// Locates any non-static method of inputType
that yields a
46 | /// value that is expressly not of ignoreOutputType.
47 | ///
48 | /// The type on which to search for member functions.
49 | /// Optional return type to avoid including in the results.
50 | ///
51 | /// The reason why ignoreOutputType exists is that when making the primary search,
52 | /// we search explicitly for f:A->B and already have cookies from those searches. We want
53 | /// to avoid performing the search again, so we search for f:A->Z where Z != B.
54 | ///
55 | public IEnumerable FindAnyToOneInstance(Type inputType, Type ignoreThisOutputType)
56 | {
57 | foreach (var method in instanceMethods.AsParallel().Where(m =>
58 | m.DeclaringType == inputType &&
59 | m.ReturnType != ignoreThisOutputType &&
60 | m.ReturnType != typeof(void)
61 | // warn: return value can be of any type
62 | ))
63 | {
64 | var pars = method.GetParameters();
65 |
66 | if (!method.IsStatic &&
67 | (pars.Length == 0
68 | || pars.AllAreOptional()
69 | || pars.IsSingleParamsArgument()))
70 | {
71 | yield return method;
72 | }
73 | }
74 | }
75 |
76 | ///
77 | /// This search ought to locate non-void extension methods available in extraneous types, such as
78 | /// IEnumerable extension methods.
79 | ///
80 | ///
81 | ///
82 | ///
83 | public IEnumerable FindAnyToOneStatic(Type inputType,
84 | Type ignoreThisOutputType)
85 | {
86 | foreach (var method in staticMethods.Where(m =>
87 | m.DeclaringType != null
88 | && (
89 | m.DeclaringType.IsIn(TypeDatabase.CoreTypes)
90 | ||
91 | m.DeclaringType.GetInterfaces().Any(i => i.IsGenericType && // no more hack ;)
92 | i.GetGenericTypeDefinition() == typeof(IEnumerable<>))
93 | )
94 | && m.ReturnType != ignoreThisOutputType
95 | && m.IsStatic))
96 | {
97 | var pars = method.GetParameters();
98 |
99 | // accept just 1 argument of required type
100 | if (pars.Length == 1 && pars[0].ParameterType == inputType)
101 | yield return method;
102 | }
103 | }
104 |
105 | public IEnumerable FindConstructorFor(Type inputType, Type outputType)
106 | {
107 | return constructors.Where(c =>
108 | c.DeclaringType == outputType
109 | && c.GetParameters()[0].ParameterType == inputType
110 | );
111 | }
112 |
113 | ///
114 | /// Locate any non-static method of inputType that takes no parameters and
115 | /// returns a value of outputType.
116 | ///
117 | ///
118 | ///
119 | ///
120 | public IEnumerable FindOneToOneInstance(Type inputType, Type outputType)
121 | {
122 | foreach (var method in instanceMethods.AsParallel().Where(m =>
123 | m.DeclaringType == inputType &&
124 | m.ReturnType.IsConvertibleTo(outputType)))
125 | {
126 | var pars = method.GetParameters();
127 |
128 | if (!method.IsStatic &&
129 | (pars.Length == 0
130 | || pars.AllAreOptional()
131 | || pars.IsSingleParamsArgument()))
132 | {
133 | yield return method;
134 | }
135 | }
136 | }
137 |
138 | private IEnumerable FindOneToXInstance(Type inputType, Type outputType,
139 | int numberOfNonOptionalArguments)
140 | {
141 | foreach (var method in instanceMethods.AsParallel().Where(m =>
142 | !m.IsStatic
143 | && m.DeclaringType == inputType
144 | && m.ReturnType.IsConvertibleTo(outputType)))
145 | {
146 | var pars = method.GetParameters();
147 | if (pars.Count(p => !p.ProvisionOfThisArgumentIsOptional()) ==
148 | numberOfNonOptionalArguments)
149 | {
150 | yield return method;
151 | }
152 | }
153 | }
154 |
155 | public IEnumerable FindOneToThreeInstance(Type inputType, Type outputType)
156 | {
157 | return FindOneToXInstance(inputType, outputType, 2);
158 | }
159 |
160 | ///
161 | /// Locate any non-static method of inputType that takes a single parameter or
162 | /// a params[].
163 | ///
164 | ///
165 | ///
166 | ///
167 | public IEnumerable FindOneToTwoInstance(Type inputType, Type outputType)
168 | {
169 | return FindOneToXInstance(inputType, outputType, 1);
170 | }
171 |
172 | ///
173 | /// Locates all static methods of any type that is in
174 | /// that takes an argument of inputType and returns a value of outputType.
175 | ///
176 | ///
177 | ///
178 | ///
179 | public IEnumerable FindOneToOneStatic(Type inputType, Type outputType)
180 | {
181 | // search in ALL core types :)
182 | // warning: allowing other types is NOT SAFE because you might call File.Delete or something
183 | foreach (var method in staticMethods.AsParallel().Where(m =>
184 | m.ReturnType.IsConvertibleTo(outputType)
185 | && TypeDatabase.CoreTypes.Contains(m.DeclaringType) // a core type
186 | && !m.Name.Equals("Parse") // it throws
187 | ))
188 | {
189 | if (method.Name.Contains("Delete"))
190 | throw new Exception("Just in case!");
191 |
192 | if (method.ToString().Contains("System.Math") && method.Name.Contains("Sqrt"))
193 | {
194 | Debugger.Break();
195 | }
196 |
197 | var pars = method.GetParameters();
198 |
199 | if (method.IsStatic &&
200 | pars.Length == 1 &&
201 | inputType.IsConvertibleTo(pars[0].ParameterType)
202 | //pars[0].ParameterType == inputType
203 | )
204 | {
205 | yield return method;
206 | }
207 | }
208 | }
209 |
210 |
211 |
212 | [Pure]
213 | public void FindCandidates(Action visitor, object origin, object input,
214 | object output, int depth, CancellationToken token, string callChain = "input")
215 | {
216 | Trace.WriteLine(callChain);
217 |
218 | // if inputs are completely identical, we have no further work to do
219 | if (input.Equals(output))
220 | {
221 | visitor(callChain);
222 | return;
223 | }
224 |
225 | // here we try to brute-force conversion of input to output
226 | // if it succeeds, we break as before
227 | object newValue = null;
228 | try
229 | {
230 | newValue = Convert.ChangeType(output, input.GetType());
231 | } catch (Exception) { }
232 | if (input.Equals(newValue))
233 | {
234 | visitor(callChain);
235 | return;
236 | }
237 |
238 | bool foundSomething = false;
239 |
240 | // contains all calls that didn't yield the right result
241 | var failCookies = new List();
242 |
243 | foreach (
244 | var ctor in FindConstructorFor(input.GetType(), output.GetType()))
245 | {
246 | // construct exactly this type of object
247 | object instance = ctor.Invoke(new[] { input });
248 | if (instance.Equals(output))
249 | {
250 | visitor($"new {ctor.ReflectedType.GetFriendlyName()}({callChain})");
251 | foundSomething = true;
252 | }
253 | }
254 |
255 | foreach (var m in FindOneToOneInstance(input.GetType(), output.GetType()))
256 | {
257 | var cookie = m.InvokeWithNoArgument(input);
258 | if (cookie != null && output.Equals(cookie.ReturnValue))
259 | {
260 | visitor(cookie.ToString(callChain));
261 | foundSomething = true;
262 | }
263 | else
264 | {
265 | failCookies.Add(cookie);
266 | }
267 | }
268 |
269 |
270 | foreach (var m in FindOneToOneStatic(input.GetType(), output.GetType()))
271 | {
272 | var cookie = m.InvokeStaticWithSingleArgument(input);
273 | if (output.Equals(cookie?.ReturnValue))
274 | {
275 | if (cookie != null && !Equals(cookie.ReturnValue, input))
276 | {
277 | visitor(cookie.ToString(callChain));
278 | foundSomething = true;
279 | }
280 | }
281 | else
282 | {
283 | failCookies.Add(cookie);
284 | }
285 | }
286 |
287 | // look for single-argument fragmentation
288 | if (!foundSomething)
289 | {
290 | foreach (var m in FindOneToTwoInstance(input.GetType(), output.GetType()))
291 | {
292 | // generate a set of values to invoke on
293 | foreach (var arg in fragEngine.Frag(input, m.GetParameters()[0].ParameterType))
294 | {
295 | var cookie = m.InvokeWithArguments(input, arg);
296 | if (output.Equals(cookie?.ReturnValue))
297 | {
298 | if (cookie != null && !Equals(cookie.ReturnValue, input))
299 | {
300 | visitor(cookie.ToString(callChain));
301 | foundSomething = true;
302 | }
303 | }
304 | else
305 | {
306 | failCookies.Add(cookie);
307 | }
308 | }
309 | }
310 | }
311 |
312 | // look for two-argument fragmentation; this is costly
313 | if (!foundSomething)
314 | {
315 | foreach (var m in FindOneToThreeInstance(input.GetType(), output.GetType()))
316 | {
317 | // generate a set of first and second arguments
318 | foreach (var arg1 in fragEngine.Frag(input, m.GetParameters()[0].ParameterType))
319 | foreach (var arg2 in fragEngine.Frag(input, m.GetParameters()[1].ParameterType))
320 | {
321 | var cookie = m.InvokeWithArguments(input, arg1, arg2);
322 | if (output.Equals(cookie?.ReturnValue))
323 | {
324 | if (cookie != null && !Equals(cookie.ReturnValue, input))
325 | {
326 | visitor(cookie.ToString(callChain));
327 | //foundSomething = true;
328 | }
329 | }
330 | else
331 | {
332 | failCookies.Add(cookie);
333 | }
334 | }
335 | }
336 | }
337 |
338 | Action visitorWithCheck = x =>
339 | {
340 | visitor(x);
341 | foundSomething = true;
342 | };
343 |
344 | // assuming we haven't found things and not in too deep
345 | if (!foundSomething && depth < 2)
346 | {
347 | // if we found nothing of worth, try a chain
348 | foreach (var m in FindAnyToOneInstance(input.GetType(), output.GetType()))
349 | {
350 | // get the cookie for this invocation
351 | var cookie = m.InvokeWithNoArgument(input);
352 |
353 | // pass it on
354 | if (cookie != null && !Equals(cookie.ReturnValue, input))
355 | {
356 | FindCandidates(visitorWithCheck, origin, cookie.ReturnValue, output, depth + 1, token, cookie.ToString(callChain));
357 | }
358 | }
359 |
360 | // could be a static call of some arbitrary type
361 | foreach (
362 | var m in FindAnyToOneStatic(input.GetType(), output.GetType()))
363 | {
364 | var cookie = m.InvokeStaticWithSingleArgument(input);
365 | if (cookie != null && !Equals(cookie.ReturnValue, input))
366 | {
367 | FindCandidates(visitorWithCheck, origin, cookie.ReturnValue, output, depth + 1, token, cookie.ToString(callChain));
368 | }
369 | }
370 |
371 | // we already have call results for some invocation chains, why not try those?
372 | foreach (var fc in failCookies.Where(fc => fc != null && !Equals(fc.ReturnValue, input)))
373 | {
374 | FindCandidates(visitorWithCheck, origin, fc.ReturnValue, output, depth + 1, token, fc.ToString(callChain));
375 | }
376 | }
377 | }
378 | }
379 | }
--------------------------------------------------------------------------------
/src/CallSharp/Db/IMemberDatabase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Threading;
5 |
6 | namespace CallSharp
7 | {
8 | public interface IMemberDatabase
9 | {
10 | void FindCandidates(Action visitor, object origin, object input,
11 | object output, int depth, CancellationToken token, string callChain = "input");
12 | }
13 | }
--------------------------------------------------------------------------------
/src/CallSharp/Empty.cs:
--------------------------------------------------------------------------------
1 | namespace CallSharp
2 | {
3 | public static class Empty
4 | {
5 | public static object[] ObjectArray = new object[0];
6 | }
7 | }
--------------------------------------------------------------------------------
/src/CallSharp/EnumerableExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace CallSharp
6 | {
7 | ///
8 | /// Provides a set of static methods for querying objects that implement IEnumerable<T>.
9 | ///
10 | ///
11 | /// These are extensions to System.Linq.Enuemrable and declared and implemented in the same fashion.
12 | ///
13 | public static class EnumerableExtensions
14 | {
15 | // This provides a useful extension-like method to find the index of and item from IEnumerable
16 | // This was based off of the Enumerable.Count extension method.
17 | ///
18 | /// Returns the index of an item in a sequence.
19 | ///
20 | /// The type of the elements of source.
21 | /// A sequence containing elements.
22 | /// The item to locate.
23 | /// The index of the entry if it was found in the sequence; otherwise, -1.
24 | public static int IndexOf(this IEnumerable source, TSource item)
25 | {
26 | return IndexOf(source, item, null);
27 | }
28 |
29 | // This provides a useful extension-like method to find the index of and item from IEnumerable
30 | // This was based off of the Enumerable.Count extension method.
31 | ///
32 | /// Returns the index of an item in a sequence.
33 | ///
34 | /// The type of the elements of source.
35 | /// A sequence containing elements.
36 | /// The item to locate.
37 | /// The item equality comparer to use. Pass null to use the default comparer.
38 | /// The index of the entry if it was found in the sequence; otherwise, -1.
39 | public static int IndexOf(this IEnumerable source, TSource item,
40 | IEqualityComparer itemComparer)
41 | {
42 | if (source == null)
43 | {
44 | throw new ArgumentNullException(nameof(source));
45 | }
46 |
47 | var listOfT = source as IList;
48 | if (listOfT != null)
49 | {
50 | return listOfT.IndexOf(item);
51 | }
52 |
53 | var list = source as IList;
54 | if (list != null)
55 | {
56 | return list.IndexOf(item);
57 | }
58 |
59 | if (itemComparer == null)
60 | {
61 | itemComparer = EqualityComparer.Default;
62 | }
63 |
64 | int i = 0;
65 | foreach (TSource possibleItem in source)
66 | {
67 | if (itemComparer.Equals(item, possibleItem))
68 | {
69 | return i;
70 | }
71 | i++;
72 | }
73 | return -1;
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/src/CallSharp/ExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace CallSharp
4 | {
5 | using System;
6 | using System.CodeDom;
7 | using System.CodeDom.Compiler;
8 | using System.Collections.Generic;
9 | using System.IO;
10 | using System.Linq;
11 | using System.Reflection;
12 | using System.Runtime.CompilerServices;
13 | using JetBrains.Annotations;
14 |
15 | public static class ExtensionMethods
16 | {
17 | public static string ToLiteral(this object o)
18 | {
19 | if (o is Array)
20 | {
21 | var a = o as Array;
22 | var sb = new StringBuilder();
23 | sb.Append("new [] { ");
24 | for (int i = 0; i < a.Length; i++)
25 | {
26 | sb.Append(a.GetValue(i).ToLiteral());
27 | if (i + 1 != a.Length)
28 | sb.Append(", ");
29 | }
30 | sb.Append(" }");
31 | return sb.ToString();
32 | }
33 | if (o is string)
34 | {
35 | if ((o as string).Length == 0)
36 | return "string.Empty";
37 | return $"\"{o}\"";
38 | }
39 | if (o is char)
40 | {
41 | return $"'{o}'";
42 | }
43 | return o.ToString();
44 | }
45 |
46 | public static string RemoveMarkers(this string s)
47 | {
48 | return s.Replace(MagicTextBox.SpaceChar, ' ');
49 | }
50 |
51 | public static bool AllAreOptional(this ParameterInfo[] ps)
52 | {
53 | return ps.All(p => p.IsOptional);
54 | }
55 |
56 | public static bool IsParams(this ParameterInfo pi)
57 | {
58 | return pi.GetCustomAttribute() != null;
59 | }
60 |
61 | public static bool ProvisionOfThisArgumentIsOptional(this ParameterInfo pi)
62 | {
63 | return pi.IsParams() || pi.HasDefaultValue;
64 | }
65 |
66 | [CanBeNull]
67 | public static MethodCallCookie InvokeStaticWithSingleArgument(this MethodInfo mi,
68 | T arg)
69 | {
70 | MethodCallCookie result = null;
71 | try
72 | {
73 | var args = new object[] { arg };
74 | var retval = mi.Invoke(null /*static*/, args);
75 | result = new MethodCallCookie(mi, args, retval);
76 | }
77 | catch
78 | {
79 | // we cannot reasonably catch this
80 | }
81 | return result;
82 | }
83 |
84 | public static IEnumerable Combinations(this T[] values, int k)
85 | {
86 | if (k < 0 || values.Length < k)
87 | yield break; // invalid parameters, no combinations possible
88 |
89 | // generate the initial combination indices
90 | var combIndices = new int[k];
91 | for (var i = 0; i < k; i++)
92 | {
93 | combIndices[i] = i;
94 | }
95 |
96 | while (true)
97 | {
98 | // return next combination
99 | var combination = new T[k];
100 | for (var i = 0; i < k; i++)
101 | {
102 | combination[i] = values[combIndices[i]];
103 | }
104 | yield return combination;
105 |
106 | // find first index to update
107 | var indexToUpdate = k - 1;
108 | while (indexToUpdate >= 0 && combIndices[indexToUpdate] >= values.Length - k + indexToUpdate)
109 | {
110 | indexToUpdate--;
111 | }
112 |
113 | if (indexToUpdate < 0)
114 | yield break; // done
115 |
116 | // update combination indices
117 | for (var combIndex = combIndices[indexToUpdate] + 1; indexToUpdate < k; indexToUpdate++, combIndex++)
118 | {
119 | combIndices[indexToUpdate] = combIndex;
120 | }
121 | }
122 | }
123 |
124 | [CanBeNull]
125 | public static MethodCallCookie InvokeWithArguments(this MethodInfo mi, object self,
126 | params object[] args)
127 | {
128 | MethodCallCookie result = null;
129 | try
130 | {
131 | var retval = mi.Invoke(self, args);
132 | result = new MethodCallCookie(mi, args, retval);
133 | }
134 | catch
135 | {
136 | // we cannot reasonably catch this
137 | }
138 | return result;
139 | }
140 |
141 | [CanBeNull]
142 | public static MethodCallCookie InvokeWithNoArgument(this MethodInfo mi, T subject)
143 | {
144 | var pars = mi.GetParameters();
145 | MethodCallCookie result = null;
146 | try
147 | {
148 | if (pars.IsSingleParamsArgument())
149 | {
150 | var args = new[]
151 | {
152 | Activator.CreateInstance(pars[0].ParameterType.UnderlyingSystemType, 0)
153 | };
154 | var retval = mi.Invoke(subject, args);
155 | result = new MethodCallCookie(mi, args, retval);
156 | }
157 | else
158 | {
159 | var retval = mi.Invoke(subject, Empty.ObjectArray);
160 | result = new MethodCallCookie(mi, Empty.ObjectArray, retval);
161 | }
162 | }
163 | catch
164 | {
165 | }
166 | return result;
167 | }
168 |
169 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
170 | public static bool IsIn(this T obj, IEnumerable collection)
171 | {
172 | return collection.Contains(obj);
173 | }
174 |
175 | public static bool IsSingleParamsArgument(this ParameterInfo[] ps)
176 | {
177 | return ps.Length == 1 && ps[0].IsParams();
178 | }
179 |
180 | public static IList