Skip to content

Commit 4a4fd51

Browse files
Add a note describing feature switches as last resort option (#11394)
1 parent 00dbc12 commit 4a4fd51

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

xml/System.Diagnostics.CodeAnalysis/FeatureSwitchDefinitionAttribute.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@
3131
corresponds to the feature switch specified by name.</para>
3232
</summary>
3333
<remarks>
34-
<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>
34+
<format type="text/markdown"><![CDATA[
35+
IL rewriters and compilers can use this attribute to substitute the return value of the specified property with the value of the feature switch.
36+
37+
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.
38+
39+
Feature switches complicate unit testing and code sharing since different application configurations might have different values of the feature switch, and it's difficult to ensure all code paths work as expected.
40+
41+
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.
42+
]]></format>
3743
</remarks>
3844
<example>
3945
<format type="text/markdown"><![CDATA[

0 commit comments

Comments
 (0)