René's URL Explorer Experiment


Title: Constructor failing argument matching, silently selects default constructor · Issue #238 · pythonnet/pythonnet · GitHub

Open Graph Title: Constructor failing argument matching, silently selects default constructor · Issue #238 · pythonnet/pythonnet

X Title: Constructor failing argument matching, silently selects default constructor · Issue #238 · pythonnet/pythonnet

Description: (Version 2.1) Given .NET class: public class A { public A() { a=1.0;} public A(double ax) { a=ax;} public double a; } then in python: from Xxx import A a1 = A(2) # surprise! default constructor is selected, silently, basically because # ...

Open Graph Description: (Version 2.1) Given .NET class: public class A { public A() { a=1.0;} public A(double ax) { a=ax;} public double a; } then in python: from Xxx import A a1 = A(2) # surprise! default constructor is ...

X Description: (Version 2.1) Given .NET class: public class A { public A() { a=1.0;} public A(double ax) { a=ax;} public double a; } then in python: from Xxx import A a1 = A(2) # surprise! default constructor is ...

Opengraph URL: https://github.com/pythonnet/pythonnet/issues/238

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constructor failing argument matching, silently selects default constructor","articleBody":"(Version 2.1)\n\nGiven .NET class:\n\n``` C#\n      public class A {\n\n           public A() { a=1.0;}\n\n           public A(double ax) { a=ax;}\n\n           public double a;\n\n     }\n```\n\nthen in python:\n\n``` python\nfrom Xxx import A\n\na1 = A(2)   # surprise! default constructor is selected, silently, basically because \n            # there is no int-\u003edouble type promotion in constructor binder\n            # causing first bind to fail, then second bind with no args (that was a fix\n            # to allow .NET objects to be super-classes (or be sub-classed) from\n            # python succeeds..\na2 = A(2.0) # Ok, now we get the second constructor, because it's a perfect match.\n```\n\nI am fully aware that super-classes, argument-matching, (automatic) type-conversion,\n and bridging the gap between python and .NET (C#) , is very complex.\nAnd providing a full implementation that 'just do the thing we want' is not trivial.\n\nIt might be that some of the issues related to sub-classing, as well as argument matching/conversion is related, - but I hope the simple example above illustrates that\nsome minor improvement at this stage could be quite useful.\n\nThere is a few fixes, that could improve this slightly:\n\n(a.) Make simple type-promotion/argument conversion happen during constructor argument matching\n(b.) If construction of a .NET object is attempted, and argument match fail, then always raise Type error\n\nI will provide a PR for (a.) since it's a simple fix to verify a simple type-promotion from int-\u003edouble etc.\n\nFixing (b.), raise error if no .NET constructor matches the arguments is easy, but will then break the sub-class mechanism. If we knew, by the time we are calling the .NET constructor, that it's a super-class, then we  _could_ either have a relaxed matching (as is to day, default to the default-ct, if fail), and then insist on match for all other cases.\n\nAfter all, providing something that fixes (b.), and at the same time supports, and possibly extends super()/sub-classing mechanism seems harder to me, since we need to know the context in which the .NET object is constructed.\n\nIf anyone see a easy solution to (b.) , - as in knowing how to get the context of the .NET class construction, that would be great.\n\nWe could then provide a  fix where \n\n' you succeed with your intention creating a new object with the supplied parameters, and get the expected result, or we raise Type-exception notifying about the problem' \n","author":{"url":"https://github.com/sigbjorn","@type":"Person","name":"sigbjorn"},"datePublished":"2016-07-03T22:09:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/238/pythonnet/issues/238"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c3ef884b-8961-c13a-92bf-11ca3bf5050c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE3CE:35935A:2AFE75:39AB07:697155A7
html-safe-nonce80ee83b78e75768f03816e9fb4fd0a40a603f42eb9b6ecac99d8653aa01eaaf5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0NFOjM1OTM1QToyQUZFNzU6MzlBQjA3OjY5NzE1NUE3IiwidmlzaXRvcl9pZCI6IjUzODAzMjY4Nzk0NTU2OTYyOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace47338c95c4f77efa14bc428b72d0dc378ae7ddfb3291cbdfc9eefafdcfdd4f3
hovercard-subject-tagissue:163582259
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/238/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d074ce529fec93adcc7ebb2fc02cb44a069d6150efeeb592ad5b31c4993fd651/pythonnet/pythonnet/issues/238
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d074ce529fec93adcc7ebb2fc02cb44a069d6150efeeb592ad5b31c4993fd651/pythonnet/pythonnet/issues/238
og:image:alt(Version 2.1) Given .NET class: public class A { public A() { a=1.0;} public A(double ax) { a=ax;} public double a; } then in python: from Xxx import A a1 = A(2) # surprise! default constructor is ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesigbjorn
hostnamegithub.com
expected-hostnamegithub.com
Nonefd5876ec68f4a61d42f4010f6d1b2764d8ae314777de44028a7708a1d7bac1b5
turbo-cache-controlno-preview
go-importgithub.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git
octolytics-dimension-user_id6050430
octolytics-dimension-user_loginpythonnet
octolytics-dimension-repository_id14748123
octolytics-dimension-repository_nwopythonnet/pythonnet
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14748123
octolytics-dimension-repository_network_root_nwopythonnet/pythonnet
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8f48ed2345879fb640360c3a24f1d1780c3ed3cb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/pythonnet/pythonnet/issues/238#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F238
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F238
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pythonnet%2Fpythonnet
Reloadhttps://github.com/pythonnet/pythonnet/issues/238
Reloadhttps://github.com/pythonnet/pythonnet/issues/238
Reloadhttps://github.com/pythonnet/pythonnet/issues/238
pythonnet https://github.com/pythonnet
pythonnethttps://github.com/pythonnet/pythonnet
Notifications https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Fork 770 https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Star 5.4k https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Code https://github.com/pythonnet/pythonnet
Issues 155 https://github.com/pythonnet/pythonnet/issues
Pull requests 18 https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects 0 https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/pythonnet/pythonnet/security
Please reload this pagehttps://github.com/pythonnet/pythonnet/issues/238
Insights https://github.com/pythonnet/pythonnet/pulse
Code https://github.com/pythonnet/pythonnet
Issues https://github.com/pythonnet/pythonnet/issues
Pull requests https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security https://github.com/pythonnet/pythonnet/security
Insights https://github.com/pythonnet/pythonnet/pulse
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/238
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/238
#1651https://github.com/pythonnet/pythonnet/pull/1651
Constructor failing argument matching, silently selects default constructorhttps://github.com/pythonnet/pythonnet/issues/238#top
#1651https://github.com/pythonnet/pythonnet/pull/1651
bughttps://github.com/pythonnet/pythonnet/issues?q=state%3Aopen%20label%3A%22bug%22
3.0.0https://github.com/pythonnet/pythonnet/milestone/6
https://github.com/sigbjorn
https://github.com/sigbjorn
sigbjornhttps://github.com/sigbjorn
on Jul 3, 2016https://github.com/pythonnet/pythonnet/issues/238#issue-163582259
bughttps://github.com/pythonnet/pythonnet/issues?q=state%3Aopen%20label%3A%22bug%22
3.0.0https://github.com/pythonnet/pythonnet/milestone/6
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.