Fix runtime schema resolution and direct construction - #4426
Conversation
Normalize namespace-index and namespace-URI data type lookup across schema resolvers. Expose the built-in schema generators and stabilize the generated factory definition path for direct construction. Fixes #4423 Fixes #4424 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b17fd166-fdef-4660-a9d5-97c0e69f1bd5
There was a problem hiding this comment.
🟡 Changes recommended
There is at least one build-blocking unused-using warning introduced in the updated tests (warnings are treated as errors).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes mismatches in runtime schema resolution between namespace-index and namespace-URI ExpandedNodeId forms, and makes the documented “direct construction” schema-generation path viable for non-friend assemblies by promoting the built-in generators and EncodeableFactoryDefinitionSource to stable public API.
Changes:
- Normalize
DataTypeDefinitionRegistryandEncodeableFactoryDefinitionSourceresolution across index/URIExpandedNodeIdforms, including replacement/re-index cleanup. - Make JSON/XSD/BSD schema generators publicly constructible and remove
[Experimental]fromEncodeableFactoryDefinitionSource, enabling directDefaultSchemaProviderconstruction. - Add/extend tests (DI path, direct construction, AOT, replacement scenarios) and update docs/NuGet readme to describe the supported usage patterns.
File summaries
| File | Description |
|---|---|
| tests/Opc.Ua.Core.Schema.Tests/SchemaServiceCollectionExtensionsTests.cs | Adds DI-based regression test covering URI-form ExpandedNodeId resolution. |
| tests/Opc.Ua.Core.Schema.Tests/GeneratedTypeDefinitionTests.cs | Updates tests to validate generated activator definitions and schema creation via factory definitions. |
| tests/Opc.Ua.Core.Schema.Tests/EncodeableFactoryDefinitionSourceTests.cs | Adds stability/normalization coverage for factory-based resolution (and schema generation) across ID forms. |
| tests/Opc.Ua.Core.Schema.Tests/DataTypeNodeRegistrationTests.cs | Expands registry tests for index/URI lookups and replacement/re-index cleanup. |
| tests/Opc.Ua.Core.Schema.Tests/ComplexTypeSystemCoverageTests.cs | Adjusts experimental-warning comment to reflect current test surface. |
| tests/Opc.Ua.Aot.Tests/SchemaAotTests.cs | Adds AOT smoke coverage for direct provider construction and factory-definition resolution. |
| src/Opc.Ua.Types/Encoders/IDataTypeDefinitionSource.cs | Clarifies interface docs to explicitly include generated activators. |
| src/Opc.Ua.Server/ComplexTypes/ServerComplexTypeSystem.cs | Removes experimental-warning suppressions now that the resolver is stable API. |
| src/Opc.Ua.Core.Schema/Xsd/XsdSchemaGenerator.cs | Makes XSD generator publicly constructible for direct provider construction. |
| src/Opc.Ua.Core.Schema/Resolution/IDataTypeDefinitionResolver.cs | Updates docs to state resolvers accept namespace-index and namespace-URI forms. |
| src/Opc.Ua.Core.Schema/Resolution/EncodeableFactoryDefinitionSource.cs | Removes [Experimental] and adds namespace-table normalization between index/URI ID forms. |
| src/Opc.Ua.Core.Schema/Resolution/DataTypeDefinitionRegistryExtensions.cs | Documents when to pass NamespaceTable to enable URI-form resolution. |
| src/Opc.Ua.Core.Schema/Resolution/DataTypeDefinitionRegistry.cs | Adds namespace-URI lookup map, replacement cleanup, and URI-form ExpandedNodeId resolution. |
| src/Opc.Ua.Core.Schema/NugetREADME.md | Documents direct construction and factory-definition-based resolution path. |
| src/Opc.Ua.Core.Schema/Json/JsonSchemaGenerator.cs | Makes JSON generator publicly constructible for direct provider construction. |
| src/Opc.Ua.Core.Schema/IUaSchemaGenerator.cs | Updates docs to reflect DI or direct provision of generators. |
| src/Opc.Ua.Core.Schema/DefaultSchemaProvider.cs | Minor doc tweak aligning with direct-generator usage. |
| src/Opc.Ua.Core.Schema/Bsd/BsdSchemaGenerator.cs | Makes BSD generator publicly constructible for direct provider construction. |
| docs/SchemaGeneration.md | Updates guidance and examples for direct construction and factory-definition resolver usage, plus URI-form resolution notes. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage✅ Coverage gate passed.
Uncovered changed lines
Coverage is above the recorded baseline - consider ratcheting Thresholds live in |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4426 +/- ##
==========================================
- Coverage 80.89% 80.87% -0.02%
==========================================
Files 1984 1984
Lines 276971 277054 +83
Branches 48061 48084 +23
==========================================
+ Hits 224045 224066 +21
- Misses 36411 36456 +45
- Partials 16515 16532 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Inspect attribute metadata by full name so the stable API guard works when net8.0 tests reference the netstandard2.1 attribute polyfill. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b17fd166-fdef-4660-a9d5-97c0e69f1bd5
Preserve upstream server, source-generation, and WoT changes alongside the schema fixes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b17fd166-fdef-4660-a9d5-97c0e69f1bd5
Remove BrowseName-derived namespace aliases, discriminate empty identifier kinds in URI keys, and reconstruct typed factory identifiers during URI-to-index fallback. Add regression coverage for public registry, factory, DI, and NativeAOT paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b17fd166-fdef-4660-a9d5-97c0e69f1bd5
Description
Fix runtime schema resolution and provide a supported DI-free construction path for generated data types.
EncodeableFactoryDefinitionSource, and document generated activator/factory usage.masterwithout dropping upstream changes.Related Issues
Validation
Opc.Ua.Core.Schema.Tests: 157/157 onnet10.0Opc.Ua.Core.Schema.Tests: 157/157 onnet48Opc.Ua.Core.Schema.Tests: 157/157 withCustomTestTarget=netstandard2.1and itsnet8.0consumerSchemaAotTests: 4/4SchemaAotTests: 4/4Checklist