Emergency call

Let’s imagine yourself sleeping on Saturday night. You feel cozy, calm and dreamy in your REM phase. Suddenly you hear your phone ringing. In the first moment you think it’s ringing in your dream, but then you wake up and drunkenly look at the phone. You register two things in your brain, 2 A.M. and your boss' name as a caller. For a split second you question your life choices but for some reason you decide to answer. On the other end your boss tells you that the production crushes and begs you to fix it. He asserts you he’ll pay tenfold for this overtime (ten times zero is still zero, heh). Will you offer your expertise this time?

sOoX1vT

How hot is very hot?

The company you work for is pretty big. Every minute the production does not respond the company loses thousands of monies. You have to fix the production quickly because every minute counts.

You cannot go the usual way. Redeploying the project would take at least 30 minutes, not even thinking about code review. What to do then? Well, we could do a very hot fix on the production!

The project

using Microsoft.AspNetCore.Mvc;

namespace VeryHotFix.API.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class MathsController : ControllerBase
    {
        [HttpGet]
        [Route("area-of-a-circle")]
        public double CalculateAreaOfCircle(double radius)
        {
            return radius * radius * 4.14;
        }

        [HttpGet]
        [Route("quotient")]
        public double DivideTwoNumbers(double a, double b)
        {
            return a / b;
        }
    }
}
9fRqMMI
Figure 1. Dll in project folder
MbbFpv1
Figure 2. Downloading dnSpy
RgX43qH
Figure 3. Opening dll in dnSpy
hhgEHrb
Figure 4. Choosing dll in dnSpy
T03pNFr
Figure 5. Choosing MathsController in dnSpy
gsjM2e7
Figure 6. Decompiled dll
FP2oHLg
Figure 7. Area before editing IL
bYfWWt4
Figure 8. Fixing area in IL
C3KoQrG
Figure 9. Fixed area
XoMtt8x
Figure 10. Simplify in quotient
XaEXjxq
Figure 11. Adding instruction in quotient
eMuyhFk
Figure 12. IL instructions added in quotient
nF3lPFZ
Figure 13. Quotient after editing its IL
yE2kbd0
Figure 14. Error after changing IL - not fixed
PyXX2Nj
Figure 15. Error after changing IL - fixed
QQTQr5u
Figure 16. Adding multiply function
CJKCom3
Figure 17. Saving in dnSpy
PdMJmG7
Figure 18. Save module window
YYATntV
Figure 19. Project working