1
How do I sync Interface with Concrete Implementations?
Question asked by Brett - 10/12/2021 at 5:53 AM
Unanswered
Hi,

I've seen that you can use GhostDoc to keep an implementation in sync with the interface, but I'm not finding that, when I generate documentation on the method, it generates fresh documentation, not based on the interface. Is there an option I need to enable?

17 Replies

Reply to Thread
0
Misha Zhutov Replied
Employee Post
Hi Brett, 

GhostDoc keeps inherited documentation by default. Could you please provide us with a code snippet or a sample project which reproduces the issue?
0
Brett Replied
Hey Misha,

I've realised it's a bug with asyncs.

Take this example:
interface ITest{

        /// <summary>
        /// Test Message.
        /// </summary>
        /// <returns>A Task representing the asynchronous operation.</returns>
        Task Test();

}
This code won't get the documentation inherited:

class Test : ITest{

public async Task Test(){
 return Task.CompletedTask();
}

}

But this code will:
class Test : ITest{

public Task Test(){
 return Task.CompletedTask();
}

}
Note the only change is the addition and deletion of the async keyword, which obviously isn't valid in the interface itself, but is on the concrete implementation.

Hope that helps,
Brett
0
Misha Zhutov Replied
Employee Post
Hi Brett, 

What GhostDoc version are you using? We cannot reproduce the issue using the GhostDoc Community v2021.2.21150.
0
Brett Replied
I'm using the trial of GhostDoc Pro at the moment (considering purchasing), version 2021.2.21150

I've just tried again and it's still doing it for me, if I remove the async keyword then press Ctrl + Shift + D, in the popup I get the "Test Message", if I put async back in and do it again, I get a generated message, not the message from the interface.
0
Misha Zhutov Replied
Employee Post
I attached the sample project we tried that. Please download and try to reproduce the issue on it.
0
Rick Mathers Replied
Misha,
Not sure if this was ever resolved, but on build 2021.2.21305 I experience the same thing.
I have found that as long as I document the concrete method before adding the async to it, it will inherit; if I add async before documenting, it gives a documentation that is different.
0
Misha Zhutov Replied
Employee Post
Hi Rick, 

Please download and install the latest GhostDoc build v22.1.22055 from https://submain.com/download/ghostdoc/pro/

0
Rick Mathers Replied
Misha,
I am still experiencing this issue with async keyword.  I am on version 2022.2.22190

Thanks,
Rick
0
Misha Zhutov Replied
Employee Post
Hi Rick,
What kind of issue did you experience? Can you provide us with a code snippet.
GhostDoc was tested and worked with "async" issue reported in this thread.

0
Rick Mathers Replied
Misha, 
I was going to upload a video; however, kept getting an error: "No user detected".  This is a result of an upload or screenshot upload on this form.

Here is a link to the video showing the interface and concrete class (it expires 11/4/22): https://1drv.ms/v/s!Agx_vwsGlArynYByjWinsokuq8pGCQ?e=6gB1oP
0
Misha Zhutov Replied
Employee Post
Hi Rick, 

Could you please explain what was the issue with "async"? We watched the video and did not find any problem because both:

public async Task<bool> TestResultAsync()
and

public Task<bool> TestResultAsync()
declarations implemented the interface and inherited the summary from it.



0
Rick Mathers Replied
Please note that starting at the 6 second mark, I highlight some the text produced on the class.  If you read it carefully; you will notice it is not the same as the highlighted text from the interface.

When using the async in the class:
The interface reads: "This is a test result"
The class reads: "Test result"

Without the async they are both the same.
0
Misha Zhutov Replied
Employee Post
We cannot reproduce the issue. We attached the sample project, please try it out and tell us if you experience the problem with it.
0
Rick Mathers Replied
Yours worked on mine too.
I found what appears to be the difference.
The "Async" at the end of the method name. I did a test with and without and the one with produced invalid results. The one without produced proper results.

TestResult() vs TestResultAsync()
0
Misha Zhutov Replied
Employee Post
You can change the Method Template in the Tools->GhostDoc Pro->Options->Rules->Method Template. Please find the GenerateSummaryText method and comment on the following lines:

else if(IsAsyncMethod())
{
        this.WriteLine(Context.ExecMacro("$(MethodName.Words.ExceptLastPascalCase)") + " as an asynchronous operation.");
}
or move that code under the

else if(!Context.CurrentCodeElement.IsNew && Context.HasInheritedTagText("summary"))
{
        this.WriteLine(Context.GetInheritedTagText("summary"));
}
0
Rick Mathers Replied
I can confirm that moving the "IsAsyncMethod" has fixed my issue.
Thank you for the help.
0
Misha Zhutov Replied
Employee Post
Hi Rick,

Thank you for the update.

Reply to Thread