Title: Proper prototype handling · Issue #60 · JavascriptNet/Javascript.Net · GitHub
Open Graph Title: Proper prototype handling · Issue #60 · JavascriptNet/Javascript.Net
X Title: Proper prototype handling · Issue #60 · JavascriptNet/Javascript.Net
Description: Problem Currently JavaScript.Net does not fully support prototype related use cases: While it is possible to register a function which creates a new object like this: _context.SetParameter("TestClass", new Func
Open Graph Description: Problem Currently JavaScript.Net does not fully support prototype related use cases: While it is possible to register a function which creates a new object like this: _context.SetParameter("TestCla...
X Description: Problem Currently JavaScript.Net does not fully support prototype related use cases: While it is possible to register a function which creates a new object like this: _context.SetParameter("Te...
Opengraph URL: https://github.com/JavascriptNet/Javascript.Net/issues/60
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proper prototype handling","articleBody":"# Problem\r\n\r\nCurrently JavaScript.Net does not fully support prototype related use cases:\r\n\r\nWhile it is possible to register a function which creates a new object like this:\r\n\r\n```c#\r\n_context.SetParameter(\"TestClass\", new Func\u003cTestClass\u003e(() =\u003e new TestClass()));\r\n\r\n_context.Run(@\"\r\n let c = new TestClass();\r\n c.foo()\").Should().Be(true);\r\n```\r\n\r\nproblems with this approach:\r\n\r\n* `instanceOf` checks are not working. `c instanceof TestClass` is false\r\n* Prototype extensions are not working (`TestClass.prototype.newMethod = function() {...}`)\r\n\r\n# Things to consider for the solution\r\n\r\n* Objects which are created by C# code should also be able to pass to JavaScript under an existing prototype\r\n* Fine grained control about which types are constructable by JS is required\r\n\r\n# Solution proposal\r\n\r\n* add method like `SetConstructor(ConstructorInfo constructor)` to the context which generates a prototype and registers under the name\r\n* when wrapping an object:\r\n - lookup whether a prototype already exists for the type\r\n - if no prototype is known: generate a prototype (but do not make it available to the context under a name)\r\n - wrap object by using the newly generated or existing prototype\r\n\r\n## Side notes\r\n\r\nThis could also improve performance of wrapping objects since the analysis of type is only required once, repetitive passing could become a lot faster.\r\n\r\n---\r\n\r\n/cc @spahnke \r\n\r\n@oliverbock do you think the proposal above is sane? Then I would start to implement it.","author":{"url":"https://github.com/Ablu","@type":"Person","name":"Ablu"},"datePublished":"2018-10-05T07:15:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/60/Javascript.Net/issues/60"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b816679-0fc0-2f9b-8d3c-1e84d9c75645 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A278:25602F:CCA1C74:10AE9CA4:69768FAE |
| html-safe-nonce | cec53bfad99c970cadbdfb7c259ec1fba7972c405e857129783fe4585ef5394d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjc4OjI1NjAyRjpDQ0ExQzc0OjEwQUU5Q0E0OjY5NzY4RkFFIiwidmlzaXRvcl9pZCI6IjE0NjU0MjQzNzQ4MDUyMDQ5MTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 91be0793494a8dcff5f6557de7ae0838ebdf7a9bf27bbcef882b740138530715 |
| hovercard-subject-tag | issue:367087666 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JavascriptNet/Javascript.Net/60/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ee99a20d94eeebee62187520c831acaaf273da068cb96b967bf9d8200e08ef5c/JavascriptNet/Javascript.Net/issues/60 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ee99a20d94eeebee62187520c831acaaf273da068cb96b967bf9d8200e08ef5c/JavascriptNet/Javascript.Net/issues/60 |
| og:image:alt | Problem Currently JavaScript.Net does not fully support prototype related use cases: While it is possible to register a function which creates a new object like this: _context.SetParameter("TestCla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Ablu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 032152924a283b83384255d9489e7b93b54ba01da8d380b05ecd3953b3212411 |
| turbo-cache-control | no-preview |
| go-import | github.com/JavascriptNet/Javascript.Net git https://github.com/JavascriptNet/Javascript.Net.git |
| octolytics-dimension-user_id | 7556289 |
| octolytics-dimension-user_login | JavascriptNet |
| octolytics-dimension-repository_id | 9036853 |
| octolytics-dimension-repository_nwo | JavascriptNet/Javascript.Net |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 9036853 |
| octolytics-dimension-repository_network_root_nwo | JavascriptNet/Javascript.Net |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5b577f6be6482e336e3c30e8daefa30144947b17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width