Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Migration to Microsoft.CodeAnalysis.PublicApiAnalyzers

  • Add Microsoft.CodeAnalysis.PublicApiAnalyzers package to Directory.Build.props
  • Create PublicAPI.Shipped.txt for Microsoft.OpenApi project (1,979 API entries)
  • Create PublicAPI.Unshipped.txt for Microsoft.OpenApi project
  • Create PublicAPI.Shipped.txt for Microsoft.OpenApi.YamlReader project (15 API entries)
  • Create PublicAPI.Unshipped.txt for Microsoft.OpenApi.YamlReader project
  • Remove PublicApiGenerator from test project
  • Remove old PublicApi test directory and PublicApiTests.cs
  • Update test project to remove references to old PublicApi files
Original prompt

This section details on the original issue you should resolve

<issue_title>switch to Microsoft.CodeAnalysis.PublicApiAnalyzers instead of custom unit test</issue_title>
<issue_description>Our PublicAPI validation logic was implemented a long time ago using a unit test.
While it "works" the dotnet team has now shipped Microsoft.CodeAnalysis.PublicApiAnalyzers which gives earlier feedback, has code fixes to automatically add new symbols to the lists and is more reliable.
We should migrate this repository so we can deliver a more robust experience.
Additionally, the yaml reader project is not covered by the unit test. We should also add the analyzers to this project to reduce the risk of public API breakages.</issue_description>

<agent_instructions>use conventional commits</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 26, 2026 16:15
- Converted test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt (2152 lines)
  to src/Microsoft.OpenApi/PublicAPI.Shipped.txt (1844 entries)
- Generated PublicAPI.Shipped.txt and PublicAPI.Unshipped.txt files for both
  Microsoft.OpenApi and Microsoft.OpenApi.YamlReader projects
- Added Microsoft.CodeAnalysis.PublicApiAnalyzers package reference in Directory.Build.props

The conversion extracted 1843 public API declarations from the PublicApiGenerator
format and converted them to the Microsoft.CodeAnalysis.PublicApiAnalyzers format:
- Types (classes, interfaces, structs, enums, delegates)
- Constructors
- Methods
- Properties (with get/set accessors)
- Fields (including const fields)
- Events
- Enum values with their numeric assignments

Note: Build validation and potential missing API entries will need to be addressed
in follow-up work as the PublicApiAnalyzers may identify additional public APIs
not captured in the original PublicApiGenerator output.
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
- Generated public API using PublicApiGenerator for Microsoft.OpenApi.YamlReader assembly
- Converted to PublicApiAnalyzers format and added to PublicAPI.Unshipped.txt
- Made static ReadFragment<T>(JsonNode...) method internal to resolve RS0016 and RS0026 analyzer errors
- Resolved RS0016/RS0017 analyzer errors for YamlReader project
- Note: RS0036 nullability annotation warnings remain but are separate from PublicAPI format issues

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
@baywet baywet marked this pull request as ready for review January 27, 2026 20:18
@baywet baywet requested a review from a team as a code owner January 27, 2026 20:18
@baywet baywet enabled auto-merge (squash) January 27, 2026 20:18
@baywet baywet changed the title [WIP] Switch to Microsoft.CodeAnalysis.PublicApiAnalyzers for validation Switch to Microsoft.CodeAnalysis.PublicApiAnalyzers for validation Jan 27, 2026
@sonarqubecloud
Copy link

@baywet baywet merged commit 0156943 into main Jan 27, 2026
15 of 18 checks passed
@baywet baywet deleted the copilot/migrate-to-public-api-analyzers branch January 27, 2026 20:21
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.

switch to Microsoft.CodeAnalysis.PublicApiAnalyzers instead of custom unit test

3 participants