Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 2, 2025

This PR addresses critical limitations in the OpNode namespace, prefix, and suffix functionality by replacing hardcoded validation with XML-compliant rules and consolidating all tests into the OpNodeTest3 project as requested.

Key Changes

Fixed Hardcoded Namespace Validation

The IsValidNamespace() method in pNode.cs was previously limited to only two hardcoded values ("ns" and "prefix"), severely restricting the namespace system's usability:

// Before: Very restrictive
var validNamespaces = new List<string> { "ns", "prefix" };
return validNamespaces.Contains(prefix);

// After: XML-compliant validation
private static bool IsValidNamespace(string prefix)
{
    if (string.IsNullOrEmpty(prefix)) return false;
    if (!char.IsLetter(prefix[0]) && prefix[0] != '_') return false;
    
    for (int i = 1; i < prefix.Length; i++)
    {
        char c = prefix[i];
        if (!char.IsLetterOrDigit(c) && c != '-' && c != '.' && c != '_')
            return false;
    }
    
    if (prefix.ToLower().StartsWith("xml")) return false;
    return true;
}

Enhanced Validation Examples

Now supports industry-standard namespace patterns:

  • math:operations, data:content, ui_controls:button
  • app-settings:config, api.v2:endpoint
  • 123invalid:test (starts with number), xml:reserved (reserved prefix)

Consolidated Test Coverage in OpNodeTest3

All namespace-related tests have been moved to the OpNodeTest3 project and standardized:

  1. UnitTest_Namespace.cs - Core namespace functionality, creation, cloning, and basic validation
  2. UnitTest_NamespaceUsability.cs - Real-world file I/O scenarios with XML
  3. UnitTest_PrefixSuffix.cs - Dedicated testing for prefix and suffix combinations

Project Standardization

  • Moved all namespace tests from OpNodeTest2 to OpNodeTest3 as requested
  • Fixed namespace inconsistencies to use UnitTestProject1 throughout the project
  • Updated project file to include new test files
  • Standardized test dependencies to match project requirements

File I/O Verification

Tested and verified that namespace information is properly preserved in XML export/import operations and complex hierarchical structures with mixed namespace prefixes and suffixes.

Impact

This change removes artificial constraints on namespace usage while maintaining XML compliance, enabling the OpNode system to work with industry-standard namespace conventions. The comprehensive test suite in OpNodeTest3 ensures reliability and prevents regressions.

Fixes #62.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 2, 2025 07:51
Co-authored-by: marcnoon <883172+marcnoon@users.noreply.github.com>
Co-authored-by: marcnoon <883172+marcnoon@users.noreply.github.com>
Copilot AI changed the title [WIP] Review documention for prefixes and suffixes and namesapces and fix any issues Fix namespace validation and add comprehensive testing for prefixes/suffixes Aug 2, 2025
Copilot AI requested a review from marcnoon August 2, 2025 07:55
@marcnoon
Copy link
Contributor

marcnoon commented Aug 2, 2025

@copilot I updated the unit test to use the project OpNodeTest3 and please fix any tests and add any remaining test in this unit test project related to this issue. I unloaded the other test projects and unrelated projects that aren't based on the windows forms project. The projects were standardized using the same build and dotnet versioning and cpu strategy.

Co-authored-by: marcnoon <883172+marcnoon@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 2, 2025

@copilot I updated the unit test to use the project OpNodeTest3 and please fix any tests and add any remaining test in this unit test project related to this issue. I unloaded the other test projects...

I've successfully moved all namespace-related tests to the OpNodeTest3 project and standardized the project structure. The changes include:

  • Moved 3 comprehensive test files from OpNodeTest2 to OpNodeTest3:

    • UnitTest_Namespace.cs - Core namespace functionality and validation
    • UnitTest_NamespaceUsability.cs - Real-world XML file I/O scenarios
    • UnitTest_PrefixSuffix.cs - Prefix and suffix combination testing
  • Fixed namespace inconsistencies - Updated all test files to use UnitTestProject1 namespace consistently

  • Updated project file - Added the new test files to OpNodeTest3.csproj

  • Removed dependencies - Simplified tests to work without external JSON libraries

All tests focus on validating the enhanced namespace validation system that now supports XML-compliant naming conventions instead of the previous hardcoded limitations. The tests cover edge cases, validation scenarios, and file I/O operations to ensure comprehensive coverage of issue #62.

Commit: 661f060

Copilot AI changed the title Fix namespace validation and add comprehensive testing for prefixes/suffixes Fix namespace validation and move tests to OpNodeTest3 project Aug 2, 2025
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.

Review documention for prefixes and suffixes and namesapces and fix any issues

3 participants