-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add async implementations to the HtmlFormatter. #376
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
Conversation
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.
Do we need to maintain both the async and the sync methods? Would it be just enough to keep the async one?
public override void Write(char[] value) | ||
{ | ||
Write(value, 0, value.GetLength(0)); | ||
} | ||
|
||
public async Task WriteAsync(char[] value) |
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.
Based on the warning, this method should have been done anyway.
'JsonInHtmlWriter.WriteAsync(char[])' hides inherited member 'TextWriter.WriteAsync(char[])'. Use the new keyword if hiding was intended.
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.
Sorry, I was not clear with this one. This "override" is not necessary. The method in the base class is implemented in the same way, I think. So delete this method?
Your call. The only difference is the resulting version number. If sync is removed then it will be a major release, otherwise a minor. |
I put the [Obsolete] marker on the sync constructors. |
…set up the sync methods of the class.
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.
Some cosmetic things...
public override void Write(char[] value) | ||
{ | ||
Write(value, 0, value.GetLength(0)); | ||
} | ||
|
||
public async Task WriteAsync(char[] value) |
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.
Sorry, I was not clear with this one. This "override" is not necessary. The method in the base class is implemented in the same way, I think. So delete this method?
string html = await RenderAsHtmlAsync(); | ||
Assert.IsTrue(html.Contains("window.CUCUMBER_MESSAGES = [];")); | ||
} | ||
|
||
[TestMethod] | ||
public void ItThrowsWhenWritingAfterClose() |
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.
(GitHub didn't allow me to add this comment to line 69)
These tests (testing the sync) should be deleted or wrap the constructor call with pragmas to disable this warning explicitly, like
#pragma warning disable CS0618 // Type or member is obsolete
MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bytes, serializer);
#pragma warning restore CS0618 // Type or member is obsolete
Same for all other warnings in this file.
In general, the compilation should produce no warnings.
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've made both sets of changes per your requests.
I think this is ready to be merged, but I don't know why the javascript test is failing. Can someone take a look at that? |
Looks like that was already fixed on main. |
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.
Looks good. But a few remarks. I'll fix these right now.
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) | |||
and this project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
## [Unreleased] | |||
### Added |
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've changed this to added. It doesn't look like anything was removed. Is that correct w.r.t the guidance on http://semver.org?
public override void Write(char[] value) | ||
{ | ||
Write(value, 0, value.GetLength(0)); | ||
} | ||
|
||
//public async Task WriteAsync(char[] value) |
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.
Can be removed?
public MessagesToHtmlWriter(Stream stream, Action<StreamWriter, Envelope> streamSerializer) : this(new StreamWriter(stream), streamSerializer) | ||
{ | ||
} | ||
public MessagesToHtmlWriter(Stream stream, Func<StreamWriter, Envelope, Task> asyncStreamSerializer) : this(new StreamWriter(stream), asyncStreamSerializer) { } | ||
|
||
[Obsolete("Cucumber.HtmlFormatter moving to async only operations. Please use the MessagesToHtmlWriter(StreamWriter, Func<StreamWriter, Envelope, Task>) constructor", false)] |
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.
This looks like a deprecation. So this needs its own deprecated
entry in the changelog. This will inform the decision for the next version number.
And as a mental note, when removing the deprecated methods, please also mark the Atleast if I understood this all correctly: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/accessibility-levels |
@mpkorstanje Thanks for taking care of these items! |
🤔 What's changed?
Added async method implementations.
⚡️ What's your motivation?
Reqnroll will want to consume the async implementations in its implementation of Messages.
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.