Add Roslyn Analyzer package for Microsoft.Identity.Web v4 migration#3542
Draft
Add Roslyn Analyzer package for Microsoft.Identity.Web v4 migration#3542
Conversation
Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add Roslyn analyzer and code fixers for v4 migration
Add Roslyn Analyzer package for Microsoft.Identity.Web v4 migration
Oct 10, 2025
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.
Overview
This PR implements a Roslyn Analyzer package (
Microsoft.Identity.Web.Analyzers) to help developers migrate from Microsoft.Identity.Web v3.x to v4.0.0 by detecting obsolete APIs and breaking changes at compile time.Problem
With the v4.0.0 release, several APIs have been deprecated or replaced:
TokenAcquirerTokenCredentialandTokenAcquirerAppTokenCredential→ replaced byMicrosoftIdentityTokenCredentialAddDownstreamWebApiextension method → replaced byAddDownstreamApiIDownstreamWebApiinterface → replaced byIDownstreamApiDevelopers need compile-time assistance to identify and migrate away from these obsolete APIs.
Solution
Diagnostic Analyzers
Implemented four diagnostic analyzers that detect obsolete API usage:
IDW4001: TokenAcquirerTokenCredential is obsolete
IDW4002: TokenAcquirerAppTokenCredential is obsolete
IDW4003: AddDownstreamWebApi is obsolete
IDW4004: IDownstreamWebApi is obsolete
Package Structure
Analyzer Project (
src/Microsoft.Identity.Web.Analyzers/):AnalyzerReleases.*.md)Test Project (
tests/Microsoft.Identity.Web.Analyzers.Test/):Usage
Developers can install the analyzer as a development dependency:
Or in the project file:
The analyzers will automatically run during build and provide warnings with clear guidance on replacements and links to migration documentation.
Testing
Documentation
Related
Fixes #[issue_number]
Original prompt
Fixes #3539
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.