Enable Likes or Rating on a SharePoint List programmatically using reflection

For some reasons there is no public property to enable likes or ratings on a list in SharePoint. Using reflection, this is still possible to do. Feel free to use this codesnippet for SharePoint 2013 on-premises.

private static void EnableLikes(SPList list)
    Assembly theAssembly = Assembly.Load("Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
    Type reputationHelperType = theAssembly.GetType("Microsoft.SharePoint.Portal.ReputationHelper", false, true);
    MethodInfo milf = reputationHelperType.GetMethod("EnableReputation", BindingFlags.Static | BindingFlags.NonPublic);
    milf.Invoke(reputationHelperType, new object[] {list, "Likes", false});