-
Notifications
You must be signed in to change notification settings - Fork 805
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
No diagnostic when custom attributes ignored on unparenthesized tuple type #462
Comments
Bringing over some context from original issue at fsharp/fsharp:
When you add parens, the attributes do appear. If you open your assembly with ILDASM you will see the attributes created in the method if you use parens:
See http://stackoverflow.com/questions/30085515/getting-attribute-data-for-return-value-of-net-method for info on how to grab them via reflection. |
OK, I will not trust the dotnetfiddle IL anymore 😞
Thanks for pointing to an example including the MemberInfo.GetCustomAttributesData method. I was not yet aware of the differences with the MemberInfo.GetCustomAttributes method. |
@bbenoist I typically use ILSpy, which seems to have the same problem. It's smart enough to show the attributes in the "C# View", yet doesn't show them in the "IL View". ILDasm is very clunky, but at least it's accurate. |
type HelloTupleWithoutParentheses =
static member Format name :
[<ReturnParameterDescription("A string containing 'Hello <name>!'.")>]
[<ReturnParameterDescription("A string containing 'Goodbye <name>!'.")>]
string * string =
("Hello " + name + "!", "Goodbye " + name + "!") @brianrourkeboll Was wondering if wrapping the return type in extra parentheses during type checking when is a |
I wonder if it's a parsing thing here. Without parentheses around the type, the attributes aren't even colorized as attributes: It looks like bare tuple types get special handling, and it doesn't look like the example code ends up in the same place it would if the tuple type were parenthesized: Lines 5730 to 5731 in a9037f4
Lines 5747 to 5748 in a9037f4
Lines 5773 to 5774 in a9037f4
Line 5795 in a9037f4
Line 5822 in a9037f4
Lines 6024 to 6056 in a9037f4
|
Hello,
After hours struggling to retrieve the values of some custom attributes assigned to an F# method return type annotation, I have found an unexpected behavior and would like to know why it did not worked as I thought.
Suppose that you have an F# method which returns a tuple value:
Then, you code a custom attribute containing a string describing each tuple field:
If you apply it to the
Format
method:The following reflection will not return anything:
Whereas it works correctly when the tuple type annotation is surrounded by parentheses:
Does anyone knows why the first attempt does not returns the custom attributes?
Am I missing something? Is it a parser bug?
Full example of my problem (try it in your web browser):
The text was updated successfully, but these errors were encountered: