Title: .NET property not accessible in derived classes where only the setter or the getter has been overridden · Issue #1455 · pythonnet/pythonnet · GitHub
Open Graph Title: .NET property not accessible in derived classes where only the setter or the getter has been overridden · Issue #1455 · pythonnet/pythonnet
X Title: .NET property not accessible in derived classes where only the setter or the getter has been overridden · Issue #1455 · pythonnet/pythonnet
Description: Environment Pythonnet version: 2.5.2 Python version: 3.7 Operating System: Windows 10 .NET Runtime: 4.8 Details Let's create a simple base class that exposes a property, then create a derived class that overrides the setter, but not the ...
Open Graph Description: Environment Pythonnet version: 2.5.2 Python version: 3.7 Operating System: Windows 10 .NET Runtime: 4.8 Details Let's create a simple base class that exposes a property, then create a derived class...
X Description: Environment Pythonnet version: 2.5.2 Python version: 3.7 Operating System: Windows 10 .NET Runtime: 4.8 Details Let's create a simple base class that exposes a property, then create a derived c...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1455
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":".NET property not accessible in derived classes where only the setter or the getter has been overridden","articleBody":"### Environment\r\n\r\n- Pythonnet version: 2.5.2\r\n- Python version: 3.7\r\n- Operating System: Windows 10\r\n- .NET Runtime: 4.8\r\n\r\n### Details\r\n\r\n- Let's create a simple base class that exposes a property, then create a derived class that overrides the setter, but not the getter (that is supposed to be as it was defined in the base class)\r\n\r\n```C#\r\nnamespace PythonNetTest\r\n{\r\n public class BaseClass\r\n {\r\n protected string name = \"noname\";\r\n\r\n public virtual string Name { get =\u003e name; set =\u003e name = value; }\r\n }\r\n\r\n public class DerivedClass : BaseClass\r\n {\r\n public override string Name { set =\u003e base.Name = value.ToUpper(); }\r\n }\r\n}\r\n```\r\n\r\n- Let's now use the above classes in Python\r\n\r\n```python\r\nimport clr\r\nclr.AddReference(\"PythonNetTest\")\r\nfrom PythonNetTest import BaseClass, DerivedClass\r\n\r\nd = DerivedClass()\r\nb = BaseClass()\r\n\r\nb.Name = 'BaseClass Name'\r\nd.Name = 'DerivedClass Name'\r\n\r\nprint(b.Name) # ok\r\nprint(d.Name) # TypeError: property cannot be read\r\n```\r\n\r\n- Here the `print(d.Name)` will rise the exception `TypeError: property cannot be read`.\r\n- As a workaround it is possible to use `print(d.GetType().BaseType.GetProperty('Name').GetValue(d))` instead, but it is not one would expect.","author":{"url":"https://github.com/spynetcamera","@type":"Person","name":"spynetcamera"},"datePublished":"2021-05-13T20:43:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1455/pythonnet/issues/1455"}
| 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:ea9fd892-2744-ed9b-cb38-5d3b72b40b23 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B504:348DF0:2F8B81B:4005D4C:697083A3 |
| html-safe-nonce | 73a31012d02f1275977ce0c84ca9bdbbf3be71e5e7325075f578b6d42dadb4d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTA0OjM0OERGMDoyRjhCODFCOjQwMDVENEM6Njk3MDgzQTMiLCJ2aXNpdG9yX2lkIjoiODI5ODAzNTk3MTk0OTEwMTk4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 719c1140f631856e7daed82945d976cce0252d4c80034d854db85253dc4c3484 |
| hovercard-subject-tag | issue:891358107 |
| 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/pythonnet/pythonnet/1455/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6dbfb05970d614e32c564b19e718ee3f0c6d88443eea1c99bff86139ddbdafe0/pythonnet/pythonnet/issues/1455 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6dbfb05970d614e32c564b19e718ee3f0c6d88443eea1c99bff86139ddbdafe0/pythonnet/pythonnet/issues/1455 |
| og:image:alt | Environment Pythonnet version: 2.5.2 Python version: 3.7 Operating System: Windows 10 .NET Runtime: 4.8 Details Let's create a simple base class that exposes a property, then create a derived class... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | spynetcamera |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| 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 | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width