Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d355cd0

Browse files
agockegewarren
andauthored
Apply suggestions from code review
Co-authored-by: Genevieve Warren <[email protected]>
1 parent 3de718b commit d355cd0

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

docs/core/deploying/trimming/trim-self-contained.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ For more information, see [.NET application publishing overview](../../deploying
7171

7272
## Next steps
7373

74-
After enabling trimming, you may encounter trim warnings during build. Follow these guides to understand and resolve them:
74+
After enabling trimming, you might encounter trim warnings during build. Follow these guides to understand and resolve them:
7575

7676
- **[Understanding trim analysis](trimming-concepts.md)** - Learn how the trimmer works and why certain code patterns produce warnings. This conceptual guide explains the fundamental principles of trim analysis.
7777
- **[Fix trim warnings](fixing-warnings.md)** - Step-by-step workflows for resolving trim warnings in your code.

docs/core/deploying/trimming/trimming-concepts.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ PrintMethodNames(typeof(DateTime));
7777

7878
From the trimmer's perspective:
7979

80-
1. It sees `type.GetMethods()` is called
81-
2. It doesn't know what `type` will be (it's a parameter)
82-
3. It can't determine which types' methods need to be preserved
83-
4. Without guidance, it might remove methods from `DateTime`, breaking the code
80+
- It sees `type.GetMethods()` is called.
81+
- It doesn't know what `type` will be (it's a parameter).
82+
- It can't determine which types' methods need to be preserved.
83+
- Without guidance, it might remove methods from `DateTime`, breaking the code.
8484

85-
This is why the trimmer produces a warning on this code.
85+
Consequently, the trimmer produces a warning on this code.
8686

8787
## Understanding DynamicallyAccessedMembers
8888

@@ -190,11 +190,11 @@ Some code patterns simply cannot be made statically analyzable. For these cases,
190190

191191
### When to use RequiresUnreferencedCode
192192

193-
Use this attribute when:
193+
Use the <xref:System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute> attribute when:
194194

195-
1. **The reflection pattern is fundamentally dynamic**: Loading assemblies or types by string names from external sources
196-
2. **The complexity is too high to annotate**: Code that uses reflection in complex, data-driven ways
197-
3. **You're using runtime code generation**: Technologies like <xref:System.Reflection.Emit> or the `dynamic` keyword
195+
- **The reflection pattern is fundamentally dynamic**: Loading assemblies or types by string names from external sources.
196+
- **The complexity is too high to annotate**: Code that uses reflection in complex, data-driven ways.
197+
- **You're using runtime code generation**: Technologies like <xref:System.Reflection.Emit> or the `dynamic` keyword.
198198

199199
Example:
200200

@@ -212,8 +212,8 @@ void LoadPlugin(string pluginPath)
212212

213213
`RequiresUnreferencedCode` serves two purposes:
214214

215-
1. **Suppresses warnings inside the method**: The trimmer won't analyze or warn about the reflection usage
216-
2. **Creates warnings at call sites**: Any code calling this method gets a warning
215+
1. **Suppresses warnings inside the method**: The trimmer won't analyze or warn about the reflection usage.
216+
2. **Creates warnings at call sites**: Any code calling this method gets a warning.
217217

218218
This "bubbles up" the warning to give developers visibility into trim-incompatible code paths.
219219

@@ -388,12 +388,12 @@ void LoadPlugins(string pluginDirectory)
388388

389389
## Key takeaways
390390

391-
1. **The trimmer uses static analysis** - it can only understand code paths visible at compile time
392-
2. **Reflection breaks static analysis** - the trimmer can't see what reflection will access at runtime
393-
3. **DynamicallyAccessedMembers creates contracts** - it tells the trimmer what needs to be preserved
394-
4. **Requirements flow backward** - from reflection usage back to the source of the `Type` value
395-
5. **RequiresUnreferencedCode documents incompatibility** - use it when code can't be made analyzable
396-
6. **Attributes aren't just hints** - the trimmer enforces contracts and produces warnings when they can't be met
391+
- **The trimmer uses static analysis** - it can only understand code paths visible at compile time.
392+
- **Reflection breaks static analysis** - the trimmer can't see what reflection will access at runtime.
393+
- **DynamicallyAccessedMembers creates contracts** - it tells the trimmer what needs to be preserved.
394+
- **Requirements flow backward** - from reflection usage back to the source of the `Type` value.
395+
- **RequiresUnreferencedCode documents incompatibility** - use it when code can't be made analyzable.
396+
- **Attributes aren't just hints** - the trimmer enforces contracts and produces warnings when they can't be met.
397397

398398
## Next steps
399399

0 commit comments

Comments
 (0)