diff --git a/README.md b/README.md index ff28d30..6269de0 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ When published, consume it as a development-only analyzer dependency: + IncludeAssets="analyzers; buildtransitive" /> ``` For local evaluation from this checkout, reference the analyzer project directly from a consumer project: @@ -64,7 +64,7 @@ activity.SetTag("error.message", message); // QYL0031; replacem - **Multi-hop rename resolution.** `SemconvMigrationCatalog.ResolveTerminalReplacement` chases `ExactRename` chains (e.g. `http.host` → `net.host.name` → `server.address`) so code-fixes land consumers on the terminal symbol, not on a still-deprecated mid-state. Cycles and chains over 8 hops bail at the last safe step. - **Structured changelog provenance.** Every `SemconvMigrationCatalogEntry` may carry an optional `SemconvChangelogEvidence` (commit / version / url / quote) pinning the migration claim to an exact upstream commit, so the catalog is auditable without re-parsing CHANGELOG.md. - **Catalog seeding from upstream.** `scripts/seed-catalog.sh ` clones a shallow upstream `open-telemetry/semantic-conventions` checkout, slices CHANGELOG.md between two version tags, and emits C# (or `--format json`) skeleton entries with provenance pre-filled. Curate the `Kind`/`Domain`/`Signal`/`MigrationKind` fields by hand before merging. -- **Generated docs and audit.** Regenerate the package catalog with `scripts/generate-docs.sh generate`; validate with `scripts/generate-docs.sh validate`; print the current 156-entry coverage audit with `scripts/generate-docs.sh audit`. Every `QYL*` rule has a stable `#qyl0010` anchor in the generated docs that every `DiagnosticDescriptor.HelpLinkUri` resolves to. +- **Generated docs and audit.** Regenerate the package catalog with `scripts/generate-docs.sh generate`; validate with `scripts/generate-docs.sh validate`; print the current coverage audit with `scripts/generate-docs.sh audit`. Every `QYL*` rule has a stable `#qyl0010` anchor in the generated docs that every `DiagnosticDescriptor.HelpLinkUri` resolves to. - **netstandard2.0** only — required by Roslyn analyzer host. Microsoft.CodeAnalysis.* dependencies only. - **Multi-version friendly.** A consumer on SemConv 1.39.0 gets live metadata diagnostics scoped to the 1.39.0 surface; upgrading expands those diagnostics automatically. The supplemental catalog is a conservative v1.41.0 migration aid. @@ -135,7 +135,7 @@ tests/WeaverRoundTrip/generate.sh # 4. Confirm the analyzer fires QYL0010 against the regenerated file: dotnet build Qyl.OpenTelemetry.SemanticConventions.Analyzers.slnx \ -c Release -warnaserror:QYL0010 -dotnet test tests/Qyl.OpenTelemetry.SemanticConventions.Analyzers.Tests/Qyl.OpenTelemetry.SemanticConventions.Analyzers.Tests.csproj \ +dotnet test tests/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.Tests/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.Tests.csproj \ --filter 'FullyQualifiedName~WeaverRoundTrip' ``` @@ -147,7 +147,7 @@ Run the repository gates before changing diagnostics, catalog data, or generated ```bash dotnet build Qyl.OpenTelemetry.SemanticConventions.Analyzers.slnx -c Release -dotnet test tests/Qyl.OpenTelemetry.SemanticConventions.Analyzers.Tests/Qyl.OpenTelemetry.SemanticConventions.Analyzers.Tests.csproj +dotnet test tests/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.Tests/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.Tests.csproj scripts/generate-docs.sh validate scripts/generate-docs.sh audit git diff --check @@ -155,7 +155,7 @@ git diff --check ## Incubation -This repository is the incubation home for what may eventually be proposed as an official `OpenTelemetry.SemanticConventions.Analyzers` companion to `opentelemetry-dotnet-contrib`. While here, it ships under the `ANcpLua.*` package ID and Apache-2.0 license. +This repository is the incubation home for what may eventually be proposed as an official `OpenTelemetry.SemanticConventions.Analyzers` companion to `opentelemetry-dotnet-contrib`. While here, it ships under the `Qyl.*` package ID and Apache-2.0 license. ## License diff --git a/docs/Qyl.OpenTelemetry.SemanticConventions.Analyzers.md b/docs/Qyl.OpenTelemetry.SemanticConventions.Analyzers.md index 0fd0b20..f1ed0a0 100644 --- a/docs/Qyl.OpenTelemetry.SemanticConventions.Analyzers.md +++ b/docs/Qyl.OpenTelemetry.SemanticConventions.Analyzers.md @@ -1,6 +1,6 @@ # Qyl.OpenTelemetry.SemanticConventions.Analyzers - + This package analyzes OpenTelemetry semantic-convention usage in C# consumers. The consumer's referenced `OpenTelemetry.SemanticConventions` assembly remains the primary source of truth: rules that read `[Obsolete]` metadata report what that package actually generated. The curated inventory below separates live-metadata coverage from supplemental diagnostics for changelog/model entries that are not reliably visible through live metadata. @@ -458,8 +458,8 @@ These value rows are intentionally separate from the 156-entry name/key/event/me Regenerate with: ```bash -dotnet run -c Release --project tools/Qyl.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator -dotnet run -c Release --project tools/Qyl.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator -- --check +dotnet run -c Release --project tools/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator +dotnet run -c Release --project tools/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator -- --check ``` The `--check` mode fails if the generated markdown differs from the checked-in file. diff --git a/tools/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator/Program.cs b/tools/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator/Program.cs index 6233d8d..4a56ea2 100644 --- a/tools/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator/Program.cs +++ b/tools/ANcpLua.OpenTelemetry.SemanticConventions.Analyzers.DocsGenerator/Program.cs @@ -126,9 +126,7 @@ private static void WriteDiagnostics( sb.AppendLine("| -- | -- | -- | -- | -- |"); foreach (var d in descriptors) { - var codeFix = fixableIds.Contains(d.Id) - ? d.Id == "QYL0030" ? "Exact replacements only" : "Yes" - : "No"; + var codeFix = GetCodeFixLabel(d.Id, fixableIds); sb.AppendLine($"| {d.Id} | {d.DefaultSeverity} | {Escape(d.Title.ToString())} | {codeFix} | {Escape(d.Description.ToString())} |"); } } @@ -154,14 +152,26 @@ private static void WriteDiagnosticAnchors( sb.AppendLine(); sb.AppendLine(Escape(d.Description.ToString())); sb.AppendLine(); - var codeFix = fixableIds.Contains(d.Id) - ? d.Id == "QYL0030" ? "Exact replacements only." : "Yes." - : "No."; - sb.AppendLine($"Code fix: {codeFix}"); + sb.AppendLine($"Code fix: {GetCodeFixLabel(d.Id, fixableIds)}."); sb.AppendLine(); } } + private static string GetCodeFixLabel(string diagnosticId, HashSet fixableIds) + { + if (!fixableIds.Contains(diagnosticId)) + { + return "No"; + } + + // QYL0030/QYL0031/QYL0032 share SupplementalSemconvMigrationCodeFixProvider, + // which gates registration via IsExactReplacement (MigrationKind == ExactRename + // / ExactValueRename) per-diagnostic, not by ID. Reflect that contract in docs. + return diagnosticId is "QYL0030" or "QYL0031" or "QYL0032" + ? "Exact replacements only" + : "Yes"; + } + private static void WritePrecedenceAndSuppression(StringBuilder sb) { sb.AppendLine("## Precedence and Suppression");