-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeBuilder::CreateTypeInfo() should not throw COMException #43282
Comments
The error here is
At the point of the throw, the exception is of type
@davidwrighton or @jkotas Any opinions or suggestions on how to change this exception type? I guess we could catch prior to the QCall exist and convert to a better managed type. |
We have plans to enabled byref fields in .NET 6. If that happens, there will be no exception thrown for this repro that will take of this specific problem. As for the more general problem of mapping HRESULTs to right exception types inside CoreCLR, I am not sure the best way to fix it either. |
Why not add suggested ArgumentException check to DefineField (that's what it'd done for everything else) ? |
The check for ByRefs in GetTypeTokenWorkerNoLock is not right. I think we should remove it. It is too aggresive. For example, it will incorrectly fire for:
that is valid IL. Reflection.Emit should not really be in the business of validating the emitted IL. |
This issue can be re-purposed somewhat then to fix or remove the byref check and add tests. |
Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT, @marek-safar, @tannergooding, @CoffeeFlux Issue DetailsWhen TypeBuilder encounters by-ref field it throws COMException. This seems to be the only reference to COMException and the behaviour is not consistent with other error handling for different type members. runtime/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineField.cs Lines 107 to 113 in cfb1335
It should be replaced with ArgumentException as it's done for all other type members. Here is an example with events runtime/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineEvent.cs Lines 109 to 115 in cfb1335
|
moving to 7.0 since this is non-essential for 6.0 |
When TypeBuilder encounters by-ref field it throws COMException. This seems to be the only reference to COMException and the behaviour is not consistent with other error handling for different type members.
runtime/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineField.cs
Lines 107 to 113 in cfb1335
It should be replaced with ArgumentException as it's done for all other type members. Here is an example with events
runtime/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineEvent.cs
Lines 109 to 115 in cfb1335
The text was updated successfully, but these errors were encountered: