feat(analyzers): ship QuerySpec.Analyzers package with QSPEC0001/2/3 diagnostics and code fixes#153
Merged
AbongileBoja merged 2 commits intodevelopfrom Apr 27, 2026
Merged
Conversation
…ostics and code fixes Adds two new netstandard2.0 projects (QuerySpec.Analyzers and QuerySpec.Analyzers.CodeFixes, packed together in one nupkg under analyzers/dotnet/cs/) plus a tri-TFM xUnit test project covering the three migration diagnostics: - QSPEC0001: GeoLocation.Latitude/.Longitude member access -> GeoCoordinate - QSPEC0002: AdvancedFilterExpression object creation -> FilterSpec - QSPEC0003: ICacheProvider.GetAsync/SetAsync invocation -> ICacheStore.TryGetAsync/SetValueAsync Each analyzer registers narrowly-scoped syntax-kind callbacks (member access, object creation, invocation respectively), matches via the semantic model rather than syntax text, and suppresses itself when the target member already carries a matching [Obsolete(DiagnosticId)] attribute so consumers see exactly one warning per call site. Code fix providers use BatchFixer for FixAll support and emit well-formed compilable replacements; the cache provider rewrite leaves any needed variable-typing change to the developer (documented in the fix's title and message). netstandard2.0 is the documented exception to the repo TFM policy because Roslyn loads analyzers into a netstandard2.0 ALC regardless of the consumer's target. RS1038 enforces analyzer assemblies cannot reference Microsoft.CodeAnalysis.Workspaces, so analyzers and code fixes ship in separate sibling projects (Microsoft canonical pattern). 27 tests x 3 TFMs = 81 green; zero analyzer warnings; nupkg layout verified. Refs #151
AbongileBoja
commented
Apr 27, 2026
Owner
Author
AbongileBoja
left a comment
There was a problem hiding this comment.
Quality-reviewer gate: PASS. All checklist items verified. Build/test/format/reproducibility/vuln-scan/dep-review/commitlint: pass. CodeQL: pass. See full review summary in PR dispatch chat.
Replace placeholder QuerySpec.Core icon with the dedicated Analyzers logo. Resized to 512x512 with white padding to honor NuGet's <=1MB icon limit (NU5047) and the square-icon convention used on nuget.org. Refs #151
This was referenced Apr 27, 2026
Merged
AbongileBoja
added a commit
that referenced
this pull request
Apr 29, 2026
Microsoft.Sbom.Targets 4.1.5 handles IncludeBuildOutput=false analyzer-shape packs correctly. The GenerateSBOM=false override from PR #153 was set when Sbom.Targets 3.x could not emit the manifest into a no-build-output pack; that limitation no longer exists. Removing the override lets Directory.Build.props drive SBOM generation for all packable projects uniformly. Fixes #248
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.
Summary
Ships QuerySpec.Analyzers — a standalone Roslyn analyzer + code-fix NuGet package that powers the 3.x → 4.0 migration window for the three deprecated APIs introduced in #84:
QSPEC0001GeoLocation.Latitude/.Longitudemember accessGeoCoordinate(calllegacy.ToGeoCoordinate().Latitude)QSPEC0002new AdvancedFilterExpression { ... }FilterSpec(immutable record withinitaccessors)QSPEC0003ICacheProvider.GetAsync<T>/SetAsync<T>invocationICacheStore.TryGetAsync<T>/SetValueAsync<T>All three carry one-click code fixes and Fix-All-In-Document/Project/Solution support via
WellKnownFixAllProviders.BatchFixer.Closes #151.
Files added
QuerySpec.sln updated; CHANGELOG
[Unreleased] -> Addedentry added.Architecture decisions
Standalone NuGet package, not bundled into QuerySpec.Core. Microsoft's canonical pattern (
Microsoft.AspNetCore.App.Analyzers,System.Text.Json.SourceGeneration) lets consumers update analyzers independently of runtime. Adding the analyzer DLL inside QuerySpec.Core's nupkg would lock the analyzer cadence to the runtime cadence and leak the analyzer'sMicrosoft.CodeAnalysis.*dependency edges into the runtime package's metadata.Two-assembly split (
QuerySpec.Analyzers+QuerySpec.Analyzers.CodeFixes). RS1038 forbids analyzer assemblies from referencingMicrosoft.CodeAnalysis.Workspaces(which only loads in IDE/CLI compile-only scenarios fail otherwise). Code fixes legitimately need Workspaces. Both DLLs ship in the same nupkg underanalyzers/dotnet/cs/.netstandard2.0TFM. This is the documented exception to the repo-wide net8/9/10 policy (Directory.Build.props comment +<TargetFramework>override + this PR's CHANGELOG entry): Roslyn loads analyzers into a netstandard2.0 ALC regardless of the consumer project's target.Self-suppression on
[Obsolete(DiagnosticId="QSPEC####")]. The 3.1 source already carries those attributes, so the compiler emits the diagnostic and our analyzer would otherwise duplicate it. Each analyzer walks the candidate symbol's attributes (and, forICacheProvider, the implemented interface members) and skips emission when a matchingDiagnosticIdis found. Net result: consumers see exactly one warning per call site, sourced from whichever path is available.Code-fix scope: the
QSPEC0003fix deliberately does NOT auto-rewrite the variable's declared type fromICacheProvidertoICacheStore. That's a cross-file decision the developer should make in context (DI registration, downstream usages). The fix produces well-formed code only when the receiver implementsICacheStore; otherwise the developer gets a compile error guiding them to the next migration step. Test cases cover the well-typed scenario via a dual-interfaceTestCacheProviderstub matching the shippingMemoryCacheProvider/DistributedCacheProvider/MultiLevelCacheshape.Test plan
dotnet build -c Release -p:QUERYSPEC_SKIP_SIGN=true— clean (0 errors, 624 pre-existing Meziantou warnings unchanged)dotnet test tests/QuerySpec.Analyzers.Tests/QuerySpec.Analyzers.Tests.csproj— 27 tests x 3 TFMs (net8/9/10) = 81 greendotnet pack src/QuerySpec.Analyzers/QuerySpec.Analyzers.csproj -c Release -p:QUERYSPEC_SKIP_SIGN=true— produces valid .nupkgunzip -l QuerySpec.Analyzers.0.0.0-local.nupkg— confirmsanalyzers/dotnet/cs/QuerySpec.Analyzers.dllandanalyzers/dotnet/cs/QuerySpec.Analyzers.CodeFixes.dll, README, icon presentdotnet test tests/QuerySpec.Core.Tests/...— 636/636 net8 (no regression, analyzer is consumer-side)dotnet test tests/QuerySpec.EFCore.Tests/...— 91/91 net8 (no regression)Per-test coverage matrix (each analyzer + code-fix pair):
GeoCoordinate,FilterSpec,ICacheStore)#pragma warning disable QSPEC####suppression[Obsolete(DiagnosticId)]HelpLinkUriconstant verification