Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 19, 2025

This PR fixes the analyzer rebuild issue where projects using the DataverseAnalyzer would encounter file locking errors during rebuild operations.

Problem

The analyzer was targeting .NET 8.0 instead of .NET Standard 2.0, which caused compatibility and isolation issues during development. When projects referenced the analyzer and attempted to rebuild, MSBuild would lock the analyzer assembly, preventing subsequent rebuilds with errors like "file is in use" or similar access violations.

Root Cause

  1. Incorrect Target Framework: The analyzer targeted net8.0 instead of the recommended netstandard2.0 for Roslyn analyzers
  2. Missing Isolation Properties: The project lacked MSBuild properties to prevent analyzer assembly locking
  3. Modern .NET APIs: Used .NET 6+ specific ArgumentNullException.ThrowIfNull() which is incompatible with .NET Standard 2.0

Changes

  • Target Framework: Changed from net8.0 to netstandard2.0 for better compatibility across .NET versions
  • Isolation Properties: Added UseSharedCompilation=false and RestoreProjectStyle=PackageReference to prevent assembly locking during rebuilds
  • API Compatibility: Replaced ArgumentNullException.ThrowIfNull(context) with traditional null checks using if (context is null) throw new ArgumentNullException(nameof(context))
  • Documentation: Updated README.md to reflect the correct output path (netstandard2.0 instead of net8.0)

Verification

  • All 26 existing tests pass, confirming no functional regression
  • Created test project and verified multiple clean/rebuild cycles work without file locking issues
  • All analyzer rules (CT0001, CT0002, CT0003) continue to function correctly

The analyzer now follows standard Roslyn analyzer practices and should work reliably in all development scenarios without rebuild conflicts.

Fixes #9.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Error when rebuilding projects that use the analyzer Fix analyzer rebuild issue by targeting .NET Standard 2.0 and adding isolation properties Aug 19, 2025
Copilot AI requested a review from magesoe August 19, 2025 10:26
@magesoe magesoe marked this pull request as ready for review August 20, 2025 12:03
@magesoe magesoe merged commit 465d210 into master Aug 20, 2025
1 check passed
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.

Error when rebuilding projects that use the analyzer

2 participants