Day 1. Make dedicated MonoError for `mono_error_set_argument_out_of_range`
So I decided to choose my first possible PR target as Mono project, which I used it once before to develop some Visual Basic.NET project.(failed though)
So this is the first issue I encountered: (#8516)
Although didn't know whether this issue is being resolved or not, this is one of the few which seems to be manageable to me, so I tried to look upon it.
```c
void
mono_error_set_argument_out_of_range (MonoError *error, const char *param_name)
{
/* ORIGINAL IMPLEMENTATION
ERROR_DECL (error_creating_exception);
mono_error_set_exception_handle (error, mono_new_exception_argument_out_of_range (name, error_creating_exception));
mono_error_cleanup (error_creating_exception);
*/
mono_error_set_specific (error, MONO_ERROR_ARGUMENT_OUT_OF_RANGE, "MonoArgumentException:%s", param_name);
if (param_name)
mono_error_set_first_argument (error, param_name);
}
```
I think I'll wait for OP of the issue to reply to me on Gitter.
UPDATE:
He replied:
Great questions.
So here's what's up with MonoError. It has basically two places where things happen to it - we allocate it at the border between managed .NET code and the C code that implements the runtime. Then we pass around MonoError* all through the C code. eventually something goes wrong and we call one of the mono_error_set_... functions. Then we thread the erroneous value back out to the callers of each function - up the call stack all the way back to the .NET/C border. There we call mono_error_prepare_exception to convert from the MonoError struct into a manage System.Exception instance.
In this case we want to create an ArgumentOutOfRangeException.
we want to call the 2 String constructor. as if you wrote new ArgumentOutOfRangeException ("param_name", "message")
So you have to do three things:
1. add a new enum value for the argument out of rang exception.
2. modify the mono_error_set_... function. you did this part already.
3. modify mono_error_prepare_exception to convert the MONO_ERROR_ARGUMENT_OUT_OF_RANGE case into a MonoException
I think you're off to a good start, please feel free to open a PR and we can revise it as you go. Folks in https://gitter.im/mono/mono should be able to help.
But seems it has been pretty late now, so I'll have to work on this issue tommorow.
So this is the first issue I encountered: (#8516)
Make dedicated MonoError for `mono_error_set_argument_out_of_range`
Although didn't know whether this issue is being resolved or not, this is one of the few which seems to be manageable to me, so I tried to look upon it.
Still, I tried to implement some function.
```c
void
mono_error_set_argument_out_of_range (MonoError *error, const char *param_name)
{
/* ORIGINAL IMPLEMENTATION
ERROR_DECL (error_creating_exception);
mono_error_set_exception_handle (error, mono_new_exception_argument_out_of_range (name, error_creating_exception));
mono_error_cleanup (error_creating_exception);
*/
mono_error_set_specific (error, MONO_ERROR_ARGUMENT_OUT_OF_RANGE, "MonoArgumentException:%s", param_name);
if (param_name)
mono_error_set_first_argument (error, param_name);
}
```I think I'll wait for OP of the issue to reply to me on Gitter.
UPDATE:
He replied:
Great questions.
So here's what's up with MonoError. It has basically two places where things happen to it - we allocate it at the border between managed .NET code and the C code that implements the runtime. Then we pass around MonoError* all through the C code. eventually something goes wrong and we call one of the mono_error_set_... functions. Then we thread the erroneous value back out to the callers of each function - up the call stack all the way back to the .NET/C border. There we call mono_error_prepare_exception to convert from the MonoError struct into a manage System.Exception instance.
In this case we want to create an ArgumentOutOfRangeException.
we want to call the 2 String constructor. as if you wrote new ArgumentOutOfRangeException ("param_name", "message")
So you have to do three things:
1. add a new enum value for the argument out of rang exception.
2. modify the mono_error_set_... function. you did this part already.
3. modify mono_error_prepare_exception to convert the MONO_ERROR_ARGUMENT_OUT_OF_RANGE case into a MonoException
I think you're off to a good start, please feel free to open a PR and we can revise it as you go. Folks in https://gitter.im/mono/mono should be able to help.
But seems it has been pretty late now, so I'll have to work on this issue tommorow.
Comments
Post a Comment