Title: Subclassing ValueType with custom constructor crashes with internal CLR error · Issue #10231 · PowerShell/PowerShell · GitHub
Open Graph Title: Subclassing ValueType with custom constructor crashes with internal CLR error · Issue #10231 · PowerShell/PowerShell
X Title: Subclassing ValueType with custom constructor crashes with internal CLR error · Issue #10231 · PowerShell/PowerShell
Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Open Graph Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
X Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Opengraph URL: https://github.com/PowerShell/PowerShell
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Subclassing ValueType with custom constructor crashes with internal CLR error","articleBody":"\u003c!--\r\n\r\nFor Windows PowerShell 5.1 issues, suggestions, or feature requests please use the following link instead:\r\nWindows PowerShell [UserVoice](https://windowsserver.uservoice.com/forums/301869-powershell)\r\n\r\nThis repository is **ONLY** for PowerShell Core 6 issues.\r\n\r\n- Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- Search the existing issues.\r\n- Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- Refer to the [known issues](https://docs.microsoft.com/powershell/scripting/whats-new/known-issues-ps6?view=powershell-6).\r\n\r\n-->\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n# Parameterless constructor isn't the best example since you can't\r\n# do that in C# either, but it also repros with parameters.\r\nclass Test : ValueType {\r\n Test() { }\r\n}\r\n\r\n[Test]::new()\r\n```\r\n\r\n# Expected behavior\r\n\r\nEither\r\n\r\n1. Parse error when `ValueType` is the base class\r\n1. Special handling for value types when generating constructors. I'm guessing this has to do with `$this` needing to be explicitly boxed, but I haven't looked into it\r\n\r\n# Actual behavior\r\n\r\n```none\r\nInternal CLR error. (0x80131506)\r\n at DynamicClass.Test(System.Runtime.CompilerServices.Closure, System.Management.Automation.Language.FunctionContext)\r\n at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(System.Management.Automation.ScriptBlockClauseToInvoke, Boolean, System.Collections.Generic.Dictionary`2\u003cSystem.String,System.Management.Automation.ScriptBlock>, System.Collections.Generic.List`1\u003cSystem.Management.Automation.PSVariable>, ErrorHandlingBehavior, System.Object, System.Object, System.Object, System.Management.Automation.Internal.Pipe, System.Management.Automation.InvocationInfo, System.Object[])\r\n at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean, ErrorHandlingBehavior, System.Object, System.Object, System.Object, System.Management.Automation.Internal.Pipe, System.Management.Automation.InvocationInfo, Boolean, System.Collections.Generic.List`1\u003cSystem.Management.Automation.PSVariable>, System.Collections.Generic.Dictionary`2\u003cSystem.String,System.Management.Automation.ScriptBlock>, System.Object[])\r\n at System.Management.Automation.ScriptBlock.InvokeAsMemberFunction(System.Object, System.Object[])\r\n at System.Management.Automation.Internal.ScriptBlockMemberMethodWrapper.InvokeHelper(System.Object, System.Object, System.Object[])\r\n at System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)\r\n at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean, Boolean, Boolean)\r\n at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean, Boolean, Boolean)\r\n at System.Activator.CreateInstance(System.Type, Boolean, Boolean)\r\n at System.Activator.CreateInstance(System.Type)\r\n at System.Management.Automation.Interpreter.InitializeLocalInstruction+MutableValue.Run(System.Management.Automation.Interpreter.InterpretedFrame)\r\n at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)\r\n at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)\r\n at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon)\r\n```\r\n\r\nThe above stack trace minus the first two lines repeats for about 5,000 lines before PowerShell crashes. Sometimes the stack trace isn't included, and it's just the first line.\r\n\r\n# Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```none\r\nName Value\r\n---- -----\r\nPSVersion 7.0.0-preview.2\r\nPSEdition Core\r\nGitCommitId 7.0.0-preview.2\r\nOS Microsoft Windows 10.0.18362\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/SeeminglyScience","@type":"Person","name":"SeeminglyScience"},"datePublished":"2019-07-26T12:08:04Z","url":"https://github.com/PowerShell/PowerShell/issues/10231"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:f4c221c5-75e0-1e86-6eb7-bb2f235df181 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84BE:3524E1:1B4F51:275D4E:6AFDD080 |
| html-safe-nonce | ef881a2694262fcade29e50a58109506b1cee70d3fd4af6ef32008a49cb2f154 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEJFOjM1MjRFMToxQjRGNTE6Mjc1RDRFOjZBRkREMDgwIiwidmlzaXRvcl9pZCI6IjMxODYyNjc4MTU4NDk4NzM1MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c9e59d5f4eb819ae5f50da2fb29f857da3454af87b2d26910d980703b2b2afd5 |
| hovercard-subject-tag | repository:49609581 |
| 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/PowerShell/PowerShell/issues/10231 |
| twitter:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| twitter:card | summary_large_image |
| og:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| og:image:alt | PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub. |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26886a40b582b821a7a76351e0a2f42b6d6160854b6e2520db24f31fd7be5da7 |
| turbo-cache-control | no-cache |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| 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 | 68ebaa631a1d248d69ebde4b9c5defd3a19aeb2f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width