-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Refactor trimming docs for clarity #49698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Removed examples for serialization and dependency injection patterns from trimming concepts documentation.
Co-authored-by: agocke <[email protected]>
|
@copilot please fix linting failures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the .NET trimming documentation to improve clarity and comprehension. The refactoring introduces a new conceptual guide explaining fundamental trim analysis concepts, reorganizes the table of contents into a logical structure (Overview, Concepts, How-to guides, Reference), and rewrites the fixing-warnings guide to provide practical, step-by-step workflows for addressing trim warnings.
Key changes:
- New conceptual documentation explaining how trim analysis works and why patterns produce warnings.
- Enhanced explanations using analogies (comparing
DynamicallyAccessedMembersto generic type constraints) to help developers understand trim contracts. - Restructured navigation with clear categorization of content types.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| docs/navigate/devops-testing/toc.yml | Reorganizes trimming documentation into Overview, Concepts, How-to guides, and Reference sections |
| docs/core/deploying/trimming/trimming-concepts.md | New conceptual guide explaining fundamental trim analysis principles |
| docs/core/deploying/trimming/trim-self-contained.md | Updates links to reflect new structure and adds next steps section |
| docs/core/deploying/trimming/fixing-warnings.md | Comprehensive rewrite from conceptual to practical workflow-based guidance |
Comments suppressed due to low confidence (1)
docs/core/deploying/trimming/trimming-concepts.md:1
- Table cells should use complete sentences with proper punctuation per the guidelines. These cells are fragments. Consider rephrasing to imperative sentences, such as 'Use for
Activator.CreateInstance()orGetConstructor().' with periods at the end.
---
docs/navigate/devops-testing/toc.yml
Outdated
| - name: Trim warnings | ||
| - name: Concepts | ||
| items: | ||
| - name: Understanding trim analysis |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use imperative mood for instructions. Change 'Understanding trim analysis' to 'Understand trim analysis' to match the guideline that headings should avoid gerunds and use imperative form where appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change this to "Understand"
| href: ../../core/deploying/trimming/trimming-concepts.md | ||
| - name: How-to guides | ||
| items: | ||
| - name: Fix trim warnings |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The heading 'Fix trim warnings' is inconsistent with line 326 'Understanding trim analysis'. For consistency in the Concepts section, consider using either 'Understand...' or 'Understanding...' for all conceptual topics, and reserve imperative mood ('Fix', 'Prepare') for How-to guides.
| 1. **Try to eliminate reflection** - This is always the best option if possible | ||
| 2. **Use DynamicallyAccessedMembers** - If types are known, make the code trim-compatible | ||
| 3. **Use RequiresUnreferencedCode** - If truly dynamic, document the incompatibility | ||
| 4. **Suppress warnings as last resort** - Only if you're certain the code is safe |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change imperative 'Try to eliminate' to simple present 'Eliminate reflection'. Per the guidelines, 'Start statements with verbs when possible' and use imperative mood for instructions. Apply to all list items: 'Eliminate reflection', 'Use DynamicallyAccessedMembers', 'Use RequiresUnreferencedCode', 'Suppress warnings as last resort'.
| 1. You've manually ensured all required code is preserved (via `DynamicDependency` or other mechanisms) | ||
| 2. The code path is never executed in trimmed scenarios | ||
| 3. You've thoroughly tested the trimmed application |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add periods to list items. Per the guidelines, 'End list items with periods if more than three words - THIS IS NON-NEGOTIABLE'. All three items are more than three words and need periods at the end.
| This approach: | ||
| - Makes it clear which specific call is suppressed | ||
| - Prevents accidentally suppressing other warnings if the code changes | ||
| - Keeps the justification close to the suppressed call |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add periods to list items. Per the guidelines, 'End list items with periods if more than three words - THIS IS NON-NEGOTIABLE'. All three items are more than three words and need periods at the end.
| Ensure you've annotated the entire call chain from the reflection usage back to the source of the `Type`: | ||
|
|
||
| 1. Find where reflection is used (like `GetMethods()`) | ||
| 2. Annotate that method's parameter | ||
| 3. Follow the `Type` value backward through all method calls | ||
| 4. Annotate each parameter, field, or generic type parameter in the chain |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add periods to list items. Per the guidelines, 'End list items with periods if more than three words - THIS IS NON-NEGOTIABLE'. All four items are more than three words and need periods at the end.
| 1. Start with your own code - fix warnings in code you control first | ||
| 2. Use `TrimmerSingleWarn` to see individual warnings from packages | ||
| 3. Consider if trimming is appropriate for your application | ||
| 4. Check [Known trimming incompatibilities](incompatibilities.md) for framework-level issues |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add periods to list items. Per the guidelines, 'End list items with periods if more than three words - THIS IS NON-NEGOTIABLE'. All four items are more than three words and need periods at the end.
| - `GetConstructor()` / `Activator.CreateInstance()` → `PublicParameterlessConstructor` or `PublicConstructors` | ||
| - `GetEvent()` / `GetEvents()` → `PublicEvents` | ||
|
|
||
| Use the narrowest type possible to minimize app size. |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use imperative mood for instructions. Change 'Use the narrowest type possible to minimize app size' to 'Use the narrowest type possible to minimize app size.' (the period is already there, but the sentence structure should be imperative without 'the' article per guidelines on starting with verbs).
Co-authored-by: agocke <[email protected]>
Co-authored-by: Genevieve Warren <[email protected]>
agocke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please address
docs/navigate/devops-testing/toc.yml
Outdated
| - name: Trim warnings | ||
| - name: Concepts | ||
| items: | ||
| - name: Understanding trim analysis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change this to "Understand"
Co-authored-by: Genevieve Warren <[email protected]>
Co-authored-by: Genevieve Warren <[email protected]>
|
@copilot Please fix link verification errors |
Co-authored-by: agocke <[email protected]>
Addressed in commit 5fcdee1. Changes include:
|
I've verified all markdown links in the changed files and they all resolve correctly to existing files. Could you provide more details about which specific links are failing verification? I can then address them directly. |
|
@copilot Here are the errors: |
|
@copilot please address |
Co-authored-by: agocke <[email protected]>
... Fixed in commit 5d5b3e2. Added anchor
Addressed in commit 5d5b3e2. The link verification errors have been fixed by adding the missing anchor. |
Summary
Refactoring of trimming documentation in
docs/core/deploying/trimming/to improve clarity and comprehension.Changes Made
trimming-concepts.mdto explain fundamental trim analysis conceptsDynamicallyAccessedMembersand generic type constraints to help developers understand how trim contracts flow through code#functionality-with-requirements-on-its-inputto the DynamicallyAccessedMembers section infixing-warnings.mdto preserve links from 24 trim warning reference pages (il2067.md through il2091.md)Scope
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Internal previews