Skip to content

Separate adapted libraries. - #30

Merged
bitai-cs merged 2 commits into
mainfrom
update/20250720-separate-novel
Jul 21, 2026
Merged

Separate adapted libraries.#30
bitai-cs merged 2 commits into
mainfrom
update/20250720-separate-novel

Conversation

@bitai-cs

@bitai-cs bitai-cs commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Assign the adapted Novell LDAP and LDAPHelperMock libraries to their own source code folders.

Summary by Sourcery

Separate LDAP adapter abstractions and concrete implementations into dedicated libraries and update documentation and tooling to reflect the new adapter-based architecture.

New Features:

  • Introduce a standalone Bitai.LDAPHelper.LdapAdapters abstraction package defining LDAP connection, search, entry, attribute, and modification interfaces and enums.
  • Add concrete adapter libraries for Novell-based production LDAP (Bitai.LDAPHelper.LdapAdapters.Novell) and in-memory mock LDAP (Bitai.LDAPHelper.LdapAdapters.LdapHelperMock) to be consumed by the core helper and demos.

Enhancements:

  • Refine the root Bitai.LDAPHelper README with detailed architecture, adapter infrastructure description, usage scenarios, and troubleshooting guidance.
  • Update the demo application and test suite to use the new mock adapter library and namespaces instead of the previous test-only mock implementations.
  • Switch solution configuration to the new .slnx format and adjust project structure to place adapters under a dedicated adapters folder.

Build:

  • Add new project files for the Novell and LdapHelperMock adapter libraries and wire them into the solution and build pipeline.

Documentation:

  • Add dedicated READMEs for the Novell and LdapHelperMock adapter libraries describing their roles, architecture, usage, and build instructions.
  • Document the LDAP adapter interfaces in Bitai.LDAPHelper.LdapAdapters with a focused README explaining their purpose and how to implement custom providers.
  • Introduce GitHub agent documentation files for .NET/C# expertise, Serilog logging guidance, and README authoring standards.

Tests:

  • Remove the legacy Bitai.LDAPHelper.Tests.Mocks project in favor of the new adapter-based mock implementation and update existing tests to reference Bitai.LDAPHelper.LdapAdapters.LdapHelperMock.

@sourcery-ai

sourcery-ai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors the LDAP adapter architecture by introducing a shared adapter contracts package, splitting Novell and mock adapters into dedicated adapter projects with new namespaces and documentation, and modernizing the root README and solution structure around these adapters.

File-Level Changes

Change Details Files
Introduce a formal LDAP adapter contracts layer consumed by both Novell and mock adapter implementations.
  • Add Bitai.LDAPHelper.LdapAdapters interfaces for connections, entries, attributes, search constraints, search queues, messages, modifications, and connection info.
  • Define shared enums for LDAP modification types and search scopes.
  • Document the adapter contracts purpose and usage in a new LdapAdapters README.
src/Bitai.LDAPHelper/LdapAdapters/README.md
src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionFactoryAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapEntryAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapAttributeSetAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapAttributeAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ISearchLimits.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapSearchConstraintsAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapSearchQueueAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapMessageAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapModificationAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/IConnectionInfo.cs
src/Bitai.LDAPHelper/LdapAdapters/Enums.cs
Promote mock LDAP adapter implementations from the test project into a dedicated adapter library with updated namespaces and new documentation.
  • Move MockLdap* adapter and data store/seeder classes from the tests mocks project into an adapters folder targeting production-style usage for testing and demos.
  • Rename namespaces from Bitai.LDAPHelper.Tests.Mocks.* to Bitai.LDAPHelper.LdapAdapters.LdapHelperMock.* consistently across moved classes and test references.
  • Add a new README describing the LdapHelperMock adapter library, its architecture, usage scenarios, and seeding infrastructure.
  • Update demo and test projects to consume the new LdapHelperMock adapter namespaces instead of the old tests mocks namespace.
  • Create a new adapter project file for the LdapHelperMock package.
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock.csproj
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/README.md
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/LdapData/MockLdapDataStore.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/LdapData/MockLdapDataSeeder.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapAttributeAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapAttributeSetAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapConnectionAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapConnectionFactoryAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapEntryAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapMessageAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapModificationAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapPersistentConnectionAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapPersistentConnectionFactoryAdapter.cs
adapters/Bitai.LDAPHelper.LdapAdapters.LdapHelperMock/MockLdapSearchQueueAdapter.cs
demo/Bitai.LDAPHelper.Demo/Program.cs
tests/Bitai.LDAPHelper.Tests/AccountManagerAdapterTests.cs
tests/Bitai.LDAPHelper.Tests/AuthenticatorAdapterTests.cs
tests/Bitai.LDAPHelper.Tests/BaseTests.cs
tests/Bitai.LDAPHelper.Tests/GroupMembershipValidatorTests.cs
tests/Bitai.LDAPHelper.Tests/SearcherAdapterTests.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapAdapters/*.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapData/*.cs
tests/Bitai.LDAPHelper.Tests.Mocks/Bitai.LDAPHelper.Tests.Mocks.csproj
Create a dedicated Novell adapter project and documentation to formalize the production LDAP implementation.
  • Add a Novell-specific adapter project file that references the core helper library and Novell.Directory.Ldap.NETStandard.
  • Introduce a README describing the Novell adapter’s role, mapping to native Novell types, usage examples, and troubleshooting guidance.
  • Add an MIT license file for the Novell adapter package.
adapters/Bitai.LDAPHelper.LdapAdapters.Novell/Bitai.LDAPHelper.LdapAdapters.Novell.csproj
adapters/Bitai.LDAPHelper.LdapAdapters.Novell/README.md
adapters/Bitai.LDAPHelper.LdapAdapters.Novell/LICENSE.md
Revise the root README to reflect the new adapter-based architecture, project structure, and usage guidance.
  • Replace the previous high-level README content with a more detailed architecture-focused document oriented around adapter infrastructure, solution layout, and core modules.
  • Update references to the Novell and mock adapters to point at their new adapter projects and namespaces.
  • Enhance quick start, usage scenarios, demo configuration, build/test/pack instructions, troubleshooting, and security guidance sections.
README.md
Add GitHub agent configuration files to standardize documentation and .NET development guidance, and introduce a new solution file format.
  • Add .github agent markdown files describing a .NET C# expert, a Serilog logging expert, and a README specialist to assist automated tooling or AI agents.
  • Add a new solution file Bitai.Ldap.Helper.slnx and remove the older .sln and ancillary PowerShell clean script.
  • Align project references (demo, src, tests) with the new adapter projects where necessary.
.github/agents/CSharpExpert.agent.md
.github/agents/NETSerilogLoggerExpert.agent.md
.github/agents/READMESpecialist.agent.md
Bitai.Ldap.Helper.slnx
Bitai.Ldap.Helper.sln
Clean Bin & Obj folders.ps1
demo/Bitai.LDAPHelper.Demo/Bitai.LDAPHelper.Demo.csproj
src/Bitai.LDAPHelper/Bitai.LDAPHelper.csproj
tests/Bitai.LDAPHelper.Tests/Bitai.LDAPHelper.Tests.csproj

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 3 issues, and left some high level feedback:

  • Exposing ServerCertificateValidationByPass() on the core ILdapConnectionAdapter contract forces all implementations (including mocks) to support a potentially unsafe operation; consider moving this to a provider-specific extension or separate interface so that the abstraction doesn’t encourage certificate bypass in general use.
  • Replacing the .sln with .slnx only may break tooling for environments that don’t yet understand the new format; consider keeping the original Bitai.Ldap.Helper.sln alongside the new solution or clearly documenting the required tooling/SDK version for .slnx usage.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Exposing `ServerCertificateValidationByPass()` on the core `ILdapConnectionAdapter` contract forces all implementations (including mocks) to support a potentially unsafe operation; consider moving this to a provider-specific extension or separate interface so that the abstraction doesn’t encourage certificate bypass in general use.
- Replacing the `.sln` with `.slnx` only may break tooling for environments that don’t yet understand the new format; consider keeping the original `Bitai.Ldap.Helper.sln` alongside the new solution or clearly documenting the required tooling/SDK version for `.slnx` usage.

## Individual Comments

### Comment 1
<location path="src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionAdapter.cs" line_range="15-20" />
<code_context>
+
+    public interface ILdapConnectionAdapter : IDisposable
+    {
+        int ConnectionTimeout { get; set; }
+        bool SecureSocketLayer { get; set; }
+        bool IsBound { get; }
+        
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Connection timeout units differ from IConnectionInfo, which may cause confusion and subtle bugs.

In `ILdapConnectionAdapter`, `ConnectionTimeout` is an `int` in milliseconds, while `IConnectionInfo` uses a `short` in seconds. This discrepancy can lead to incorrect conversions or loss of precision when mapping between them. Please either standardize the unit across both interfaces or make the unit explicit in the property names (e.g., `ConnectionTimeoutMs` / `ConnectionTimeoutSeconds`).

Suggested implementation:

```csharp
namespace Bitai.LDAPHelper.LdapAdapters;

/// <summary>
/// Defines the operations required to manage and use an LDAP connection.
/// </summary>
public interface ILdapConnectionAdapter : IDisposable
{
    /// <summary>
    /// Gets or sets the connection timeout in seconds.
    /// This property uses the same unit and underlying type as <c>IConnectionInfo.ConnectionTimeout</c>
    /// to avoid confusion and conversion issues.
    /// </summary>
    short ConnectionTimeoutSeconds { get; set; }

```

1. Update all implementations of `ILdapConnectionAdapter` to replace the old `ConnectionTimeout` property (milliseconds) with the new `short ConnectionTimeoutSeconds` property, including backing fields and any related logic.
2. Adjust any mapping code between `IConnectionInfo` and `ILdapConnectionAdapter` to use `ConnectionTimeoutSeconds` directly without converting units.
3. Fix any consumers that still expect a millisecond-based timeout; if millisecond precision is needed in some places, compute it locally via `TimeSpan.FromSeconds(ConnectionTimeoutSeconds)` or `ConnectionTimeoutSeconds * 1000`.
4. If the old `ConnectionTimeout` property was public and already in use, consider marking it as obsolete (with `[Obsolete]`) or removing it entirely, depending on your versioning and compatibility requirements.
</issue_to_address>

### Comment 2
<location path="src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionAdapter.cs" line_range="31" />
<code_context>
+    /// Bypasses server certificate validation.
+    /// </summary>
+    /// <remarks>Use only in controlled environments.</remarks>
+    void ServerCertificateValidationByPass(); 
+
+    /// <summary>
</code_context>
<issue_to_address>
**🚨 issue (security):** The `ServerCertificateValidationByPass` method name contains a typo and suggests potentially risky behavior.

Beyond the minor typo (`ByPass` → `Bypass`), exposing an API that disables certificate validation is inherently risky. To reduce misuse, consider renaming it to something clearly test-only (e.g., `DisableServerCertificateValidationForTesting`) and/or limiting it to internal or test-only usage so it’s not available in production contexts.
</issue_to_address>

### Comment 3
<location path="adapters/Bitai.LDAPHelper.LdapAdapters.Novell/README.md" line_range="156" />
<code_context>
+using Bitai.LDAPHelper.DTO;
+using Bitai.LDAPHelper.LdapAdapters.Novell;
+
+// 1. Instanciate the Novell connection factory
+var connectionFactory = new NovellLdapConnectionFactoryAdapter();
+
</code_context>
<issue_to_address>
**issue (typo):** Correct spelling of "Instanciate" to "Instantiate" in the quick start comment.

In the quick start comment, correct "Instanciate" to "Instantiate" to fix the typo.

Suggested implementation:

```
# 1. Instantiate the Novell connection factory

```

If this comment appears inside a C# code block in the README (e.g., between ```csharp and ```), keep it as a C# comment and only fix the spelling:

<<<<<<< SEARCH
// 1. Instanciate the Novell connection factory
=======
 // 1. Instantiate the Novell connection factory
>>>>>>> REPLACE

Adjust the exact formatting (markdown heading vs C# comment, leading spaces) to match the surrounding README style you are using for the quick start section.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionAdapter.cs
Comment thread src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionAdapter.cs
Comment thread adapters/Bitai.LDAPHelper.LdapAdapters.Novell/README.md
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