Skip to content

[Microsoft.Gen.Logging] Fully qualify classification types - #7689

Open
Rimobul wants to merge 1 commit into
dotnet:mainfrom
Rimobul:lsokolovsky/issue-7157
Open

[Microsoft.Gen.Logging] Fully qualify classification types#7689
Rimobul wants to merge 1 commit into
dotnet:mainfrom
Rimobul:lsokolovsky/issue-7157

Conversation

@Rimobul

@Rimobul Rimobul commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #7157

Use SymbolDisplayFormat.FullyQualifiedFormat for the classification attributes collected from parameters, properties, base types and record constructor parameters, and emit the DataClassification field type with a global:: prefix as well. The global:: prefix is stripped before deriving the field name, so generated field names are unchanged.

Microsoft Reviewers: Open in CodeFlow

Fixes dotnet#7157

Use SymbolDisplayFormat.FullyQualifiedFormat for the classification
attributes collected from parameters, properties, base types and record
constructor parameters, and emit the DataClassification field type with
a global:: prefix as well. The global:: prefix is stripped before
deriving the field name, so generated field names are unchanged.
Copilot AI review requested due to automatic review settings August 7, 2026 14:03
@Rimobul
Rimobul requested a review from a team as a code owner August 7, 2026 14:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Microsoft.Gen.Logging source generator to emit globally-qualified (global::) type names for data-classification attributes (and the generated DataClassification field type) to avoid namespace-collision compilation failures like the one reported in #7157.

Changes:

  • Switch classification-attribute type rendering to SymbolDisplayFormat.FullyQualifiedFormat when collecting attributes from parameters, properties, and base types.
  • Emit the generated DataClassification backing fields using a global::-qualified DataClassification type, while preserving existing generated field naming by stripping global:: before encoding.
  • Add a regression test that runs the generator over a full compilation and verifies the emitted source matches the expected snapshot and compiles cleanly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/Generators/Microsoft.Gen.Logging/Verified/AttributeParserTests.DataClassificationAttributeNamespaceIsGloballyQualified.verified.txt New verified snapshot asserting global:: qualification in generated output.
test/Generators/Microsoft.Gen.Logging/Unit/AttributeParserTests.cs Adds compilation-based regression test + snapshot verification for the namespace-collision scenario.
src/Generators/Microsoft.Gen.Logging/Parsing/Parser.LogProperties.cs Ensures classification attribute types gathered from properties/base types are fully qualified.
src/Generators/Microsoft.Gen.Logging/Parsing/Parser.cs Ensures classification attribute types gathered from parameters are fully qualified.
src/Generators/Microsoft.Gen.Logging/Emission/Emitter.cs Emits DataClassification field type with global:: and preserves field naming by stripping global:: for encoding.

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.

Redaction LoggerMessage generator fails when classification namespace requires global::

2 participants