Skip to content

Fix redacting log article: pushed code out to snippets and added missing classes#55006

Merged
adegeo merged 6 commits into
mainfrom
adegeo/54570/logging
Jul 24, 2026
Merged

Fix redacting log article: pushed code out to snippets and added missing classes#55006
adegeo merged 6 commits into
mainfrom
adegeo/54570/logging

Conversation

@adegeo

@adegeo adegeo commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pushed code from inline to snippets.
  • Added missing information that were declared in other articles.

Fixes #54570


Internal previews

📄 File 🔗 Preview link
docs/core/extensions/logging/source-generation.md Compile-time logging source generation

Copilot AI review requested due to automatic review settings July 23, 2026 18:21
@adegeo
adegeo requested review from a team and gewarren as code owners July 23, 2026 18:21
@dotnetrepoman dotnetrepoman Bot added this to the July 2026 milestone Jul 23, 2026

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 compile-time logging source-generation article to use external snippet files (instead of inline code blocks) and fixes the “Redacting sensitive information in logs” example by including the previously missing supporting types in the snippet source.

Changes:

  • Replaced multiple inline C# examples in source-generation.md with :::code snippet references.
  • Added a new C# snippets project and extracted example code into dedicated snippet files.
  • Added supporting redaction and data-classification types to make the redaction example self-contained.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/core/extensions/logging/source-generation.md Replaces inline examples with snippet references, including the redaction section.
docs/core/extensions/logging/snippets/source-generation/csharp/csharp.csproj Adds a snippet project to compile the extracted examples.
docs/core/extensions/logging/snippets/source-generation/csharp/Program.cs Adds a minimal entry point for the snippets project.
docs/core/extensions/logging/snippets/source-generation/csharp/BasicUsage/StaticLog.cs Adds snippet source for basic static LoggerMessage usage.
docs/core/extensions/logging/snippets/source-generation/csharp/BasicUsage/ExtensionLog.cs Adds snippet source for extension-method LoggerMessage usage.
docs/core/extensions/logging/snippets/source-generation/csharp/BasicUsage/InstanceLog.cs Adds snippet source for instance/field-based logger usage.
docs/core/extensions/logging/snippets/source-generation/csharp/BasicUsage/PrimaryCtorLog.cs Adds snippet source for primary-constructor logger usage.
docs/core/extensions/logging/snippets/source-generation/csharp/BasicUsage/DynamicLog.cs Adds snippet source for dynamic log level usage.
docs/core/extensions/logging/snippets/source-generation/csharp/LogMethodAnatomy/LogMethods.cs Adds snippet source for a “valid log method” example.
docs/core/extensions/logging/snippets/source-generation/csharp/LogMethodAnatomy/IndeterminateOrder.cs Adds snippet source for indeterminate parameter ordering example.
docs/core/extensions/logging/snippets/source-generation/csharp/LogMethodAnatomy/CaseInsensitiveExample.cs Adds snippet source for case-insensitive template name support example.
docs/core/extensions/logging/snippets/source-generation/csharp/MoreLoggingExamples/LoggingSample.cs Adds snippet source for additional logging examples section.
docs/core/extensions/logging/snippets/source-generation/csharp/RedactingSensitiveInformation/RedactionSetup.cs Adds self-contained redaction setup snippet (taxonomy, attribute, and redactor).

Comment thread docs/core/extensions/logging/source-generation.md Outdated
Comment thread docs/core/extensions/logging/source-generation.md Outdated
Comment thread docs/core/extensions/logging/snippets/source-generation/csharp/Usings.cs Outdated
adegeo and others added 3 commits July 23, 2026 15:11
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@adegeo
adegeo merged commit e613b05 into main Jul 24, 2026
12 checks passed
@adegeo
adegeo deleted the adegeo/54570/logging branch July 24, 2026 17:04
[LoggerMessage(0, LogLevel.Information, "User SSN: {SSN}")]
public static partial void LogPrivateInformation(
this ILogger logger,
[MyTaxonomyClassifications.Private] string SSN);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is incorrect as reported in #54570
[MyTaxonomyClassifications.Private]

@adegeo adegeo Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @laicasaane this does work, it's resolving to PrivateAttribute, even though you type in Private. We have a compiler running as an action that compiles the code snippets and blocks the PR if it won't compile.

I think the reason why it didn't work for you was because you were working with an incomplete snippet and had to cobble it together and you were just missing the actual attribute definition.

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.

Incomplete code example and error in "Redacting sensitive information in logs"

4 participants