Is it possible to inherit comments in an abstract body method from BaseClass?
I have PersonBaseClass and EmployeeClass that derive from it. Now I would like to define the body of the method as a comment in the BaseClass, that when I use Resharper "Implement Items" (or manually implement them), it also puts it in the body of the method.
Something (roughly):
public abstract class PersonBaseClass : DependencyObject
{
//<methodComment>
// object connectionString;
// _configurations.TryGetValue("ConnectionString", out connectionString);
//</methodComment>
protected abstract void InstanceOnPersonChanged(object sender, EventArgs eventArgs);
}
It will be implemented like this:
public class EmployeeClass : PersonBaseClass
{
protected override void InstanceOnPersonChanged(object sender, EventArgs eventArgs)
{
// object connectionString;
// _configurations.TryGetValue("ConnectionString", out connectionString);
}
}
Is this already possible? Couldn't get this to work with GhostDoc .
Edit: Would be helpful as I want to have BaseClass in the library and its implementation usually looks the same every time.
source to share
Not exactly what you are asking, but you can pull comments using Ghostdoc for legacy members. Note that it will not add comments to the body of the derived class method, but it will add it to its comments section.
Suppose you have a class like this with a comment. Hey this is a great method :)
public abstract class PersonBaseClass
{
/// <summary>
/// Hey, this is great method :)
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="eventArgs">The <see cref="EventArgs" /> instance containing the event data.</param>
protected abstract void InstanceOnPersonChanged(object sender, EventArgs eventArgs);
}
Then you add a derived class and override a member like this
public class EmployeeClass : PersonBaseClass
{
protected override void InstanceOnPersonChanged(object sender, EventArgs eventArgs)
{
throw new NotImplementedException();
}
}
Then place the cursor inside the body of the derived class and press ctrl+ shift+ d. It will pull the comments from the base class.
And your derived class will look something like this after following the above step.
public class EmployeeClass : PersonBaseClass
{
/// <summary>
/// Hey, this is great method :)
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="eventArgs">The <see cref="EventArgs" /> instance containing the event data.</param>
/// <exception cref="System.NotImplementedException"></exception>
protected override void InstanceOnPersonChanged(object sender, EventArgs eventArgs)
{
throw new NotImplementedException();
}
}
source to share