Skip to content

Fix TemplateEngine RS0016/RS0041 public API analyzer violations#53978

Merged
MichaelSimons merged 3 commits intodotnet:mainfrom
MichaelSimons:templateengine-fix-public-api-analyzers
Apr 21, 2026
Merged

Fix TemplateEngine RS0016/RS0041 public API analyzer violations#53978
MichaelSimons merged 3 commits intodotnet:mainfrom
MichaelSimons:templateengine-fix-public-api-analyzers

Conversation

@MichaelSimons
Copy link
Copy Markdown
Member

@MichaelSimons MichaelSimons commented Apr 17, 2026

Summary

After merging the templating repo into the SDK, the RS0016 and RS0041 public API analyzer rules were suppressed via NoWarn in src/TemplateEngine/Directory.Build.props. This PR removes that suppression and fixes the underlying issues.

Root Cause

The SDK repo uses PublicApiAnalyzers v5.7.0 which detects compiler-synthesized members (delegate Invoke methods, record struct equality/deconstruct members) that the templating repo's v3.3.4 did not flag. The PublicAPI.*.txt files were correct for the old analyzer but incomplete for the new one.

Changes

  • Directory.Build.props: Removed RS0016 and RS0041 from NoWarn
  • .editorconfig: Added dotnet_diagnostic.RS0041.severity = suggestion (matching the templating repo's .editorconfig)
  • PublicAPI files: Added missing synthesized members:
    • VulnerabilityInfo record struct members (Abstractions)
    • Delegate Invoke methods (Core.Contracts, Core, Authoring.TemplateVerifier)

contributes to dotnet/templating#10085

- Remove RS0016 and RS0041 from NoWarn in TemplateEngine Directory.Build.props
- Add dotnet_diagnostic.RS0041.severity = suggestion to .editorconfig
  (matching the setting from the templating repo)
- Add missing compiler-synthesized members to PublicAPI files:
  - VulnerabilityInfo record struct members (Equals, GetHashCode, ToString,
    ==, !=, Deconstruct) in Abstractions
  - Delegate Invoke methods for KeysChangedEventHander, ValueReadEventHander
    in Core.Contracts
  - Delegate Invoke methods for ConditionEvaluator, TypeConverterDelegate<T>
    in Core
  - Delegate Invoke methods for RunInstantiation, ScrubFileByPath,
    VerifyDirectory in Authoring.TemplateVerifier

These were not detected by the older PublicApiAnalyzers v3.3.4 used in the
templating repo but are flagged by v5.7.0 used in the SDK repo.

Resolves part of dotnet/templating#10085

Co-authored-by: Copilot <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes TemplateEngine’s suppression of PublicApiAnalyzers RS0016/RS0041 and updates the tracked public surface area to account for compiler-synthesized members that are now detected by the SDK’s newer analyzer version.

Changes:

  • Removed RS0016/RS0041 from src/TemplateEngine/Directory.Build.props NoWarn.
  • Adjusted TemplateEngine analyzer configuration by adding an RS0041 severity override in src/TemplateEngine/.editorconfig.
  • Updated multiple PublicAPI.*.txt files to include synthesized members (delegate Invoke, record struct synthesized members).

Reviewed changes

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

Show a summary per file
File Description
src/TemplateEngine/Tools/Microsoft.TemplateEngine.Authoring.TemplateVerifier/PublicAPI.Unshipped.txt Adds delegate Invoke entries required by PublicApiAnalyzers.
src/TemplateEngine/Microsoft.TemplateEngine.Core/PublicAPI.Shipped.txt Adds shipped delegate Invoke entries required by PublicApiAnalyzers.
src/TemplateEngine/Microsoft.TemplateEngine.Core.Contracts/PublicAPI.Unshipped.txt Adds delegate Invoke entries (note: placement vs shipped needs adjustment).
src/TemplateEngine/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt Adds synthesized record-struct members required by PublicApiAnalyzers.
src/TemplateEngine/Directory.Build.props Removes analyzer suppressions from NoWarn.
src/TemplateEngine/.editorconfig Sets RS0041 severity to suggestion for TemplateEngine projects.

Comment thread src/TemplateEngine/Directory.Build.props Outdated
MichaelSimons and others added 2 commits April 17, 2026 16:34
KeysChangedEventHander and ValueReadEventHander are already shipped
types, so their synthesized Invoke methods belong in Shipped.txt.

Co-authored-by: Copilot <[email protected]>
@MichaelSimons MichaelSimons merged commit 9f30498 into dotnet:main Apr 21, 2026
24 checks passed
@MichaelSimons MichaelSimons deleted the templateengine-fix-public-api-analyzers branch April 21, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants