feat: wire WithReflectorModulesFromAssembly into the Unity MCP plugin build#805
Merged
IvanMurzak merged 1 commit intoJun 4, 2026
Merged
Conversation
… build Add .WithReflectorModulesFromAssembly(assemblies) to the McpPluginBuilder chain in BuildMcpPlugin(...), alongside the existing .WithToolsFromAssembly(assemblies) etc. (assemblies = AssemblyUtils.AllAssemblies). Any loaded assembly - including extensions added later, unknown ahead of time - can now auto-register its own ReflectorNet JSON/reflection converters, serialization-blacklist entries, and attribute-scan prune rules via an IReflectorModule, without a hardcoded extension list. Discovery honors the existing .IgnoreAssemblies(...) core prune (heavy assemblies are never type-enumerated) and runs strictly before the heavy attribute scan inside Build(). The hardcoded core converters/blacklist in CreateDefaultReflector() stay the Order=0 baseline; module contributions layer on top. Add a verification suite (ReflectorModuleDiscoveryTests, guarded behind the test-only Editor.Tests asmdef) that drives McpPluginBuilder directly with a throwaway in-repo IReflectorModule carrying zero hardcoded reference, proving end to end: (1) a contributed JSON converter, (2) a contributed reflection converter, (3) a contributed serialization-blacklist type, and the scan-ignore surface all reach effect via dynamic discovery; a deliberately throwing module is isolated (the healthy sibling still runs); and an ignored hosting assembly is never type-enumerated (perf guarantee). Add Microsoft.Extensions.DependencyInjection.Abstractions.dll to the test asmdef precompiledReferences (transitively required by the McpPluginBuilder ctor signature). Closes #801
6fc8941 to
99addf0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.WithReflectorModulesFromAssembly(assemblies)intoBuildMcpPlugin(...)so any loaded assembly (including extensions added later, unknown ahead of time) auto-registers its own ReflectorNet JSON/reflection converters, serialization-blacklist entries, and attribute-scan prune rules via anIReflectorModule— no hardcoded extension list. Discovery honors the existing.IgnoreAssemblies(...)core prune and runs before the heavy attribute scan;CreateDefaultReflector()stays the Order=0 baseline.ReflectorModuleDiscoveryTests(guarded behind the test-only Editor.Tests asmdef) proving all four contribution surfaces reach effect via dynamic discovery, that a throwing module is isolated, and that an ignored hosting assembly is never type-enumerated.McpPlugin.dll(all 6 destinations) is replaced with a Release netstandard2.1 build of MCP-Plugin-dotnetmainat2fed761carrying theIReflectorModuleAPI (the published 6.5.5 NuGet predates it). This is the only thing CI compiles against; see the stub commit body for the follow-up obligation once a release ships.Test plan
ReflectorModuleDiscoveryTestsdiscovered + passing).McpPlugin.dllcarrying the new API.Closes #801