Skip to content

Commit ffc0d60

Browse files
Add a note describing feature switches as last resort option
1 parent 84b0860 commit ffc0d60

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

xml/System.Diagnostics.CodeAnalysis/FeatureSwitchDefinitionAttribute.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@
3232
</summary>
3333
<remarks>
3434
<para>
35-
IL rewriters and compilers can use this attribute to substitute the return value
36-
of the specified property with the value of the feature switch.</para>
35+
<format type="text/markdown"><![CDATA[
36+
IL rewriters and compilers can use this attribute to substitute the return value of the specified property with the value of the feature switch.
37+
38+
The value of the feature switch can only be specified at the application level and affects the entire application. It is possible to get into situations where one library that is part of the application requires the feature switch to be turned on, but has no way to communicate this to the application author.
39+
40+
Feature switches complicate unit testing and code sharing since different application configurations may have different values of the feature switch and it's difficult to ensure all code paths work as expected.
41+
42+
It is therefore preferable to structure APIs in a way that trimming can happen naturally without any feature switches. The use of feature switches should be reserved for situations where trimming needs to happen, but it's not feasible to change the APIs to allow trimming naturally.
43+
]]></format>
3744
</remarks>
3845
<example>
3946
<format type="text/markdown"><![CDATA[

0 commit comments

Comments
 (0)