Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

Plugin Loading Enhancement

Update plugin loading to use a dedicated "plugins" property in package.json instead of scanning all dependencies.

Summary of Changes:

Changed Files:

  1. GeneratorHandler.cs - Updated GetOrderedPluginDlls method

    • Changed to look for plugins property instead of dependencies in package.json
    • Added error handling to throw InvalidOperationException when plugin dist directory doesn't exist
    • Added error handling to throw InvalidOperationException when no DLL files found in plugin dist directory
  2. GeneratorHandlerTests.cs - Enhanced test coverage

    • Updated existing test to use plugins property
    • Added test for missing plugin directory error case
    • Added test for missing plugin DLL error case
    • Added test for backward compatibility (no plugins property)
  3. plugins.md (NEW) - Comprehensive plugin documentation

    • Explains plugins as a lighter-weight alternative to custom emitters/generators
    • "Adding a Plugin" section with instructions for adding plugins to package.json
    • "Creating a Custom Plugin" section with sample code
    • Reference to the logging plugin sample for a complete example
  4. usage.md - Updated to reference plugins guide

    • Added "Using Plugins" section that links to the plugins.md guide
    • Maintains consistent structure with customization guide reference

Benefits:

  • Better error handling: Generator now fails fast with clear messages when plugin DLLs are missing
  • Explicit plugin declaration: Separates plugins from regular dependencies
  • Prevents downstream bugs: Issues are caught during plugin loading rather than later in the pipeline
  • Clear documentation: Users now have comprehensive documentation on how to use and create plugins, including guidance on when to use plugins vs custom generators

Testing:

  • ✅ All 1107 tests pass
  • ✅ 3 new tests added for error handling
  • ✅ Full generator build succeeds
  • ✅ Code review completed and feedback addressed
  • ✅ Documentation enhanced per reviewer feedback

Plan:

  • Explore repository structure and understand current implementation
  • Review GeneratorHandler.cs and GetOrderedPluginDlls method
  • Review existing tests for plugin loading functionality
  • Build and test current state (all tests passing)
  • Update GetOrderedPluginDlls to look for "plugins" property in package.json
  • Add error handling to throw if specified plugin DLL is not found
  • Update existing test to use "plugins" property instead of "dependencies"
  • Add new test to verify error is thrown when plugin DLL is missing
  • Run tests to validate changes (all 1107 tests passing)
  • Run code review and address feedback
  • Revert SampleService package.json change per reviewer feedback
  • Add plugin documentation section to usage.md
  • Move plugin documentation to separate plugins.md file
  • Add note about plugins as lightweight alternative to custom generators
  • Final validation - all tests passing, build successful
Original prompt

This section details on the original issue you should resolve

<issue_title>Plugin loading should use a special property rather than just dependencies</issue_title>
<issue_description>Currently, we look under dependencies in package.json for any plugins. This is problematic because the plugins need to be built, and the generator doesn't know what dep is supposed to be a plugin so it can't throw if there is no dll found. We should instead adopt a new convention where we add a top-level property, called "plugins" and look there for any plugins. This would allow us to throw if we don't find a dll for the specified by plugin preventing downstream bugs.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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 changed the title [WIP] Update plugin loading to use a special property Use dedicated "plugins" property in package.json for plugin loading Oct 31, 2025
Copilot AI requested a review from JoshLove-msft October 31, 2025 20:35
Copilot finished work on behalf of JoshLove-msft October 31, 2025 20:35
Copilot AI requested a review from JoshLove-msft November 1, 2025 19:39
Copilot finished work on behalf of JoshLove-msft November 1, 2025 19:39
Copilot finished work on behalf of JoshLove-msft November 14, 2025 00:39
Copilot AI requested a review from JoshLove-msft November 14, 2025 00:39
Copilot finished work on behalf of JoshLove-msft November 14, 2025 00:52
@JoshLove-msft JoshLove-msft marked this pull request as ready for review November 14, 2025 17:07
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Nov 14, 2025
@github-actions
Copy link
Contributor

No changes needing a change description found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin loading should use a special property rather than just dependencies

3 participants