-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Quirks mode switches in patches
A "quirks mode switch" is a switch to change behavior of an application without having to re-compile (or even re-deploy) an application. They are useful in patches where a behavior needs to be changed, but in case it inadvertently (or sometimes purposefully) introduces an unwanted change, the app developer or app administrator can revert the behavior to the pre-patch behavior.
In general, when patching, assume a quirks mode switch should be added. Only if there are good reasons to avoid a switch, don't add on. Such reasons may include technical challenges, such as where there is no simple if
statement that can be used to change behavior, or it's a template change where the code is what it is.
A full quirks-mode example is available here: https://github.com/Eilon/QuirksModeSwitchSample
And here is an example of where we have used switches in the past:
- Full code change: https://github.com/aspnet/Mvc/commit/7cea779b7a744a3d915aa207a760f6f7b9c6dccc
- Check if the switch is set: https://github.com/aspnet/Mvc/commit/7cea779b7a744a3d915aa207a760f6f7b9c6dccc#diff-619f757abd9c40d0a06dafb6649c1ab5R50
Switch names should be descriptive, sort of like namespace/class/method names, e.g. Switch.Microsoft.AspNetCore.Mvc.AllowJsonHtml
.
Quirks mode switches are currently used only in patches. Quirks mode switches are not used in major/minor versions.