Skip to content

Move XSD manifest retrieval into dedicated SlnxXsdProvider class with interface#36

Merged
304NotModified merged 3 commits intomainfrom
copilot/move-manifest-retrieval-to-class
Mar 12, 2026
Merged

Move XSD manifest retrieval into dedicated SlnxXsdProvider class with interface#36
304NotModified merged 3 commits intomainfrom
copilot/move-manifest-retrieval-to-class

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

XsdValidator was directly responsible for both locating the embedded XSD resource and performing validation — mixing resource lookup with validation logic.

Changes

  • New ISlnxXsdProvider — interface defining the GetXsdStream() contract
  • New SlnxXsdProvider — implements ISlnxXsdProvider; extracts the const XsdResourceName and GetXsdStream() (wrapping Assembly.GetManifestResourceStream) into its own class
  • XsdValidator — now accepts ISlnxXsdProvider as a constructor dependency; delegates resource loading entirely to it
  • DI registrationISlnxXsdProvider registered as singleton mapping to SlnxXsdProvider in ServiceCollectionExtensions
  • Tests — updated call sites to supply new SlnxXsdProvider() when constructing XsdValidator directly
// Before — resource retrieval embedded in XsdValidator
private const string XsdResourceName = "JulianVerdurmen.SlnxValidator.Slnx.xsd";

await using var xsdStream = Assembly
    .GetExecutingAssembly()
    .GetManifestResourceStream(XsdResourceName) ?? throw new InvalidOperationException("XSD file not found");

// After — delegated via ISlnxXsdProvider
public interface ISlnxXsdProvider
{
    Stream GetXsdStream();
}

public sealed class SlnxXsdProvider : ISlnxXsdProvider
{
    private const string XsdResourceName = "JulianVerdurmen.SlnxValidator.Slnx.xsd";

    public Stream GetXsdStream() =>
        Assembly.GetExecutingAssembly()
            .GetManifestResourceStream(XsdResourceName)
            ?? throw new InvalidOperationException($"XSD resource '{XsdResourceName}' not found in assembly");
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor manifest retrieval into separate class Move XSD manifest retrieval into dedicated SlnxXsdProvider class Mar 11, 2026
@304NotModified 304NotModified marked this pull request as ready for review March 12, 2026 04:21
@304NotModified 304NotModified enabled auto-merge (squash) March 12, 2026 04:21
@304NotModified 304NotModified disabled auto-merge March 12, 2026 04:22
@304NotModified
Copy link
Owner

@copilot create also an interface and use that one

…stration

Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot create also an interface and use that one

Done in e08b310. Added ISlnxXsdProvider interface, SlnxXsdProvider now implements it, XsdValidator depends on the interface, and DI registers ISlnxXsdProvider → SlnxXsdProvider.

Copilot AI changed the title Move XSD manifest retrieval into dedicated SlnxXsdProvider class Move XSD manifest retrieval into dedicated SlnxXsdProvider class with interface Mar 12, 2026
@304NotModified 304NotModified force-pushed the copilot/move-manifest-retrieval-to-class branch from a4651c1 to e08b310 Compare March 12, 2026 16:37
@304NotModified 304NotModified enabled auto-merge (squash) March 12, 2026 16:38
@304NotModified 304NotModified merged commit 2747fcb into main Mar 12, 2026
7 checks passed
@304NotModified 304NotModified deleted the copilot/move-manifest-retrieval-to-class branch March 12, 2026 16:39
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.

2 participants