Skip to content

Issue 20#21

Open
MichalFrends1 wants to merge 2 commits into
masterfrom
issue-20
Open

Issue 20#21
MichalFrends1 wants to merge 2 commits into
masterfrom
issue-20

Conversation

@MichalFrends1
Copy link
Copy Markdown

@MichalFrends1 MichalFrends1 commented Jan 13, 2025

Issue-20

Summary by CodeRabbit

  • New Features

    • Added support for .NET 6.0 alongside .NET Framework 4.5.2
    • Enhanced XML processing with framework-specific Saxon library implementations
  • Refactor

    • Modernized project configuration using SDK-style project files
    • Updated package references and dependencies
    • Modified internal method access modifiers for better encapsulation
  • Chores

    • Updated NuGet package versions
    • Added project metadata (version, authors, description)
    • Removed legacy package configuration files

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 13, 2025

Walkthrough

The pull request introduces a comprehensive modernization of the Frends.Xml project, focusing on multi-framework support and updated project configurations. The changes primarily involve migrating from traditional .NET Framework project structures to SDK-style project files, adding support for both .NET Framework 4.5.2 and .NET 6.0. The project files have been restructured to use PackageReference, remove legacy configuration, and add metadata. Additionally, the code has been updated to provide framework-specific implementations for XML processing and transformation methods.

Changes

File Change Summary
Frends.Xml.Tests/Frends.Xml.Tests.csproj - Migrated to SDK-style project format
- Added multi-framework support (net452, net6.0)
- Updated package references
- Removed legacy project configuration
Frends.Xml.Tests/packages.config - File completely removed
Frends.Xml/Definitions.cs - Changed Extensions class and methods from public to internal
Frends.Xml/Frends.Xml.csproj - Migrated to SDK-style project format
- Added multi-framework support (net452, net6.0)
- Added project metadata
- Updated package references for Saxon and Newtonsoft.Json
Frends.Xml/packages.config - File completely removed
Frends.Xml/Xml.cs - Added conditional compilation for .NET 6.0
- Introduced framework-specific methods for XPath queries and transformations
- Added new methods for SaxonCS and SaxonHE libraries

Sequence Diagram

sequenceDiagram
    participant Client
    participant XmlProcessor
    participant SaxonHE
    participant SaxonCS
    
    alt .NET Framework
    Client->>XmlProcessor: XPath Query/Transform
    XmlProcessor->>SaxonHE: Process XML
    SaxonHE-->>XmlProcessor: Return Results
    else .NET 6.0
    Client->>XmlProcessor: XPath Query/Transform
    XmlProcessor->>SaxonCS: Process XML
    SaxonCS-->>XmlProcessor: Return Results
    end
    XmlProcessor-->>Client: Return Results
Loading

Poem

🐰 A Rabbit's Ode to Framework Delight

From old .NET to SDK's embrace,
Frameworks dance with newfound grace,
Saxon's magic, JSON's might,
Compatibility shining bright!
Code evolves with playful leap 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@MichalFrends1 MichalFrends1 self-assigned this Jan 13, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
Frends.Xml/Definitions.cs (1)

Version management needs attention

The internal access modifier changes constitute breaking changes, but:

  • Current version in csproj (1.1.0) only indicates minor changes
  • No CHANGELOG.md exists to document the API changes
  • Nuspec file shows an outdated version (1.0.0.0)

Recommendations:

  • Bump version to 2.0.0 following semver for breaking changes
  • Create CHANGELOG.md to document the API surface changes
  • Sync version numbers between csproj and nuspec files
🔗 Analysis chain

Line range hint 97-116: Consider version management and documentation updates.

Since these access modifier changes are breaking changes:

  1. The package version should be bumped according to semantic versioning (major version increment)
  2. The changelog should document these API surface changes
  3. Migration guide should be provided for users who might be directly using these types

Let's check the version information:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for version information in project files and documentation
rg -l "version|Version" --type xml
cat */CHANGELOG.md 2>/dev/null || echo "No changelog found"

Length of output: 255


Script:

#!/bin/bash
# Search for project files and documentation
fd -e csproj -e props -e nuspec
fd -g "*.md" -g "*.txt"
# Check content of project files for version info
fd -e csproj -e props -e nuspec --exec cat {}

Length of output: 4837

🧹 Nitpick comments (8)
Frends.Xml.Tests/Frends.Xml.Tests.csproj (2)

3-11: Consider enabling GenerateAssemblyInfo for better maintainability

While the multi-targeting setup looks good, consider setting GenerateAssemblyInfo to true to leverage the SDK's built-in assembly metadata generation. This would help maintain version information more consistently across frameworks.

-		<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+		<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org


14-29: Simplify build configurations

The Debug and Release configuration blocks can be significantly simplified as many of these settings are already defaults in SDK-style projects.

Consider replacing both PropertyGroup blocks with:

-	<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
-		<DebugSymbols>true</DebugSymbols>
-		<DebugType>full</DebugType>
-		<Optimize>false</Optimize>
-		<OutputPath>bin\Debug\</OutputPath>
-		<DefineConstants>DEBUG;TRACE</DefineConstants>
-		<WarningLevel>4</WarningLevel>
-	</PropertyGroup>
-
-	<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
-		<DebugType>pdbonly</DebugType>
-		<Optimize>true</Optimize>
-		<OutputPath>bin\Release\</OutputPath>
-		<DefineConstants>TRACE</DefineConstants>
-		<WarningLevel>4</WarningLevel>
-	</PropertyGroup>
+	<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
+		<DefineConstants>DEBUG;TRACE</DefineConstants>
+	</PropertyGroup>
🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Frends.Xml/Frends.Xml.csproj (1)

11-19: Enable automatic assembly info generation.

Setting GenerateAssemblyInfo to false while defining assembly attributes in the PropertyGroup is contradictory. The SDK can automatically generate assembly info from these properties.

 <PropertyGroup>
-    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <Version>1.1.0</Version>
     <Authors>Frends</Authors>
🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Frends.Xml/Xml.cs (5)

28-35: Consider reducing code duplication in conditional methods

The XpathQuery method conditionally calls XpathQueryCS or XpathQueryHE based on the .NET version. This pattern is repeated in several places, leading to code duplication. To improve maintainability, consider abstracting the common logic into a shared method and parameterizing the framework-specific differences.


Line range hint 39-51: Refactor XpathQueryCS and XpathQueryHE to eliminate duplication

The methods XpathQueryCS and XpathQueryHE share almost identical logic, differing mainly in the namespaces (SaxonCS vs. SaxonHE). Refactoring these methods to use a common interface or delegate for the processor and selector can reduce duplication and simplify future maintenance.

Also applies to: 57-68


85-97: Eliminate duplicate code in XpathQuerySingleCS and XpathQuerySingleHE

Similar to the previous comment, XpathQuerySingleCS and XpathQuerySingleHE have overlapping code. Refactor these methods to share common logic, reducing duplication and potential for inconsistencies between framework implementations.

Also applies to: 100-113


124-160: Consolidate TransformWithSaxonCS and TransformWithSaxonHE methods

The TransformWithSaxonCS and TransformWithSaxonHE methods perform similar operations with minor differences in processor initialization and type references. Consider unifying these methods by abstracting the processor creation and type-specific operations, which will enhance maintainability and reduce code redundancy.

Also applies to: 167-204


266-298: Unify SetupXPathSelectorCS and SetupXPathSelectorHE methods

The SetupXPathSelectorCS and SetupXPathSelectorHE methods contain substantial duplicated code. To improve code maintainability, refactor these methods to a single method that handles both framework versions, possibly by abstracting the differences or using generics.

Also applies to: 302-334

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cec9f2 and 50b5a15.

📒 Files selected for processing (6)
  • Frends.Xml.Tests/Frends.Xml.Tests.csproj (1 hunks)
  • Frends.Xml.Tests/packages.config (0 hunks)
  • Frends.Xml/Definitions.cs (2 hunks)
  • Frends.Xml/Frends.Xml.csproj (1 hunks)
  • Frends.Xml/Xml.cs (8 hunks)
  • Frends.Xml/packages.config (0 hunks)
💤 Files with no reviewable changes (2)
  • Frends.Xml.Tests/packages.config
  • Frends.Xml/packages.config
🧰 Additional context used
🪛 GitHub Actions: PR #21
Frends.Xml.Tests/Frends.Xml.Tests.csproj

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Frends.Xml/Frends.Xml.csproj

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

🔇 Additional comments (8)
Frends.Xml.Tests/Frends.Xml.Tests.csproj (2)

43-46: LGTM! Test infrastructure packages are well configured

The test adapter and SDK versions are appropriate and will work well with both target frameworks.

🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org


49-51: LGTM! Project reference is correctly configured

The project reference to Frends.Xml is properly specified using the simplified SDK-style format.

🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Frends.Xml/Frends.Xml.csproj (2)

1-9: LGTM! Multi-targeting configuration is well structured.

The project setup correctly uses the SDK-style format and properly configures multi-targeting for both .NET Framework 4.5.2 and .NET 6.0.

🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org


41-41: Verify Newtonsoft.Json compatibility with .NET Framework 4.5.2.

While version 13.0.3 is the latest, we should verify its compatibility with .NET Framework 4.5.2.

✅ Verification successful

Newtonsoft.Json 13.0.3 is compatible with .NET Framework 4.5.2

Newtonsoft.Json 13.0.3 fully supports .NET Framework 4.5.2 and is correctly configured as a common dependency for both target frameworks (net452 and net6.0).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check package metadata for framework compatibility
curl -s https://api.nuget.org/v3/registration5-gz-semver2/newtonsoft.json/13.0.3.json | jq -r '.catalogEntry.dependencyGroups[].targetFramework'

Length of output: 204


Script:

#!/bin/bash
# Check project file for framework targeting and package references
cat Frends.Xml/Frends.Xml.csproj

# Search for any package config files
fd -e config -e nuspec -e props . Frends.Xml/

# Look for any compatibility warnings in build logs or documentation
rg -i "newtonsoft.*compatibility|framework.*requirement" -g "!{bin,obj}/*"

Length of output: 1868

🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Frends.Xml/Definitions.cs (2)

Line range hint 99-110: Methods are well-implemented but access changes may impact external users.

The implementation of both methods is robust:

  • GetJTokenFromXdmItem properly handles both atomic values and XML nodes
  • GetXmlOrAtomicObject correctly handles type conversion

The change to internal access is consistent with the class-level change.

Let's verify the usage of these methods:

Also applies to: 112-116

✅ Verification successful

Access modifier changes are safe and well-justified

The methods are only used internally within Definitions.cs for XML/JSON conversion implementation details. No external usage was found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any direct method calls to these methods
rg -A 2 "GetJTokenFromXdmItem|GetXmlOrAtomicObject" --type cs

Length of output: 1399


97-97: Access modifier change improves encapsulation but is a breaking change.

Changing the Extensions class from public to internal is a good practice for encapsulation as these methods appear to be implementation details. However, this is a breaking change that could affect external consumers if they were directly using this class.

Let's verify if there are any external dependencies on this class:

✅ Verification successful

The change to internal access modifier is safe and appropriate

The Extensions class contains internal utility methods for XML/JSON conversion and was never meant for external consumption, as evidenced by:

  • All its methods were already marked as internal
  • No external usage found in tests or other code
  • The class serves as an internal implementation detail for the public XML processing APIs
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any external references to the Extensions class
rg -l "Frends\.Xml\.Extensions" --type cs

Length of output: 43


Script:

#!/bin/bash
# First, let's find the Extensions class definition to see its methods
ast-grep --pattern 'class Extensions {
  $$$
}'

# Then search for any test files related to Frends.Xml
fd "test" -e cs --exec grep -l "Frends.Xml"

Length of output: 119


Script:

#!/bin/bash
# Check the test file content for any Extensions usage
cat "./Frends.Xml.Tests/Tests.cs"

# Also look for any public methods in the Extensions class
ast-grep --pattern 'internal static class Extensions {
  $$$
}'

Length of output: 16914

Frends.Xml/Xml.cs (2)

1-6: Confirm the necessity of including Frends.Saxon.Activation only for .NET 6.0

In the #if NET6_0_OR_GREATER block, you are importing Frends.Saxon.Activation, but it's not included in the #else block for earlier .NET versions. Ensure that this namespace is only required for .NET 6.0 or greater and that omitting it for older frameworks won't cause issues.


291-295: Review the handling of BaseUri in SetupXPathSelector methods

In SetupXPathSelectorCS, builder.BaseUri is set using DetectAndSetBaseUri(input.Xml), while in SetupXPathSelectorHE, it is set to new Uri("file://"). This inconsistency might lead to different behaviors between .NET versions. Verify that this difference is intentional and that it won't affect the XPath query execution.

Also applies to: 329-333

Comment on lines +32 to +40
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="3.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="3.13.3" />
</ItemGroup>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing Saxon activation package and verify NUnit version compatibility

  1. The pipeline is failing due to a missing Frends.Saxon.Activation package. This dependency needs to be added.
  2. Consider if NUnit 3.6.0 for .NET Framework 4.5.2 should be updated to a newer version that's still compatible with the framework.

Add the missing package and optionally update NUnit:

 	<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
 		<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
-		<PackageReference Include="NUnit" Version="3.6.0" />
+		<PackageReference Include="NUnit" Version="3.13.3" />
+		<PackageReference Include="Frends.Saxon.Activation" Version="[latest-compatible-version]" />
 	</ItemGroup>

 	<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
 		<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
 		<PackageReference Include="NUnit" Version="3.13.3" />
+		<PackageReference Include="Frends.Saxon.Activation" Version="[latest-compatible-version]" />
 	</ItemGroup>

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Comment on lines +30 to +37
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Frends.Saxon.Activation">
<Version>1.1.4</Version>
</PackageReference>
<PackageReference Include="SaxonCS">
<Version>12.5.0</Version>
</PackageReference>
</ItemGroup>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the missing package reference causing build failure.

The pipeline is failing because the package Frends.Saxon.Activation cannot be found on nuget.org. This needs to be addressed before the PR can be merged.

Options to resolve this:

  1. Verify if the package name is correct
  2. Check if the package needs to be published to nuget.org
  3. Consider using a different package or version that is available

Also, consider using the more concise package reference syntax:

 <PackageReference Include="Frends.Saxon.Activation">
-  <Version>1.1.4</Version>
+  Version="1.1.4"
 </PackageReference>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Frends.Saxon.Activation">
<Version>1.1.4</Version>
</PackageReference>
<PackageReference Include="SaxonCS">
<Version>12.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Frends.Saxon.Activation" Version="1.1.4" />
<PackageReference Include="SaxonCS">
<Version>12.5.0</Version>
</PackageReference>
</ItemGroup>
🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Comment on lines +21 to +23
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<DefineConstants>NET6_0</DefineConstants>
</PropertyGroup>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codebase verification

Remove unused custom framework constant

The custom NET6_0 constant defined in the project file is not used in the codebase. The code correctly uses the built-in NET6_0_OR_GREATER constant for conditional compilation. Remove the unnecessary PropertyGroup that defines this custom constant.

🔗 Analysis chain

Verify if custom framework constant is necessary.

Consider using the built-in NETCOREAPP or NET6_0 constants that are automatically defined by the SDK instead of defining custom constants.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the custom constant is actually used in the code
rg "NET6_0" --type cs

Length of output: 341

🧰 Tools
🪛 GitHub Actions: PR #21

[error] Unable to find package Frends.Saxon.Activation. No packages exist with this id in source(s): nuget.org

Comment thread Frends.Xml/Xml.cs
Comment on lines +338 to +345
if (xml.Contains("<!DOCTYPE") || xml.Contains("schemaLocation") || xml.Contains("noNamespaceSchemaLocation"))
{
var currentDir = Directory.GetCurrentDirectory();
return new Uri($"file:///{currentDir.Replace("\\", "/")}/");
}

return new Uri($"file:///{Directory.GetCurrentDirectory().Replace("\\", "/")}/"); ;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify the DetectAndSetBaseUri method

The DetectAndSetBaseUri method currently checks for certain substrings in the XML but ultimately returns the same result in both cases. You can simplify the method by removing the condition and directly returning the BaseUri, which improves readability without changing functionality.

Apply this diff to simplify the method:

-private static Uri DetectAndSetBaseUri(string xml)
-{
-    if (xml.Contains("<!DOCTYPE") || xml.Contains("schemaLocation") || xml.Contains("noNamespaceSchemaLocation"))
-    {
-        var currentDir = Directory.GetCurrentDirectory();
-        return new Uri($"file:///{currentDir.Replace("\\", "/")}/");
-    }
-
-    return new Uri($"file:///{Directory.GetCurrentDirectory().Replace("\\", "/")}/"); ;
-}
+private static Uri DetectAndSetBaseUri(string xml)
+{
+    var currentDir = Directory.GetCurrentDirectory();
+    return new Uri($"file:///{currentDir.Replace("\\", "/")}/");
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (xml.Contains("<!DOCTYPE") || xml.Contains("schemaLocation") || xml.Contains("noNamespaceSchemaLocation"))
{
var currentDir = Directory.GetCurrentDirectory();
return new Uri($"file:///{currentDir.Replace("\\", "/")}/");
}
return new Uri($"file:///{Directory.GetCurrentDirectory().Replace("\\", "/")}/"); ;
}
private static Uri DetectAndSetBaseUri(string xml)
{
var currentDir = Directory.GetCurrentDirectory();
return new Uri($"file:///{currentDir.Replace("\\", "/")}/");
}

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.

1 participant