-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Unable to specify interface type to GetCustomAttributes #7190
Comments
It looks like the desktop has a mismatch in behavior between
and
(This is probably because CustomAttributeExtensions.GetCustomAttribute() is statically defined to return IEnumerable rather than object[], so it has to ensure everything that passes the filter is assignable to Attribute.) On the desktop, the C# expression "ti.GetCustomAttributes()" resolves to MemberInfo.GetCustomAttributes(). On .NetCore 1.0, MemberInfo.GetCustomAttributes() doesn't exist, so the expression "ti.GetCustomAttributes()" resolves to the more restrictive CustomAttributeExtensions version. With .NS2.0, MemberInfo.GetCustomAttributes() is returning, so this won't be such a problem. However, as part of investigating this, I realized that corert gets MemberInfo.GetCustomAttribute() wrong so there's an issue to fix there. |
With .NS2.0, MemberInfo.GetCustomAttributes() is returning, so this won't be such a problem. |
Looking at dotnet#7190, the .NET Core behavior here is strange and my changes in dotnet@0844cb7a6152 with the type checking may have been a mistake. I think this should be fine with the interface special-casing, but if deemed too great a concern I can revert that subset of my old changes. Additionally, if people come up with other scenarios where this might fail, I'll just revert until we can migrate to use a shared CustomAttribute implementation rather than try to play whack-a-mole.
…33942) Looking at #7190, the .NET Core behavior here is strange and my changes in 0844cb7a6152 with the type checking may have been a mistake. I think this should be fine with the interface special-casing, but if deemed too great a concern I can revert that subset of my old changes. Additionally, if people come up with other scenarios where this might fail, I'll just revert until we can migrate to use a shared CustomAttribute implementation rather than try to play whack-a-mole.
On the full framework, WCF looks for any attributes declared on a type where the attribute type derives from IServiceBehavior. This works on the full framework, but on .Net Core an
ArgumentException
is thrown with the message "Type passed in must be derived from System.Attribute or System.Attribute itself." Here is a simple repro which runs to completion on the full framework but throws on .Net Core.The text was updated successfully, but these errors were encountered: