Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8429839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:26:52+00:00 2026-06-10T05:26:52+00:00

I have a situation where I’ve exposed a plugin architecture to my class library,

  • 0

I have a situation where I’ve exposed a plugin architecture to my class library, and I want others to be able to implement the interfaces I’ve created and have their custom implementations be used by the class.

I’m using dependency injection (specifically constructor injection) to accomplish this.

This works fine, except for the fact that I’ve tried to design the application with two conflicting goals:

  • Consumers of the API should not be able to modify the return values; I’ve created custom read-only collections and objects, using internal on the setters and such to ensure no consumers can modify it
  • Plugins, in other assemblies, should be able to access these internal methods and properties

These two goals are conflicting because there is no way for my API (or C# for that matter) to grant internal access (via InternalsVisibleTo or similar) to the plugin assemblies, but not to general consumers.


Illustrative example

Suppose we have three assemblies. My class (Class), a plugin assembly (Plugin), and a consumer assembly (Consumer).

An interface, IReturnValue specifies a return value of the API (some method or class in the Class assembly). The problem is this: I want Plugin to be able to set read-only (internal) properties and indexers on any given instance of IReturnValue, but I don’t want Consumer code to be able to do this.

Since a plugin system is in play, I can’t know ahead of time what assemblies to grant InternalsVisibleTo to.


In this situation, should I really care about consumers modifying return types? It seems like it’s their own fault if they do. And I can’t think of any decent solution to solving this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:26:54+00:00Added an answer on June 10, 2026 at 5:26 am

    As I already said in my comment, I am not sure I understood your question correctly.

    I understood your question like this:

    You have a class A that is used by Consumers and by Implementors. Consumers should only be able to get data, implementors should additionally be able to set data.

    In this case, I would create one interface that is modeled to the consumers needs with only read access and one with read/write access for the implementors.

    UPDATE after question update:
    The read only interface for the consumer already exists: IReturnValue and should be used for this purpose.

    All you need to do now is to create an interface that is either write only or that is read/write, depending on the needs of the API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have situation like this: class IData { virtual void get() = 0; virtual
Pseudo-situation: have a class (let's say BackgroundMagic ), and it has Start() and Stop()
I have situation like this: // Object Class class Person_Object { protected $_id; public
i have situation in which i have some library projects, say DataProcessors,Lib2 , included
I have situation to extend the Enumerable class in c# to add the new
I have a situation (using the Raphael library) where I have this: rect.click(doSomething); And
i have a situation i want to add a vimeo player in to my
I have situation like this: Range formulaCells = range.SpecialCells(XlCellType.xlCellTypeFormulas); And I want to iterate
I have situation where my Java class needs to create a ton of certain
I have situation where I want to change layout of activity after 3 seconds.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.