0

Is there a way to redefine a function definition/method in C#?

Situation:

Modding someone else's code, and they have:

namespace TheirCode 
{
  public static class SomeUtility
  {
    public static void A(this Thing thing) 
    {
      //do something I want to change
    }
  }
}

I can load another dll that will allow me to insert my own code...but I want to change the behavior of a_thing.A(); I need the changes to affect all Things, not just any derived NewThings I might create.

Can I rewrite the method definition somehow? Can I change the behavior another way?

Thanks

Peter Kay
  • 123
  • 7

1 Answers1

0

Oh wow, there's a whole series of answers in this other question:

Dynamically replace the contents of a C# method?

The Harmony answer looks great!

I don't know why I couldn't find it earlier when I was searching; maybe this question's search terms will help someone else.

Peter Kay
  • 123
  • 7