-
Notifications
You must be signed in to change notification settings - Fork 166
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
Introducing ASP.NET Layout Renderer base class #22
Introducing ASP.NET Layout Renderer base class #22
Conversation
Current coverage is
|
Looks really nice! No comments :) |
I'm going to need to take a dependency on a mocking library in order to mock HttpContext. I looked at NLog/NLog but we are not using one. Do you have any preference? |
Sorry about the delay. I prefer Moq, but I think NSubstitute is also fine. |
I'll do Moq then. Moq used to be my favorite but the simplicity of NSubstitute won me over. |
Well if NSubstitute is in your opinion is a lot easier to read/write, maybe that's a better choice. (because I prefer that also others can add unit tests easily) :) |
@304NotModified done with all the tasks. Let me know what you think. |
@@ -56,18 +56,14 @@ public class AspNetItemValueLayoutRenderer : LayoutRenderer | |||
/// </summary> | |||
/// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param> | |||
/// <param name="logEvent">Logging event.</param> | |||
protected override void Append(StringBuilder builder, LogEventInfo logEvent) | |||
protected override void DoAppend(StringBuilder builder, LogEventInfo logEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doubting if this is backwards-compatible when we create a subclass of AspNetItemValueLayoutRenderer. There are two cases:
1 ) override the full behavior: before override Append
. Now we need to override DoAppend
2) Call base.Append
- this still works, this has now also other behaviour
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but I dont see a backward-compatibility issue. Any subclass that calls base.Append will still experience the same behavior, the implementation changed but the behavior remains the same. If the subclass doesn't call base.Append then it is opting out of the base class behavior.
The DoAppend method is optional to override, but I would add to the docs that is the recommended way to write aspnet layout renderers that rely on the HttpContext since it makes the layout renderers more unit test friendly.
Impressive! Just one note about backwards-compatibility. Really good work! |
@304NotModified have u had time to review my comment on your concern about backward compatibility. |
@epignosisx will look at this now. Thanks for the reminder |
Introducing ASP.NET Layout Renderer base class
I made two examples, and indeed, both behave the same: private class AspNetSessionIDLayoutRenderer2 : AspNetSessionIDLayoutRenderer
{
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
{
builder.Append("before");
//before: AspNetSessionIDLayoutRenderer.append()
//after: AspNetLayoutRendererBase.append() -> AspNetSessionIDLayoutRenderer.DoAppend
base.Append(builder, logEvent);
builder.Append("after");
}
} private class AspNetSessionIDLayoutRenderer3 : AspNetSessionIDLayoutRenderer
{
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
{
builder.Append("fixed");
}
} I needed a double check, because of semver. |
This is an initial commit for #20. There is still more work to be done. I just wanted to share and get some initial feedback.
fixes #20