Skip to content

Commit 9124ebf

Browse files
authored
Minor docs update (#132)
1 parent 5b6e6de commit 9124ebf

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@ If you're using [Central Package Management](https://learn.microsoft.com/en-us/n
2626
```
2727

2828
### C#
29-
You'll need to enable C# documentation XML generation to ensure good analysis results. If your repo is not already using docxml globally, this can introduce a large number of errors and warnings specific to docxml. Additionally, turning on docxml adds additional output I/O that can slow down large repos.
29+
You'll need to enable C# documentation XML generation to ensure good analysis results (RT0000 will fire if it's not enabled). If your repo is not already using docxml globally, this can introduce a large number of errors and warnings specific to docxml. Additionally, turning on docxml adds additional output I/O that can slow down large repos.
3030

31-
You can turn off specific docxml related warnings and errors while defaulting ReferenceTrimmer to off using a block of code like this in your `Directory.Build.props`. Turn on the ReferenceTrimmer build by setting `/p:EnableReferenceTrimmer=true` on the MSBuild command line or setting the same property value as an environment variable. You could create a separate build pipeline for your repo to run ReferenceTrimmer builds.
31+
If your repo does not already set `<GenerateDocumentationFile>` to `true`, add the following to your `Directory.Build.props` to enable it and suppress related warnings:
3232

3333
```xml
34-
<!-- ReferenceTrimmer - run build with /p:EnableReferenceTrimmer=true to enable -->
35-
<PropertyGroup Label="ReferenceTrimmer">
36-
<EnableReferenceTrimmer Condition=" '$(EnableReferenceTrimmer)' == '' ">false</EnableReferenceTrimmer>
37-
</PropertyGroup>
38-
<PropertyGroup Condition=" '$(EnableReferenceTrimmer)' == 'true' and '$(GenerateDocumentationFile)' != 'true' " Label="ReferenceTrimmer">
34+
<PropertyGroup>
3935
<!-- Documentation file generation is required for more accurate C# detection. -->
4036
<GenerateDocumentationFile>true</GenerateDocumentationFile>
4137

42-
<!-- Suppress XML doc comment issues to avoid errors during ReferenceTrimmer:
38+
<!-- Suppress XML doc comment issues:
4339
- CS0419: Ambiguous reference in cref attribute
4440
- CS1570: XML comment has badly formed XML
4541
- CS1573: Parameter has no matching param tag in the XML comment
@@ -52,7 +48,7 @@ You can turn off specific docxml related warnings and errors while defaulting Re
5248
</PropertyGroup>
5349
```
5450

55-
Note: To get better results, enable the [`IDE0005`](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005) unnecessary `using` rule. This avoids the C# compiler seeing a false positive assembly usage from unneeded `using` directives causing it to miss a removable dependency. See also the note for why IDE0005 code analysis rule requires `<GenerateDocumentationFile>` property to be enabled. Documentation generation is also required for accuracy of used references detection (based on https://github.com/dotnet/roslyn/issues/66188).
51+
Note: To get better results, enable the [`IDE0005`](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005) unnecessary `using` rule. This prevents the C# compiler from seeing false positive assembly usage from unneeded `using` directives, which could cause it to miss a removable dependency. Note that IDE0005 also requires `<GenerateDocumentationFile>` to be enabled. Documentation generation is also required for accuracy of used references detection (see https://github.com/dotnet/roslyn/issues/66188).
5652

5753
#### What makes a reference non-trimmable?
5854

@@ -142,6 +138,14 @@ Alternatively, you can add `TreatAsUsed` metadata to suppress all ReferenceTrimm
142138
## Configuration
143139
`$(EnableReferenceTrimmer)` - Controls whether the build logic should run for a given project. Defaults to `true`.
144140

141+
To make ReferenceTrimmer opt-in rather than always-on, you can default it to `false` in your `Directory.Build.props` and enable it via `/p:EnableReferenceTrimmer=true` on the MSBuild command line or as an environment variable. You could also create a separate build pipeline for your repo to run ReferenceTrimmer builds.
142+
143+
```xml
144+
<PropertyGroup>
145+
<EnableReferenceTrimmer Condition=" '$(EnableReferenceTrimmer)' == '' ">false</EnableReferenceTrimmer>
146+
</PropertyGroup>
147+
```
148+
145149
`$(ReferenceTrimmerEnableVcxproj)` - Controls whether MSVC link flags are set up to print out unused libraries and delay-load DLLs. Defaults to `true`.
146150

147151
`$(EnableReferenceTrimmerDiagnostics)` - When set to `true`, writes used and unused reference lists to the intermediate output directory for debugging. Defaults to `false`.

0 commit comments

Comments
 (0)