Add BindingFlags.DoNotWrapExceptions - #7863
Conversation
|
Support for filter clauses is not perfect, it would be better to simply duplicate the body: |
|
I have update my pull request to not use exception filter clauses. |
|
approve |
There was a problem hiding this comment.
Please instead of changing this file replace it in corlib.dll.sources with the version from external/corefx/src/Common/src/CoreLib/System/Reflection/BindingFlags.cs
There was a problem hiding this comment.
Before this change RuntimeType called Activator.CreateInstance(Type type, bool nonPublic) when a constructor has no arguments. After this change I needed a way to propagate the DoNotWrapExceptions flag, so I added this internal overload.
There was a problem hiding this comment.
As it's used by CreateInstance only, it does have to be internal
|
approve |
|
I noticed that API Diff check failed because of the addition of the new flag. Is that something I should fix in this pull request? |
|
We'll take care of apidiff handling |
There was a problem hiding this comment.
You should do these 2 modifications to https://github.com/mono/mono/blob/master/mcs/class/corlib/corlib.dll.sources instead. This corlib-net_4_x.csproj is autogenerated from the mcs/class/corlib/*.sources files
There was a problem hiding this comment.
I have removed my changes from the generated csproj file.
For compatibility with dotnet/corefx#22866
|
@luhenry It appears that a bot periodically regenerates the csproj file so I have removed my changes to that file. Is that what you had in mind? |
|
@monojenkins commit apidiff |
|
@AustinWise yes we do regenerate periodically the csproj files from the |
The original design review is here: dotnet/corefx#22866 . To summarize, this adds a new flag to
BindingFlagscalledDoNotWrapExceptions. When this flag is used to invoke a method using reflection, any exceptions thrown are not wrapped with aTargetInvocationException.It has already been implemented in some other version of .NET:
I would be delighted if this handy feature was also available in Mono.
I have in part based my changes on the CoreCLR implementation. There all already tests for this feature in corefx, so I have added those to the corlib_xtest.dll.sources file.
I have a couple of concerns about my implementation:
DynamicMethod.Invokewas ignoring the BindingFlags and other arguments. I changed this method to pass along all the arguments. For what it's worth, it appears that CoreCLR respects these arguments.