Skip to content

Refactor profile input loading responsibilities - #59

Closed
rogeralsing wants to merge 1 commit into
mainfrom
codex/20260321-114355-69be847a
Closed

rogeralsing wants to merge 1 commit into
mainfrom
codex/20260321-114355-69be847a

Conversation

@rogeralsing

Copy link
Copy Markdown
Contributor

Summary

  • extract profile input classification, labeling, trace detection, and default mode selection into ProfileInputPath and ProfileInputKind
  • extract allocation call-tree to memory-profile projection into MemoryProfileResultFactory
  • simplify ProfileInputLoader so it focuses on file existence checks, heap/trace orchestration, and themed error reporting
  • split the old loader tests into focused suites for loader behavior, input-path behavior, and memory result shaping

Testing

  • roslynator fix src/ProfilerCore/Asynkron.Profiler.Core.csproj
  • roslynator fix src/ProfileTool/ProfileTool.csproj
  • roslynator fix tests/Asynkron.Profiler.Tests/Asynkron.Profiler.Tests.csproj
  • dotnet format Asynkron.Profiler.sln --verify-no-changes
  • dotnet build Asynkron.Profiler.sln -v minimal
  • dotnet test Asynkron.Profiler.sln -v minimal
  • quickdup -path . -ext .cs -select 0..30 -min 2 -exclude ".g.,.generated.,bin/,obj/"

Copilot AI review requested due to automatic review settings March 21, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors profile-input handling by centralizing input-path classification/labeling/default-mode selection and extracting memory-profile shaping logic, while simplifying the loader and splitting tests accordingly.

Changes:

  • Introduce ProfileInputPath + ProfileInputKind to handle input kind detection, label building, trace detection, and default-mode selection.
  • Extract allocation call-tree → MemoryProfileResult shaping into MemoryProfileResultFactory.
  • Update callers and reorganize tests into focused suites (ProfileInputPathTests, MemoryProfileResultFactoryTests).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Asynkron.Profiler.Tests/ProfileInputPathTests.cs Adds unit tests for input kind detection, label fallback, and default mode mapping.
tests/Asynkron.Profiler.Tests/ProfileInputLoaderTests.cs Removes tests moved to the new focused suites.
tests/Asynkron.Profiler.Tests/MemoryProfileResultFactoryTests.cs Adds unit tests for memory result shaping/sorting/capping behavior.
src/ProfileTool/ProfilerExecutionRequestFactory.cs Switches label/default-mode logic to ProfileInputPath.
src/ProfileTool/ProfileInputPath.cs New central implementation for label/kind/default-mode logic.
src/ProfileTool/ProfileInputLoader.cs Simplifies loader by delegating kind detection and memory result shaping.
src/ProfileTool/ProfileInputKind.cs New enum defining supported input kinds.
src/ProfileTool/ProfileCollectionRunner.cs Uses MemoryProfileResultFactory for memory results.
src/ProfileTool/MemoryProfileResultFactory.cs New extracted factory for producing MemoryProfileResult from allocation call trees.
Comments suppressed due to low confidence (1)

src/ProfileTool/ProfilerExecutionRequestFactory.cs:53

  • ApplyDefaults only ever sets flags to true. In this block, runCpu/runMemory are initialized to true when no explicit modes are provided (invocation.* || !hasExplicitModes), so the extension-based defaults can’t actually turn modes off. This makes --input default mode selection ineffective (e.g., a .gcdump input can still try to run CPU/memory). Consider re-initializing all run* flags to false when hasInput && !hasExplicitModes before calling ApplyDefaults (and then re-apply the Hot/JIT forcing logic), or change ApplyDefaults to explicitly assign all flags for each kind.
            if (!hasExplicitModes)
            {
                ProfileInputPath.ApplyDefaults(
                    invocation.InputPath!,
                    ref runCpu,
                    ref runMemory,
                    ref runHeap,
                    ref runException,
                    ref runContention);
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants