Skip to content

ahmad2smile/DotnetTricks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Dotnet Tricks

Replace Private Method

This Project ReplacePrivateMethod Replaces a private method's implementation with some other method, so when the private method is called your custom method runs. Ex:

  1. Suppose a private method in a library you want to do something else:
private string? PrivateMethod()
{
    return "This is a private";
}
  1. Replaces it so when it's called it runs following method instead:
// NOTE: Method in any class with any name
private string? PrivateMethod()
{
    return "This is an overwritten private";
}

This is done by replacing original method's Instructions' Location in IL with Instructions Location of method to replaced in IL.

Credits: Code Ease Blog

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages