External Annotations on Delegate (Common.Logging)

Hi,

I am working on creating an External Annotations xml for the Common.Logging framework.

It's nearly identical to log4net so I have all the base "format" methods working already.

example:

<?xml version="1.0" encoding="utf-8"?>
<assembly name="Common.Logging.Core">
  <member name="M:Common.Logging.ILog.DebugFormat(System.String,System.Object[])">
    <attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)"><argument>format</argument></attribute>
  </member>
  <member name="M:Common.Logging.ILog.DebugFormat(System.String,System.Exception,System.Object[])">
    <attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)"><argument>format</argument></attribute>
  </member>
  <member name="M:Common.Logging.ILog.DebugFormat(System.IFormatProvider,System.String,System.Object[])">
    <attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)"><argument>format</argument></attribute>
  </member>
  <member name="M:Common.Logging.ILog.DebugFormat(System.IFormatProvider,System.String,System.Exception,System.Object[])">
    <attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)"><argument>format</argument></attribute>
  </member>
</assembly>


My problem comes in with some methods with delegate arguments. I haven't been able to figure out the correct xml to get the delegate methods working, and I haven't found a good way to troubleshoot without trial and error.

The methods in the dll look like:

DLL: Common.Logging.Core.dll

namespace Common.Logging
{
  public interface ILog
  {
    void Trace(Action<FormatMessageHandler> formatMessageCallback);
    void Debug(Action<FormatMessageHandler> formatMessageCallback);
    void Info(Action<FormatMessageHandler> formatMessageCallback);
    void Warn(Action<FormatMessageHandler> formatMessageCallback);
    void Error(Action<FormatMessageHandler> formatMessageCallback);
    void Fatal(Action<FormatMessageHandler> formatMessageCallback);
  }

  public delegate string FormatMessageHandler(string format, params object[] args);
}


In my xml I added this to the aboving working code, but it still isn't giving the syntax highlighting for the format string.

<member name="M:Common.Logging.FormatMessageHandler(System.String,System.Object[])">
  <attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)"><argument>format</argument></attribute>
</member>



Also, I created an equivalent method in code to see how it behaves

[JetBrains.Annotations.StringFormatMethod("format")]
public delegate string FormatMessageHandler(string format, params object[] args);


and it gave me the expected syntax highlighting, so I think I'm on the right track.


I would appreciate any help that anyone could give me. If I can get it figured out I think I'll create a plugin out of it to share with anyone else using this logging framework (an to make it easy on myself to import later :)).

Thanks in advance,
Ken

2 comments
Comment actions Permalink

You need to use "T:JetBrains.ReSharper.Plugins.PresentationAssistant.FormatMessageHandler" to specify the delegate - note the "T:". The prefix is used to distinguish the type of the member or type declaration you're describing. They're documented here: https://msdn.microsoft.com/en-us/library/fsbx0t7x.aspx

As a shortcut, you can put the text caret on the name of the type (FormatMessageHander) and select ReSharper → Edit → Copy XML-Doc ID to Clipboard. This will copy the fully qualified name, with the correct prefix applied, to the clipboard, ready to be pasted into an external annotations file.

0
Comment actions Permalink

That was it Matt, works perfect now!

Ty for you help and for letting me know about the "Copy XML-Doc ID to Clipboard" shortcut.

For anyone else who may need this in the future, my final xml for this looked like:

<member name="T:Common.Logging.FormatMessageHandler">
  <attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)"><argument>format</argument></attribute>
</member>

0

Please sign in to leave a comment.