MrJul / ReSharper.EnhancedTooltip

A plugin for JetBrains Resharper that colorizes the tooltip and parameter information.
Apache License 2.0
173 stars 27 forks source link

Show full attribute application information (useful for e.g. JetBrains contract annotations) #26

Closed dsaf closed 7 years ago

dsaf commented 9 years ago

http://blog.jetbrains.com/dotnet/2012/08/15/contract-annotations-in-resharper-7

https://github.com/aspnet/EntityFramework/blob/dev/src/Shared/Check.cs

Code example:

    [ContractAnnotation("format: null => halt")]
    [StringFormatMethod("format")]
    [Pure]
    public static string FormatWith([NotNull] this string format, params object[] args)
    {
      Check.NotNull<string>(format, "format");
      return string.Format(format, args);
    }

    public string DoSampleUsage()
    {
        return "{0} knows Java better than {1}".FormatWith("Gilfoyle", "Dinesh");
    }

When hovering over the FormatWith usage it would be nice to show something like:

"(method) [ContractAnnotation("format: null => halt")] [StringFormatMethod("format")] [Pure] ...signature... "

Alternatively / additionally, treat JetBrain contracts specially:

"(method) [StringFormatMethod("format")] ...signature... pure format: null => halt"

MrJul commented 9 years ago

Currently JetBrains' annotations are already treated specially, these are the only attributes that are displayed inside the tooltips (if the "display annotations for identifiers" option is set to "display all")).

There's only the attribute name though, not full information, so I'm keeping this open.

dsaf commented 9 years ago

Yes, I turned that on. The presentation could be similar to that of possible exception (little gray box [Contract] and the arrow notation).

dsaf commented 9 years ago

Consider standard string.IsNullOrWhiteSpace(...) method. On mouse over it will say "(method) [ContractAnnotation, Pure] ..." Yet I don't know what that ContractAnnotation states and it could be anything. Furthermore because it is annotated externally even navigating to sources will not give me the information!

MrJul commented 9 years ago

Indeed. Quick doc displays full external annotations, but I understand that you don't like it :)

dsaf commented 9 years ago

I am afraid so. For example on my custom non-documented annotated method FormatWith I need to:

1) press Ctrl+Shift+F1 2) click on the attribute link to expand it

Also when I press "go to read more" it tries to find my absent documentation on MSDN. And last but not least: it's not colorful at all :).

dsaf commented 7 years ago

Thanks!

MrJul commented 7 years ago

You're welcome! Please try it in v3.0.1 for ReSharper 2017.1 EAP4.

dsaf commented 7 years ago

Looks like it works just fine in VS 2015:

image

Will try in VS 2017 soon as well.