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 6597411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:12:19+00:00 2026-05-25T18:12:19+00:00

how are extension methods evaluated? or in a very specific use case: if an

  • 0

how are extension methods evaluated? or in a very specific use case: if an extension method is implemented as a class instance method by a new version of an assembly and that assembly is updated but dependent assemblies are not, will they:

  1. still access the extension method
  2. access the new class instance method
  3. throw

I’ve added the following simple code samples of a FooExtensions assembly, an IFoo assembly, a FooBefore assembly and a FooAfter assembly, and a Test assembly. The idea is that the first release starts out with FooExtensions, IFoo, FooBefore and Test. The test will dynamically load assembly FooBefore and dependent assemblies and create a Foo. It will then call GetMessage and should write to the console “message”. For the second release we only replace FooBefore with FooAfter and run the test again. Then what happens?

#region Assembly FooExtensions
public static class FooExtensions
{
    public static string GetMessage(this IFoo foo)
    {
        return foo.Message;
    }
}
#endregion

#region Assembly IFoo
public interface IFoo
{
    string Message { get; }
}
#endregion

#region Assembly Foo before update
namespace FooBefore
{
    public class Foo : IFoo
    {
        public string Message
        {
            get { return "message"; }
        }
    }
}
#endregion

#region Assembly Foo after update
namespace FooAfter
{
    public class Foo : IFoo
    {
        public string GetMessage() { return "bar"; }

        public string Message
        {
            get { return "message"; }
        }
    }
}
#endregion

#region Assembly Test
public class Class1
{
    public void T()
    {
        // if extension method is implemented in new version of deriving assembly and
        // just that assembly is switched but not dependent assemblies, what happens?

        // before update: extension method, as we know it
        Console.WriteLine((Activator.CreateInstance("Foo.DLL", "Foo").Unwrap() as IFoo).GetMessage());
        // after update: class instance method, but do we know?
        Console.WriteLine((Activator.CreateInstance("Foo.DLL", "Foo").Unwrap() as IFoo).GetMessage());
    }
}
#endregion
  • 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-05-25T18:12:20+00:00Added an answer on May 25, 2026 at 6:12 pm

    Extension methods are just syntactic sugar for regular static methods, so they will work as before until you recompile the dependent assembly, at which point the compiler will find the new instance method and generate a call to it instead.

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

Sidebar

Related Questions

Is there any way to use extension methods on a class that has been
I typically use extension methods very sparingly. When I do feel compelled to write
C# 3.0 Extension methods add extensions to the base Type making calling that method
I've implemented some extension methods and put those in separate Class Library project. Imagine
I have two extension methods that are very similar. I'd like to remove the
Does Python have extension methods like C#? Is it possible to call a method
Is an interface + extension methods (mixin) preferable to an abstract class? If your
I've implemented some extension methods as defined here . I've put these into a
Extension methods are useful for types that you don't own and can't/don't want to
Using extension methods for C#, how can include an AddNode method (see below) in

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.