Skip to content

Local and Copilot dev can generate public apis #30500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2025
Merged

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Jul 8, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Currently, the only way is to use the IDE and the lightbulb - or manually. This is often not successful and AI still struggles as well.

The new version of the Mono.ApiTools.MSBuildTasks package now has the ability to generate the files and they can be checked in during development to show the actual API changes.

The rules would be if this is release of CI, then it is set to Validate only, and then only if it is debug AND not CI (ie: local) will it enable generation.

Issues Fixed

The pain of trying to get IDEs to actually generate files in a multi-targeted world.

@Copilot Copilot AI review requested due to automatic review settings July 8, 2025 20:47
@mattleibow mattleibow requested a review from a team as a code owner July 8, 2025 20:47
@mattleibow mattleibow requested review from jfversluis and rmarinho July 8, 2025 20:47
Copy link
Contributor

@Copilot 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

This PR enables automatic generation of public API files locally and via Copilot by integrating the updated Mono.ApiTools.MSBuildTasks package, adding conditional logic in the PublicAPI build targets, and recording new API changes.

  • Remove hard-coded version for Mono.ApiTools.MSBuildTasks and centralize versioning
  • Introduce PublicApiType conditions and a _GeneratePublicApiFiles target in PublicAPI.targets
  • Update PublicAPI.Unshipped.txt across TFMs for new API signatures and hide fields

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/SingleProject/Resizetizer/src/Resizetizer.csproj Drop explicit Version="0.3.0" to use central version management
src/PublicAPI.targets Add PublicApiType conditions, conditional analyzer/tasks package refs, and new generate target
src/Controls/src/Core/PublicAPI/*/PublicAPI.Unshipped.txt Record hiding of Element.transientNamescope and updated FlexLayout.CrossPlatformMeasure
src/Controls/src/Core/Layout/FlexLayout.cs Remove pragma warnings around the public CrossPlatformMeasure override
src/Controls/src/Core/Element/Element.cs Remove pragma warnings around the public transientNamescope field
eng/Versions.props Bump MonoApiToolsMSBuildTasksPackageVersion to 0.4.0
eng/NuGetVersions.targets Add Mono.ApiTools.MSBuildTasks central package reference
Comments suppressed due to low confidence (4)

src/PublicAPI.targets:40

  • Add automated tests (unit or integration) covering the new _GeneratePublicApiFiles target to verify that API files are generated correctly under the Generate condition.
  <Target Name="_GeneratePublicApiFiles" AfterTargets="Build" Condition="'$(TargetFramework)' != '' and '$(PublicApiType)' == 'Generate'">

src/Controls/src/Core/Layout/FlexLayout.cs:467

  • The RS0016 suppression pragmas around this public override were removed. This can lead to public API analyzer warnings. Reintroduce #pragma warning disable RS0016 before and #pragma warning restore RS0016 after the method to limit the suppression scope.
		new public Graphics.Size CrossPlatformMeasure(double widthConstraint, double heightConstraint)

src/Controls/src/Core/Element/Element.cs:507

  • The pragma disable/restore for RS0016 was removed around this field, causing potential analyzer failures. Add back #pragma warning disable RS0016 above and #pragma warning restore RS0016 below this declaration.
		public INameScope transientNamescope;

src/SingleProject/Resizetizer/src/Resizetizer.csproj:36

  • Removing the explicit version relies on central version management. Verify that eng/Versions.props defines the correct version to avoid mismatched package versions in local vs CI builds.
    <PackageReference Include="Mono.ApiTools.MSBuildTasks" PrivateAssets="all" />

@mattleibow
Copy link
Member Author

/rebase

Currently, the only way is to use the IDE and the lightbulb - or manually.
This is often not successful and AI still struggles as well.

The new version of the Mono.ApiTools.MSBuildTasks package now has
the ability to generate the files and they can be checked in during
development to show the actual API changes.

Local dev will start generating automatically.

The rules would be if this is release of CI, then it is set to Validate only,
and then only if it is debug AND not CI (ie: local) will it enable generation.
@mattleibow mattleibow merged commit c256626 into main Jul 16, 2025
1 of 34 checks passed
@mattleibow mattleibow deleted the dev/auto-public branch July 16, 2025 15:24
@mattleibow
Copy link
Member Author

/backport to net10.0

Copy link
Contributor

Started backporting to net10.0: https://github.com/dotnet/maui/actions/runs/16323633832

@mattleibow
Copy link
Member Author

/backport to inflight/current

This comment was marked as off-topic.

Copy link
Contributor

Started backporting to inflight/current: https://github.com/dotnet/maui/actions/runs/16323643779

mattleibow added a commit that referenced this pull request Jul 16, 2025
* Local and Copilot dev can generate public apis

Currently, the only way is to use the IDE and the lightbulb - or manually.
This is often not successful and AI still struggles as well.

The new version of the Mono.ApiTools.MSBuildTasks package now has
the ability to generate the files and they can be checked in during
development to show the actual API changes.

The rules would be if this is release of CI, then it is set to Validate only,
and then only if it is debug AND not CI (ie: local) will it enable generation.

# Conflicts:
#	src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
mattleibow added a commit that referenced this pull request Jul 16, 2025
* Local and Copilot dev can generate public apis

Currently, the only way is to use the IDE and the lightbulb - or manually.
This is often not successful and AI still struggles as well.

The new version of the Mono.ApiTools.MSBuildTasks package now has
the ability to generate the files and they can be checked in during
development to show the actual API changes.

The rules would be if this is release of CI, then it is set to Validate only,
and then only if it is debug AND not CI (ie: local) will it enable generation.

# Conflicts:
#	src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
PureWeen pushed a commit that referenced this pull request Jul 17, 2025
* Local and Copilot dev can generate public apis

Currently, the only way is to use the IDE and the lightbulb - or manually.
This is often not successful and AI still struggles as well.

The new version of the Mono.ApiTools.MSBuildTasks package now has
the ability to generate the files and they can be checked in during
development to show the actual API changes.

The rules would be if this is release of CI, then it is set to Validate only,
and then only if it is debug AND not CI (ie: local) will it enable generation.

# Conflicts:
#	src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
PureWeen pushed a commit that referenced this pull request Jul 17, 2025
* Local and Copilot dev can generate public apis (#30500)

* Local and Copilot dev can generate public apis

Currently, the only way is to use the IDE and the lightbulb - or manually.
This is often not successful and AI still struggles as well.

The new version of the Mono.ApiTools.MSBuildTasks package now has
the ability to generate the files and they can be checked in during
development to show the actual API changes.

The rules would be if this is release of CI, then it is set to Validate only,
and then only if it is debug AND not CI (ie: local) will it enable generation.

# Conflicts:
#	src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt

* regen
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.

2 participants