Skip to content

Fix trimming warnings in System.Diagnostics.Process tests#127221

Merged
MichalStrehovsky merged 1 commit intodotnet:mainfrom
MichalStrehovsky:processtests
Apr 22, 2026
Merged

Fix trimming warnings in System.Diagnostics.Process tests#127221
MichalStrehovsky merged 1 commit intodotnet:mainfrom
MichalStrehovsky:processtests

Conversation

@MichalStrehovsky
Copy link
Copy Markdown
Member

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.

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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.Process tests by removing the EnableTrimAnalyzer=false override.
  • Replace Assembly.GetType(...) and obj.GetType().GetField(...) usage with assembly-qualified Type.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.

Comment thread src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs
Comment thread src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants