Skip to content

chore: avoid analyzer test Buildalyzer hang#1798

Merged
martinothamar merged 1 commit into
Altinn:mainfrom
martinothamar-agent:fix/analyzer-test-buildalyzer-hang
Jun 5, 2026
Merged

chore: avoid analyzer test Buildalyzer hang#1798
martinothamar merged 1 commit into
Altinn:mainfrom
martinothamar-agent:fix/analyzer-test-buildalyzer-hang

Conversation

@martinothamar-agent

@martinothamar-agent martinothamar-agent commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • switch analyzer test fixture initialization to Buildalyzer's design-time project analysis path
  • add referenced projects to the Roslyn workspace so injected test code resolves app-lib project types
  • remove duplicate metadata references for assemblies that are represented by workspace project references

Why

The local analyzer test harness could hang inside Buildalyzer/MSBuild pipe logger disposal when the fixture forced a non-design-time Clean;Build. The analyzer tests only need Roslyn compilation inputs, not build outputs, so design-time analysis is a better fit.

Testing

  • dotnet build test/Altinn.App.Analyzers.Tests/Altinn.App.Analyzers.Tests.csproj -v minimal
  • timeout 120s dotnet test test/Altinn.App.Analyzers.Tests/Altinn.App.Analyzers.Tests.csproj --no-build -v normal --filter "FullyQualifiedName~HttpContextAccessorUsageAnalyzerTests.Emits_Diagnostic" --blame-hang --blame-hang-timeout 2m --blame-hang-dump-type mini
  • dotnet test test/Altinn.App.Analyzers.Tests/Altinn.App.Analyzers.Tests.csproj --no-build -v minimal --filter "Category!=Integration"

Build emits existing NU1903 package vulnerability warnings for Microsoft.Build/System.Security.Cryptography.Xml packages.

Summary by CodeRabbit

Release Notes

This pull request contains internal testing infrastructure improvements with no user-facing changes. Updates include:

  • Tests
    • Simplified test fixture initialization process
    • Enhanced workspace project handling to eliminate metadata reference duplication

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR refactors BaseFixture.Init in the test analyzer fixture by removing the optional preBuildTarget parameter and introducing workspace normalization. The initialization now automatically handles metadata-reference deduplication when adding projects to the workspace with project references enabled.

Changes

Simplified fixture initialization

Layer / File(s) Summary
Init signature and workspace normalization
test/Altinn.App.Analyzers.Tests/Fixtures/BaseFixture.cs
Method signature simplified to remove the optional preBuildTarget parameter. Core logic now builds with default EnvironmentOptions, adds the project to AdhocWorkspace with addProjectReferences: true, removes duplicate metadata references using a new private helper, applies solution changes, and refreshes the Project instance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

ignore-for-release, backport-ignore

Suggested reviewers

  • martinothamar
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately describes the main change: avoiding a Buildalyzer hang in analyzer tests by switching to design-time project analysis.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@martinothamar martinothamar changed the title fix: avoid analyzer test Buildalyzer hang chore: avoid analyzer test Buildalyzer hang Jun 5, 2026
@martinothamar martinothamar added kind/chore other A PR that should be in release notes, but as a chore labels Jun 5, 2026
@martinothamar martinothamar merged commit d0a715a into Altinn:main Jun 5, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/chore other A PR that should be in release notes, but as a chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants