-
-
Notifications
You must be signed in to change notification settings - Fork 115
Context finder for strings that start with an html5 tag #220
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
* componentparametercollection * Support for passing multiple template and render fragments * Automated dotnet-format update * cascading values * Finished component parameter collection, closed #142, updated tests to component parameter factory * Fixed null warnings * Automated dotnet-format update * Fixes for CodeQL warnings * Added ChildContent and RenderFragment tests * Added support for passing template fragments * Removed ComponentParameterBuilder, added support for unmatched and cascading values * Switched to C# 9 compile * Automated dotnet-format update * unnamed cascading value with add * Removed .net move hack from workflows * Fix for null errors * Automated dotnet-format update * Added extra factory method and moved ComponentParameter out into Bunit namespace * Updated docs with new parameter passing logic * Automated dotnet-format update * Updated changelog Co-authored-by: Github Actions <[email protected]>
Codecov Report
@@ Coverage Diff @@
## dev #220 +/- ##
======================================
Coverage ? 79.17%
======================================
Files ? 103
Lines ? 3011
Branches ? 394
======================================
Hits ? 2384
Misses ? 498
Partials ? 129
Continue to review full report at Codecov.
|
FlorianRappl
left a comment
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 think this looks good.
As suggested, I would only create the document + elements locally and separate the parser instance from the document instance. Also I would go for the async variant. However, as it is it should also just work fine.
|
Huge thanks for the review. In all the cases where this is used in bUnit isnt async, so from that point of view it does not make sense to make the parse method async. I am not sure I follow your suggestion, can you share a link to some docs are a snippet that shows what you are thinking of? Last question. I would like to support parsing |
I am not sure which suggestion you mean. Locality means avoid having members, but just local references, e.g., public INodeList Parse(string markup)
{
var document = ...
var body = ...
return ParseInto(document, body, ..., markup); // just an example call, you could also make a local function and capture the variables above
}
For the given three tags I would not use a fragment, but rather full parsing. These are not fragments but (parts of) full documents. |
|
Ahh yes, that's what I meant. Is it purely esthetics that you prefer locality or is there also some internal AngleSharp reason not to reuse the "contexts"? Update: saw your other comment on the code, so I guess the answer is yes to the last part. |
If yes means "has functional consequences" then yes. You should always prefer locals over members. If that parser is reused you will be in deep trouble as there are already members on them. |
How so? The current version in main does the same thing, and that is typically scoped to a test, such that all parsing needs within a single test share the document. What kind of problems should this be causing? |
Again, if you reuse the parser you reuse the document you end up with unexpected results. This can cause all kinds of problems - usually you want that locality (it does not only help the GC, but it implies a more advanced development paradigm that avoids side-effects). I mean this discussion quite derailed right now. So I'd like to close it. If you want to have members - sure go ahead. All I am writing is that keeping local things local does help. It also helps thinking just in the context of one class (I don't want to look at uses of this class to understand if having members is acceptable or not - just avoiding it would be the way to go to prevent unnecessary cognitive load in the first place). |
That's fair. I am not pro one or the other, but I am trying to understand how AngleSharp works and how to use it correct in this regard. |
|
@FlorianRappl I did as you suggested and stopped reusing the context elements. Also have support for (code is a bit messy but I can refactor it later when my flu passes). |
|
Kudos, SonarCloud Quality Gate passed!
|
Pull request description
Fixes #198. This is an attempt to implement a automatic context detection if the string to be parsed by
BunitHtmlParserstarts with a HTML tag.PR meta checklist
DEVbranch.Content checklist