Fix trimming warnings in System.Diagnostics.Process tests#127221
Merged
MichalStrehovsky merged 1 commit intodotnet:mainfrom Apr 22, 2026
Merged
Fix trimming warnings in System.Diagnostics.Process tests#127221MichalStrehovsky merged 1 commit intodotnet:mainfrom
MichalStrehovsky merged 1 commit intodotnet:mainfrom
Conversation
Replace obj.GetType().GetField(...) and assembly.GetType(...) with
Type.GetType("FullName, AssemblyName") patterns that the trim
analyzer can statically analyze. Re-enable the trim analyzer in the
test project.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates System.Diagnostics.Process tests to be compatible with the trim analyzer by replacing reflection patterns that the analyzer can’t reason about with Type.GetType("FullName, AssemblyName")-based lookups, and then re-enables the trim analyzer in the test project.
Changes:
- Re-enable trim analysis for
System.Diagnostics.Processtests by removing theEnableTrimAnalyzer=falseoverride. - Replace
Assembly.GetType(...)andobj.GetType().GetField(...)usage with assembly-qualifiedType.GetType(...)lookups in Unix wait-state helpers. - Update environment-variable test reflection to use assembly-qualified
Type.GetType(...)for the internal wrapper type.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj |
Re-enables the trim analyzer by removing the prior suppression. |
src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs |
Uses assembly-qualified Type.GetType(...) for ProcessWaitState reflection to satisfy trim analysis. |
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs |
Uses assembly-qualified Type.GetType(...) for DictionaryWrapper reflection to satisfy trim analysis. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
adamsitnik
approved these changes
Apr 21, 2026
jkotas
approved these changes
Apr 21, 2026
This was referenced Apr 21, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace obj.GetType().GetField(...) and assembly.GetType(...) with Type.GetType("FullName, AssemblyName") patterns that the trim analyzer can statically analyze. Re-enable the trim analyzer in the test project.