Skip to content
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

Support namespaces #176

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open

Support namespaces #176

wants to merge 49 commits into from

Conversation

aveXcaesar
Copy link
Contributor

@aveXcaesar aveXcaesar commented Dec 22, 2021

Please check if the PR fulfills these requirements

  • I made sure that my code builds
  • I merged the master into this branch before pushing
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?** (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

closes #173
closes #177

What is the new behavior?

  • Updated NsDirective
  • Updated XPathDirective
  • Injectable namespace resolver in Directives
  • new XmlResolverFromDocument that can resolve namespaces from given XML

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications

Other information

@codecov
Copy link

codecov bot commented Dec 22, 2021

Codecov Report

Attention: Patch coverage is 78.06604% with 93 lines in your changes are missing coverage. Please review.

Project coverage is 63.56%. Comparing base (99c5d85) to head (30ef201).

❗ Current head 30ef201 differs from pull request most recent head a4ba3e9. Consider uploading reports for the commit a4ba3e9 to get more accurate results

Files Patch % Lines
src/Yaapii.Xambly/ThreadSafeCollection.cs 5.88% 16 Missing ⚠️
src/Yaapii.Xambly/Xambler/Xambler.cs 53.57% 13 Missing ⚠️
src/Yaapii.Xambly/Directive/XpathDirective.cs 77.08% 11 Missing ⚠️
src/Yaapii.Xambly/Directive/StrictDirective.cs 41.17% 2 Missing and 8 partials ⚠️
src/Yaapii.Xambly/Directive/Directives.cs 65.21% 8 Missing ⚠️
src/Yaapii.Xambly/Arg/Symbol.cs 0.00% 7 Missing ⚠️
src/Yaapii.Xambly/Directive/PiDirective.cs 14.28% 6 Missing ⚠️
src/Yaapii.Xambly/Directive/CopyOfDirective.cs 54.54% 4 Missing and 1 partial ⚠️
src/Yaapii.Xambly/Directive/NsDirective.cs 96.32% 4 Missing and 1 partial ⚠️
src/Yaapii.Xambly/Arg/ElementEscaped.cs 0.00% 4 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff            @@
##           main     #176       +/-   ##
=========================================
+ Coverage      0   63.56%   +63.56%     
=========================================
  Files         0       39       +39     
  Lines         0     1213     +1213     
  Branches      0      107      +107     
=========================================
+ Hits          0      771      +771     
- Misses        0      414      +414     
- Partials      0       28       +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aveXcaesar aveXcaesar marked this pull request as ready for review December 22, 2021 15:34
@Meerownymous Meerownymous self-assigned this Jan 3, 2022
@Meerownymous Meerownymous self-requested a review January 3, 2022 08:31
Copy link
Contributor

@Meerownymous Meerownymous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against changing the interface for this. Isn't there a way without introducing a breaking change?

@Meerownymous
Copy link
Contributor

Rejecting breaking change

@Meerownymous
Copy link
Contributor

Meerownymous commented Jan 11, 2022

@aveXcaesar There is a simple solution. The namespaceresolver can be built when needed by obtaining the namespaces from the document node.
Then it is not necessary to make the breaking change.

@aveXcaesar
Copy link
Contributor Author

@Meerownymous
Thanks for the hint. I will have a look later due to heavy work load

@Meerownymous
Copy link
Contributor

Consider this for building the manager on-the-fly

            foreach (var attribute in
                new Filtered<XAttribute>(
                    att => att.IsNamespaceDeclaration,
                    ((XElement)doc.FirstNode).Attributes()
                )
            )
            {
                if (attribute.Name == "xmlns")
                {
                    mgr.AddNamespace("def", attribute.Value);
                }
                else
                {
                    mgr.AddNamespace(attribute.Name.LocalName, attribute.Value);
                }
            }

@aveXcaesar aveXcaesar requested a review from Meerownymous March 3, 2022 18:49
@aveXcaesar
Copy link
Contributor Author

@Meerownymous
Refactoring done on the basis of your suggestion

@HerickJ-22
Copy link
Collaborator

HerickJ-22 commented Mar 31, 2022

Next time please split the PR into two. One with the feature and one with the refactoring eg. the added this, styling and indentations. That makes the pr smaller and a lot easier to review

using Xunit;
using Yaapii.Atoms.Enumerable;
using Yaapii.Atoms.Text;

namespace Yaapii.Xambly.Directive.Tests
{
public sealed class CopyOfDirectiveTests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for the CopyOfDirective so it also works with namespaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen it. You are right and I think there is something to do...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HerickJ-22
I would like to split the CopyOfDirective to another branch a create an new issue. Do you agree?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #192

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is a good idea! But I think we should not merge and not publish this PR bevore the issue #192 is resolved.

@aveXcaesar aveXcaesar removed the WIP Work in progress label Apr 9, 2024
@jaanpeeter
Copy link

Wer merged hier eigentlich @HerickJ-22

@HerickJ-22
Copy link
Collaborator

@jaanpeeter I am merging in this Repo, but there is still an open discussion when this pr is going to be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement NsDirective Querying XPath with namespace fails
4 participants